1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/jaf_classes/javax/activation/DataContentHandler.java Wed Apr 27 01:27:09 2016 +0800 1.3 @@ -0,0 +1,101 @@ 1.4 +/* 1.5 + * Copyright (c) 1997, 2005, Oracle and/or its affiliates. All rights reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. Oracle designates this 1.11 + * particular file as subject to the "Classpath" exception as provided 1.12 + * by Oracle in the LICENSE file that accompanied this code. 1.13 + * 1.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.17 + * version 2 for more details (a copy is included in the LICENSE file that 1.18 + * accompanied this code). 1.19 + * 1.20 + * You should have received a copy of the GNU General Public License version 1.21 + * 2 along with this work; if not, write to the Free Software Foundation, 1.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.23 + * 1.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 1.25 + * or visit www.oracle.com if you need additional information or have any 1.26 + * questions. 1.27 + */ 1.28 + 1.29 +package javax.activation; 1.30 + 1.31 +import java.awt.datatransfer.DataFlavor; 1.32 +import java.awt.datatransfer.UnsupportedFlavorException; 1.33 +import java.io.InputStream; 1.34 +import java.io.IOException; 1.35 +import java.io.OutputStream; 1.36 +import javax.activation.DataSource; 1.37 + 1.38 +/** 1.39 + * The DataContentHandler interface is implemented by objects that can 1.40 + * be used to extend the capabilities of the DataHandler's implementation 1.41 + * of the Transferable interface. Through <code>DataContentHandlers</code> 1.42 + * the framework can be extended to convert streams in to objects, and 1.43 + * to write objects to streams. <p> 1.44 + * 1.45 + * Applications don't generally call the methods in DataContentHandlers 1.46 + * directly. Instead, an application calls the equivalent methods in 1.47 + * DataHandler. The DataHandler will attempt to find an appropriate 1.48 + * DataContentHandler that corresponds to its MIME type using the 1.49 + * current DataContentHandlerFactory. The DataHandler then calls 1.50 + * through to the methods in the DataContentHandler. 1.51 + * 1.52 + * @since 1.6 1.53 + */ 1.54 + 1.55 +public interface DataContentHandler { 1.56 + /** 1.57 + * Returns an array of DataFlavor objects indicating the flavors the 1.58 + * data can be provided in. The array should be ordered according to 1.59 + * preference for providing the data (from most richly descriptive to 1.60 + * least descriptive). 1.61 + * 1.62 + * @return The DataFlavors. 1.63 + */ 1.64 + public DataFlavor[] getTransferDataFlavors(); 1.65 + 1.66 + /** 1.67 + * Returns an object which represents the data to be transferred. 1.68 + * The class of the object returned is defined by the representation class 1.69 + * of the flavor. 1.70 + * 1.71 + * @param df The DataFlavor representing the requested type. 1.72 + * @param ds The DataSource representing the data to be converted. 1.73 + * @return The constructed Object. 1.74 + * @exception UnsupportedFlavorException if the handler doesn't 1.75 + * support the requested flavor 1.76 + * @exception IOException if the data can't be accessed 1.77 + */ 1.78 + public Object getTransferData(DataFlavor df, DataSource ds) 1.79 + throws UnsupportedFlavorException, IOException; 1.80 + 1.81 + /** 1.82 + * Return an object representing the data in its most preferred form. 1.83 + * Generally this will be the form described by the first DataFlavor 1.84 + * returned by the <code>getTransferDataFlavors</code> method. 1.85 + * 1.86 + * @param ds The DataSource representing the data to be converted. 1.87 + * @return The constructed Object. 1.88 + * @exception IOException if the data can't be accessed 1.89 + */ 1.90 + public Object getContent(DataSource ds) throws IOException; 1.91 + 1.92 + /** 1.93 + * Convert the object to a byte stream of the specified MIME type 1.94 + * and write it to the output stream. 1.95 + * 1.96 + * @param obj The object to be converted. 1.97 + * @param mimeType The requested MIME type of the resulting byte stream. 1.98 + * @param os The output stream into which to write the converted 1.99 + * byte stream. 1.100 + * @exception IOException errors writing to the stream 1.101 + */ 1.102 + public void writeTo(Object obj, String mimeType, OutputStream os) 1.103 + throws IOException; 1.104 +}