12009
|
1 |
/*
|
|
2 |
* Copyright (c) 1997, 2005, Oracle and/or its affiliates. All rights reserved.
|
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
4 |
*
|
|
5 |
* This code is free software; you can redistribute it and/or modify it
|
|
6 |
* under the terms of the GNU General Public License version 2 only, as
|
|
7 |
* published by the Free Software Foundation. Oracle designates this
|
|
8 |
* particular file as subject to the "Classpath" exception as provided
|
|
9 |
* by Oracle in the LICENSE file that accompanied this code.
|
|
10 |
*
|
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that
|
|
15 |
* accompanied this code).
|
|
16 |
*
|
|
17 |
* You should have received a copy of the GNU General Public License version
|
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
20 |
*
|
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
22 |
* or visit www.oracle.com if you need additional information or have any
|
|
23 |
* questions.
|
|
24 |
*/
|
|
25 |
|
|
26 |
package javax.activation;
|
|
27 |
|
|
28 |
import java.awt.datatransfer.DataFlavor;
|
|
29 |
import java.awt.datatransfer.UnsupportedFlavorException;
|
|
30 |
import java.io.InputStream;
|
|
31 |
import java.io.IOException;
|
|
32 |
import java.io.OutputStream;
|
|
33 |
import javax.activation.DataSource;
|
|
34 |
|
|
35 |
/**
|
|
36 |
* The DataContentHandler interface is implemented by objects that can
|
|
37 |
* be used to extend the capabilities of the DataHandler's implementation
|
|
38 |
* of the Transferable interface. Through <code>DataContentHandlers</code>
|
|
39 |
* the framework can be extended to convert streams in to objects, and
|
|
40 |
* to write objects to streams. <p>
|
|
41 |
*
|
|
42 |
* Applications don't generally call the methods in DataContentHandlers
|
|
43 |
* directly. Instead, an application calls the equivalent methods in
|
|
44 |
* DataHandler. The DataHandler will attempt to find an appropriate
|
|
45 |
* DataContentHandler that corresponds to its MIME type using the
|
|
46 |
* current DataContentHandlerFactory. The DataHandler then calls
|
|
47 |
* through to the methods in the DataContentHandler.
|
|
48 |
*
|
|
49 |
* @since 1.6
|
|
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[] 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 getTransferData(DataFlavor df, DataSource ds)
|
|
76 |
throws UnsupportedFlavorException, IOException;
|
|
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 getContent(DataSource ds) throws IOException;
|
|
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 obj, String mimeType, OutputStream os)
|
|
100 |
throws IOException;
|
|
101 |
}
|