java.lang.Object | |
↳ | sun.awt.datatransfer.DataTransferer |
Provides a set of functions to be shared among the DataFlavor class and platform-specific data transfer implementations. The concept of "flavors" and "natives" is extended to include "formats", which are the numeric values Win32 and X11 use to express particular data types. Like FlavorMap, which provides getNativesForFlavors(DataFlavor[]) and getFlavorsForNatives(String[]) functions, DataTransferer provides a set of getFormatsFor(Transferable|Flavor|Flavors) and getFlavorsFor(Format|Formats) functions. Also provided are functions for translating a Transferable into a byte array, given a source DataFlavor and a target format, and for translating a byte array or InputStream into an Object, given a source format and a target DataFlavor.
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
DataTransferer.CharsetComparator | An IndexedComparator which compares two String charsets. | ||||||||||
DataTransferer.DataFlavorComparator | An IndexedComparator which compares two DataFlavors. | ||||||||||
DataTransferer.IndexOrderComparator | |||||||||||
DataTransferer.IndexedComparator | A Comparator which includes a helper function for comparing two Objects which are likely to be keys in the specified Map. | ||||||||||
DataTransferer.ReencodingInputStream | Used for decoding and reencoding an InputStream on demand so that we can strip NUL terminators and perform EOLN search-and-replace. |
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
byteArrayClass | Cached value of Class.forName("[B"); | ||||||||||
charArrayClass | Cached value of Class.forName("[C"); | ||||||||||
javaTextEncodingFlavor | The DataFlavor representing a Java text encoding String
encoded in UTF-8, where
representationClass = [B mimeType = "application/x-java-text-encoding" |
||||||||||
plainTextStringFlavor | The DataFlavor representing plain text with Unicode
encoding, where:
representationClass = java.lang.String mimeType = "text/plain; charset=Unicode" |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Converts a FlavorMap to a FlavorTable.
| |||||||||||
Converts an arbitrary text encoding to its canonical name.
| |||||||||||
Tests only whether the flavor's MIME type supports the charset
parameter.
| |||||||||||
Returns the platform's default character encoding.
| |||||||||||
Returns the default Unicode encoding for the platform.
| |||||||||||
Returns a Map whose keys are all of the possible DataFlavors into which
data in the specified format can be translated.
| |||||||||||
Returns an array of all DataFlavors for which
1) a mapping from the specified format exists in the specified map and
2) the data translation for this mapping can be performed by the data
transfer subsystem.
| |||||||||||
Returns a Map whose keys are all of the possible DataFlavors into which
data in the specified formats can be translated.
| |||||||||||
Returns an array of all DataFlavors for which
1) a mapping from at least one of the specified formats exists in the
specified map and
2) the data translation for this mapping can be performed by the data
transfer subsystem.
| |||||||||||
Returns a Set of all DataFlavors for which
1) a mapping from at least one of the specified formats exists in the
specified map and
2) the data translation for this mapping can be performed by the data
transfer subsystem.
| |||||||||||
Returns a Map whose keys are all of the possible formats into which data
in the specified DataFlavor can be translated.
| |||||||||||
Returns a Map whose keys are all of the possible formats into which data
in the specified DataFlavors can be translated.
| |||||||||||
Returns a Map whose keys are all of the possible formats into which the
Transferable's transfer data flavors can be translated.
| |||||||||||
Reduces the Map output for the root function to an array of the
Map's keys.
| |||||||||||
The accessor method for the singleton DataTransferer instance.
| |||||||||||
Returns platform-specific mappings for the specified flavor.
| |||||||||||
Returns platform-specific mappings for the specified native.
| |||||||||||
If the specified flavor is a text flavor which supports the "charset"
parameter, then this method returns that parameter, or the default
charset if no such parameter was specified at construction.
| |||||||||||
Determines whether this JRE can both encode and decode text in the
specified encoding.
| |||||||||||
Determines whether the DataFlavor corresponding to the specified long
format is DataFlavor.javaFileListFlavor.
| |||||||||||
Returns whether this flavor is a text type which supports the
'charset' parameter.
| |||||||||||
Returns whether this flavor is a text type which does not support the
'charset' parameter.
| |||||||||||
Determines whether the DataFlavor corresponding to the specified long
format is DataFlavor.imageFlavor.
| |||||||||||
Specifies whether text imported from the native system in the specified
format is locale-dependent.
| |||||||||||
Helper function to reduce a Map with DataFlavor keys to a DataFlavor
array.
| |||||||||||
Helper function to reduce a Map with Long keys to a long array.
| |||||||||||
This method is called for text flavor mappings established while parsing
the flavormap.properties file.
| |||||||||||
Helper function to convert a Set of DataFlavors to a sorted array.
| |||||||||||
Helper function to convert a Set of DataFlavors to a sorted array.
| |||||||||||
Returns an Iterator which traverses a SortedSet of Strings which are
a total order of the standard character sets supported by the JRE.
| |||||||||||
Primary translation function for translating a Transferable into
a byte array, given a source DataFlavor and target format.
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Decodes a byte array into a set of String filenames.
| |||||||||||
Looks-up or registers the String native with the native data transfer
system and returns a long format corresponding to that native.
| |||||||||||
Looks-up the String native corresponding to the specified long format in
the native data transfer system.
| |||||||||||
Translates a Java Image into a byte array which contains platform-
specific image data in the given format.
| |||||||||||
Translates a Java Image into a byte array which contains
an image data in the given standard format.
| |||||||||||
Helper function to convert an InputStream to a byte[] array.
| |||||||||||
Determines whether the native corresponding to the specified long format
was listed in the flavormap.properties file.
| |||||||||||
Translates either a byte array or an input stream which contain
platform-specific image data in the given format into an Image.
| |||||||||||
Translates either a byte array or an input stream which contain
an image data in the given standard format into an Image.
| |||||||||||
Primary translation function for translating either a byte array or
an InputStream into an Object, given a source format and a target
DataFlavor.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
The DataFlavor
representing a Java text encoding String
encoded in UTF-8, where
representationClass = [B mimeType = "application/x-java-text-encoding"
The DataFlavor
representing plain text with Unicode
encoding, where:
representationClass = java.lang.String mimeType = "text/plain; charset=Unicode"
Converts an arbitrary text encoding to its canonical name.
IOException |
---|
Tests only whether the flavor's MIME type supports the charset parameter. Must only be called for flavors with a primary type of "text".
Returns the default Unicode encoding for the platform. The encoding need not be canonical. This method is only used by the archaic function DataFlavor.getTextPlainUnicodeFlavor().
Returns a Map whose keys are all of the possible DataFlavors into which data in the specified format can be translated. The value of each key is the format in which the Clipboard or dropped data should be requested when converting to the DataFlavor.
Returns an array of all DataFlavors for which
1) a mapping from the specified format exists in the specified map and
2) the data translation for this mapping can be performed by the data
transfer subsystem.
The array will be sorted according to a
DataFlavorComparator
created with the specified
map as an argument.
format | the data format |
---|---|
map | the FlavorTable which contains mappings between DataFlavors and data formats |
NullPointerException | if map is null
|
---|
Returns a Map whose keys are all of the possible DataFlavors into which data in the specified formats can be translated. The value of each key is the format in which the Clipboard or dropped data should be requested when converting to the DataFlavor.
Returns an array of all DataFlavors for which
1) a mapping from at least one of the specified formats exists in the
specified map and
2) the data translation for this mapping can be performed by the data
transfer subsystem.
The array will be sorted according to a
DataFlavorComparator
created with the specified
map as an argument.
formats | the data formats |
---|---|
map | the FlavorTable which contains mappings between DataFlavors and data formats |
NullPointerException | if formats or map is null
|
---|
Returns a Set of all DataFlavors for which 1) a mapping from at least one of the specified formats exists in the specified map and 2) the data translation for this mapping can be performed by the data transfer subsystem.
formats | the data formats |
---|---|
map | the FlavorTable which contains mappings between DataFlavors and data formats |
NullPointerException | if formats or map is null
|
---|
Returns a Map whose keys are all of the possible formats into which data in the specified DataFlavor can be translated. The value of each key is the DataFlavor in which a Transferable's data should be requested when converting to the format.
The map keys are sorted according to the native formats preference order.
Returns a Map whose keys are all of the possible formats into which data in the specified DataFlavors can be translated. The value of each key is the DataFlavor in which the Transferable's data should be requested when converting to the format.
The map keys are sorted according to the native formats preference order.
flavors | the data flavors |
---|---|
map | the FlavorTable which contains mappings between DataFlavors and data formats |
NullPointerException | if flavors or map is null
|
---|
Returns a Map whose keys are all of the possible formats into which the Transferable's transfer data flavors can be translated. The value of each key is the DataFlavor in which the Transferable's data should be requested when converting to the format.
The map keys are sorted according to the native formats preference order.
Reduces the Map output for the root function to an array of the Map's keys.
The accessor method for the singleton DataTransferer instance. Note that in a headless environment, there may be no DataTransferer instance; instead, null will be returned.
Returns platform-specific mappings for the specified flavor.
If there are no platform-specific mappings for this flavor, the method
returns an empty List
.
Returns platform-specific mappings for the specified native.
If there are no platform-specific mappings for this native, the method
returns an empty List
.
If the specified flavor is a text flavor which supports the "charset" parameter, then this method returns that parameter, or the default charset if no such parameter was specified at construction. For non- text DataFlavors, and for non-charset text flavors, this method returns null.
Determines whether this JRE can both encode and decode text in the specified encoding.
Determines whether the DataFlavor corresponding to the specified long format is DataFlavor.javaFileListFlavor.
Returns whether this flavor is a text type which supports the 'charset' parameter.
Returns whether this flavor is a text type which does not support the 'charset' parameter.
Determines whether the DataFlavor corresponding to the specified long format is DataFlavor.imageFlavor.
Specifies whether text imported from the native system in the specified format is locale-dependent. If so, when decoding such text, 'nativeCharsets' should be ignored, and instead, the Transferable should be queried for its javaTextEncodingFlavor data for the correct encoding.
Helper function to reduce a Map with DataFlavor keys to a DataFlavor
array. The array will be sorted according to
DataFlavorComparator
.
Helper function to reduce a Map with Long keys to a long array.
The map keys are sorted according to the native formats preference order.
This method is called for text flavor mappings established while parsing the flavormap.properties file. It stores the "eoln" and "terminators" parameters which are not officially part of the MIME type. They are MIME parameters specific to the flavormap.properties file format.
Helper function to convert a Set of DataFlavors to a sorted array.
The array will be sorted according to DataFlavorComparator
.
Helper function to convert a Set of DataFlavors to a sorted array.
The array will be sorted according to a
DataFlavorComparator
created with the specified
flavor-to-native map as an argument.
Returns an Iterator which traverses a SortedSet of Strings which are a total order of the standard character sets supported by the JRE. The ordering follows the same principles as DataFlavor.selectBestTextFlavor. So as to avoid loading all available character converters, optional, non-standard, character sets are not included.
IOException |
---|
IOException |
---|
Primary translation function for translating a Transferable into a byte array, given a source DataFlavor and target format.
IOException |
---|
Decodes a byte array into a set of String filenames.
Looks-up or registers the String native with the native data transfer system and returns a long format corresponding to that native.
Looks-up the String native corresponding to the specified long format in the native data transfer system.
Translates a Java Image into a byte array which contains platform- specific image data in the given format.
IOException |
---|
Translates a Java Image into a byte array which contains an image data in the given standard format.
mimeType | image MIME type, such as: image/png, image/jpeg |
---|
IOException |
---|
IOException |
---|
Helper function to convert an InputStream to a byte[] array.
IOException |
---|
Determines whether the native corresponding to the specified long format was listed in the flavormap.properties file.
Translates either a byte array or an input stream which contain platform-specific image data in the given format into an Image.
IOException |
---|
Translates either a byte array or an input stream which contain an image data in the given standard format into an Image.
mimeType | image MIME type, such as: image/png, image/jpeg, image/gif |
---|
IOException |
---|
Primary translation function for translating either a byte array or an InputStream into an Object, given a source format and a target DataFlavor. One of str/bytes is non-null; the other is null. The conversion from byte[] to InputStream is cheap, so do that immediately if necessary. The opposite conversion is expensive, so avoid it if possible.
IOException |
---|