KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > activation > DataContentHandler


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the "License"). You may not use this file except
5  * in compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * glassfish/bootstrap/legal/CDDLv1.0.txt or
9  * https://glassfish.dev.java.net/public/CDDLv1.0.html.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * HEADER in each file and include the License file at
15  * glassfish/bootstrap/legal/CDDLv1.0.txt. If applicable,
16  * add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your
18  * own identifying information: Portions Copyright [yyyy]
19  * [name of copyright owner]
20  */

21
22 /*
23  * @(#)DataContentHandler.java 1.16 05/11/16
24  *
25  * Copyright 1997-2005 Sun Microsystems, Inc. All Rights Reserved.
26  */

27
28 package javax.activation;
29
30 import java.awt.datatransfer.DataFlavor JavaDoc;
31 import java.awt.datatransfer.UnsupportedFlavorException JavaDoc;
32 import java.io.InputStream JavaDoc;
33 import java.io.IOException JavaDoc;
34 import java.io.OutputStream JavaDoc;
35 import javax.activation.DataSource JavaDoc;
36
37 /**
38  * The DataContentHandler interface is implemented by objects that can
39  * be used to extend the capabilities of the DataHandler's implementation
40  * of the Transferable interface. Through <code>DataContentHandlers</code>
41  * the framework can be extended to convert streams in to objects, and
42  * to write objects to streams. <p>
43  *
44  * Applications don't generally call the methods in DataContentHandlers
45  * directly. Instead, an application calls the equivalent methods in
46  * DataHandler. The DataHandler will attempt to find an appropriate
47  * DataContentHandler that corresponds to its MIME type using the
48  * current DataContentHandlerFactory. The DataHandler then calls
49  * through to the methods in the DataContentHandler.
50  */

51
52 public interface DataContentHandler {
53     /**
54      * Returns an array of DataFlavor objects indicating the flavors the
55      * data can be provided in. The array should be ordered according to
56      * preference for providing the data (from most richly descriptive to
57      * least descriptive).
58      *
59      * @return The DataFlavors.
60      */

61     public DataFlavor JavaDoc[] getTransferDataFlavors();
62
63     /**
64      * Returns an object which represents the data to be transferred.
65      * The class of the object returned is defined by the representation class
66      * of the flavor.
67      *
68      * @param df The DataFlavor representing the requested type.
69      * @param ds The DataSource representing the data to be converted.
70      * @return The constructed Object.
71      * @exception UnsupportedFlavorException if the handler doesn't
72      * support the requested flavor
73      * @exception IOException if the data can't be accessed
74      */

75     public Object JavaDoc getTransferData(DataFlavor JavaDoc df, DataSource JavaDoc ds)
76                 throws UnsupportedFlavorException JavaDoc, IOException JavaDoc;
77
78     /**
79      * Return an object representing the data in its most preferred form.
80      * Generally this will be the form described by the first DataFlavor
81      * returned by the <code>getTransferDataFlavors</code> method.
82      *
83      * @param ds The DataSource representing the data to be converted.
84      * @return The constructed Object.
85      * @exception IOException if the data can't be accessed
86      */

87     public Object JavaDoc getContent(DataSource JavaDoc ds) throws IOException JavaDoc;
88
89     /**
90      * Convert the object to a byte stream of the specified MIME type
91      * and write it to the output stream.
92      *
93      * @param obj The object to be converted.
94      * @param mimeType The requested MIME type of the resulting byte stream.
95      * @param os The output stream into which to write the converted
96      * byte stream.
97      * @exception IOException errors writing to the stream
98      */

99     public void writeTo(Object JavaDoc obj, String JavaDoc mimeType, OutputStream JavaDoc os)
100                                                    throws IOException JavaDoc;
101 }
102
Popular Tags