aoqi@0: /* aoqi@0: * Copyright (c) 1997, 2005, Oracle and/or its affiliates. All rights reserved. aoqi@0: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. aoqi@0: * aoqi@0: * This code is free software; you can redistribute it and/or modify it aoqi@0: * under the terms of the GNU General Public License version 2 only, as aoqi@0: * published by the Free Software Foundation. Oracle designates this aoqi@0: * particular file as subject to the "Classpath" exception as provided aoqi@0: * by Oracle in the LICENSE file that accompanied this code. aoqi@0: * aoqi@0: * This code is distributed in the hope that it will be useful, but WITHOUT aoqi@0: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or aoqi@0: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License aoqi@0: * version 2 for more details (a copy is included in the LICENSE file that aoqi@0: * accompanied this code). aoqi@0: * aoqi@0: * You should have received a copy of the GNU General Public License version aoqi@0: * 2 along with this work; if not, write to the Free Software Foundation, aoqi@0: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. aoqi@0: * aoqi@0: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA aoqi@0: * or visit www.oracle.com if you need additional information or have any aoqi@0: * questions. aoqi@0: */ aoqi@0: aoqi@0: package javax.activation; aoqi@0: aoqi@0: import java.awt.datatransfer.DataFlavor; aoqi@0: import java.awt.datatransfer.UnsupportedFlavorException; aoqi@0: import java.io.InputStream; aoqi@0: import java.io.IOException; aoqi@0: import java.io.OutputStream; aoqi@0: import javax.activation.DataSource; aoqi@0: aoqi@0: /** aoqi@0: * The DataContentHandler interface is implemented by objects that can aoqi@0: * be used to extend the capabilities of the DataHandler's implementation aoqi@0: * of the Transferable interface. Through DataContentHandlers aoqi@0: * the framework can be extended to convert streams in to objects, and aoqi@0: * to write objects to streams.

aoqi@0: * aoqi@0: * Applications don't generally call the methods in DataContentHandlers aoqi@0: * directly. Instead, an application calls the equivalent methods in aoqi@0: * DataHandler. The DataHandler will attempt to find an appropriate aoqi@0: * DataContentHandler that corresponds to its MIME type using the aoqi@0: * current DataContentHandlerFactory. The DataHandler then calls aoqi@0: * through to the methods in the DataContentHandler. aoqi@0: * aoqi@0: * @since 1.6 aoqi@0: */ aoqi@0: aoqi@0: public interface DataContentHandler { aoqi@0: /** aoqi@0: * Returns an array of DataFlavor objects indicating the flavors the aoqi@0: * data can be provided in. The array should be ordered according to aoqi@0: * preference for providing the data (from most richly descriptive to aoqi@0: * least descriptive). aoqi@0: * aoqi@0: * @return The DataFlavors. aoqi@0: */ aoqi@0: public DataFlavor[] getTransferDataFlavors(); aoqi@0: aoqi@0: /** aoqi@0: * Returns an object which represents the data to be transferred. aoqi@0: * The class of the object returned is defined by the representation class aoqi@0: * of the flavor. aoqi@0: * aoqi@0: * @param df The DataFlavor representing the requested type. aoqi@0: * @param ds The DataSource representing the data to be converted. aoqi@0: * @return The constructed Object. aoqi@0: * @exception UnsupportedFlavorException if the handler doesn't aoqi@0: * support the requested flavor aoqi@0: * @exception IOException if the data can't be accessed aoqi@0: */ aoqi@0: public Object getTransferData(DataFlavor df, DataSource ds) aoqi@0: throws UnsupportedFlavorException, IOException; aoqi@0: aoqi@0: /** aoqi@0: * Return an object representing the data in its most preferred form. aoqi@0: * Generally this will be the form described by the first DataFlavor aoqi@0: * returned by the getTransferDataFlavors method. aoqi@0: * aoqi@0: * @param ds The DataSource representing the data to be converted. aoqi@0: * @return The constructed Object. aoqi@0: * @exception IOException if the data can't be accessed aoqi@0: */ aoqi@0: public Object getContent(DataSource ds) throws IOException; aoqi@0: aoqi@0: /** aoqi@0: * Convert the object to a byte stream of the specified MIME type aoqi@0: * and write it to the output stream. aoqi@0: * aoqi@0: * @param obj The object to be converted. aoqi@0: * @param mimeType The requested MIME type of the resulting byte stream. aoqi@0: * @param os The output stream into which to write the converted aoqi@0: * byte stream. aoqi@0: * @exception IOException errors writing to the stream aoqi@0: */ aoqi@0: public void writeTo(Object obj, String mimeType, OutputStream os) aoqi@0: throws IOException; aoqi@0: }