Path: blob/aarch64-shenandoah-jdk8u272-b10/jaxws/src/share/jaf_classes/javax/activation/DataContentHandler.java
38877 views
/*1* Copyright (c) 1997, 2005, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package javax.activation;2627import java.awt.datatransfer.DataFlavor;28import java.awt.datatransfer.UnsupportedFlavorException;29import java.io.InputStream;30import java.io.IOException;31import java.io.OutputStream;32import javax.activation.DataSource;3334/**35* The DataContentHandler interface is implemented by objects that can36* be used to extend the capabilities of the DataHandler's implementation37* of the Transferable interface. Through <code>DataContentHandlers</code>38* the framework can be extended to convert streams in to objects, and39* to write objects to streams. <p>40*41* Applications don't generally call the methods in DataContentHandlers42* directly. Instead, an application calls the equivalent methods in43* DataHandler. The DataHandler will attempt to find an appropriate44* DataContentHandler that corresponds to its MIME type using the45* current DataContentHandlerFactory. The DataHandler then calls46* through to the methods in the DataContentHandler.47*48* @since 1.649*/5051public interface DataContentHandler {52/**53* Returns an array of DataFlavor objects indicating the flavors the54* data can be provided in. The array should be ordered according to55* preference for providing the data (from most richly descriptive to56* least descriptive).57*58* @return The DataFlavors.59*/60public DataFlavor[] getTransferDataFlavors();6162/**63* Returns an object which represents the data to be transferred.64* The class of the object returned is defined by the representation class65* of the flavor.66*67* @param df The DataFlavor representing the requested type.68* @param ds The DataSource representing the data to be converted.69* @return The constructed Object.70* @exception UnsupportedFlavorException if the handler doesn't71* support the requested flavor72* @exception IOException if the data can't be accessed73*/74public Object getTransferData(DataFlavor df, DataSource ds)75throws UnsupportedFlavorException, IOException;7677/**78* Return an object representing the data in its most preferred form.79* Generally this will be the form described by the first DataFlavor80* returned by the <code>getTransferDataFlavors</code> method.81*82* @param ds The DataSource representing the data to be converted.83* @return The constructed Object.84* @exception IOException if the data can't be accessed85*/86public Object getContent(DataSource ds) throws IOException;8788/**89* Convert the object to a byte stream of the specified MIME type90* and write it to the output stream.91*92* @param obj The object to be converted.93* @param mimeType The requested MIME type of the resulting byte stream.94* @param os The output stream into which to write the converted95* byte stream.96* @exception IOException errors writing to the stream97*/98public void writeTo(Object obj, String mimeType, OutputStream os)99throws IOException;100}101102103