- All Implemented Interfaces:
FlavorMap
,FlavorTable
- Since:
- 1.2
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addFlavorForUnencodedNative(String nat, DataFlavor flav)
Adds a mapping from a singleString
native to a singleDataFlavor
.void
addUnencodedNativeForFlavor(DataFlavor flav, String nat)
Adds a mapping from the specifiedDataFlavor
(and allDataFlavor
s equal to the specifiedDataFlavor
) to the specifiedString
native.static DataFlavor
decodeDataFlavor(String nat)
Decodes aString
native for use as aDataFlavor
.static String
decodeJavaMIMEType(String nat)
Decodes aString
native for use as a Java MIME type.static String
encodeDataFlavor(DataFlavor flav)
Encodes aDataFlavor
for use as aString
native.static String
encodeJavaMIMEType(String mimeType)
Encodes a MIME type for use as aString
native.static FlavorMap
Returns the default FlavorMap for this thread's ClassLoader.getFlavorsForNative(String nat)
Returns aList
ofDataFlavor
s to which the specifiedString
native can be translated by the data transfer subsystem.getFlavorsForNatives(String[] natives)
Returns aMap
of the specifiedString
natives to their most preferredDataFlavor
.getNativesForFlavor(DataFlavor flav)
Returns aList
ofString
natives to which the specifiedDataFlavor
can be translated by the data transfer subsystem.getNativesForFlavors(DataFlavor[] flavors)
Returns aMap
of the specifiedDataFlavor
s to their most preferredString
native.static boolean
isJavaMIMEType(String str)
Returns whether the specifiedString
is an encoded Java MIME type.void
setFlavorsForNative(String nat, DataFlavor[] flavors)
Discards the current mappings for the specifiedString
native, and creates new mappings to the specifiedDataFlavor
s.void
setNativesForFlavor(DataFlavor flav, String[] natives)
Discards the current mappings for the specifiedDataFlavor
and allDataFlavor
s equal to the specifiedDataFlavor
, and creates new mappings to the specifiedString
natives.
-
Method Details
-
getDefaultFlavorMap
Returns the default FlavorMap for this thread's ClassLoader.- Returns:
- the default FlavorMap for this thread's ClassLoader
-
getNativesForFlavor
Returns aList
ofString
natives to which the specifiedDataFlavor
can be translated by the data transfer subsystem. TheList
will be sorted from best native to worst. That is, the first native will best reflect data in the specified flavor to the underlying native platform.If the specified
DataFlavor
is previously unknown to the data transfer subsystem and the data transfer subsystem is unable to translate thisDataFlavor
to any existing native, then invoking this method will establish a mapping in both directions between the specifiedDataFlavor
and an encoded version of its MIME type as its native.- Specified by:
getNativesForFlavor
in interfaceFlavorTable
- Parameters:
flav
- theDataFlavor
whose corresponding natives should be returned. Ifnull
is specified, all natives currently known to the data transfer subsystem are returned in a non-deterministic order.- Returns:
- a
java.util.List
ofjava.lang.String
objects which are platform-specific representations of platform-specific data formats - Since:
- 1.4
- See Also:
encodeDataFlavor(java.awt.datatransfer.DataFlavor)
-
getFlavorsForNative
Returns aList
ofDataFlavor
s to which the specifiedString
native can be translated by the data transfer subsystem. TheList
will be sorted from bestDataFlavor
to worst. That is, the firstDataFlavor
will best reflect data in the specified native to a Java application.If the specified native is previously unknown to the data transfer subsystem, and that native has been properly encoded, then invoking this method will establish a mapping in both directions between the specified native and a
DataFlavor
whose MIME type is a decoded version of the native.If the specified native is not a properly encoded native and the mappings for this native have not been altered with
setFlavorsForNative
, then the contents of theList
is platform dependent, butnull
cannot be returned.- Specified by:
getFlavorsForNative
in interfaceFlavorTable
- Parameters:
nat
- the native whose correspondingDataFlavor
s should be returned. Ifnull
is specified, allDataFlavor
s currently known to the data transfer subsystem are returned in a non-deterministic order.- Returns:
- a
java.util.List
ofDataFlavor
objects into which platform-specific data in the specified, platform-specific native can be translated - Since:
- 1.4
- See Also:
encodeJavaMIMEType(java.lang.String)
-
getNativesForFlavors
Returns aMap
of the specifiedDataFlavor
s to their most preferredString
native. Each native value will be the same as the first native in the List returned bygetNativesForFlavor
for the specified flavor.If a specified
DataFlavor
is previously unknown to the data transfer subsystem, then invoking this method will establish a mapping in both directions between the specifiedDataFlavor
and an encoded version of its MIME type as its native.- Specified by:
getNativesForFlavors
in interfaceFlavorMap
- Parameters:
flavors
- an array ofDataFlavor
s which will be the key set of the returnedMap
. Ifnull
is specified, a mapping of allDataFlavor
s known to the data transfer subsystem to their most preferredString
natives will be returned.- Returns:
- a
java.util.Map
ofDataFlavor
s toString
natives - See Also:
getNativesForFlavor(java.awt.datatransfer.DataFlavor)
,encodeDataFlavor(java.awt.datatransfer.DataFlavor)
-
getFlavorsForNatives
Returns aMap
of the specifiedString
natives to their most preferredDataFlavor
. EachDataFlavor
value will be the same as the firstDataFlavor
in the List returned bygetFlavorsForNative
for the specified native.If a specified native is previously unknown to the data transfer subsystem, and that native has been properly encoded, then invoking this method will establish a mapping in both directions between the specified native and a
DataFlavor
whose MIME type is a decoded version of the native.- Specified by:
getFlavorsForNatives
in interfaceFlavorMap
- Parameters:
natives
- an array ofString
s which will be the key set of the returnedMap
. Ifnull
is specified, a mapping of all supportedString
natives to their most preferredDataFlavor
s will be returned.- Returns:
- a
java.util.Map
ofString
natives toDataFlavor
s - See Also:
getFlavorsForNative(java.lang.String)
,encodeJavaMIMEType(java.lang.String)
-
addUnencodedNativeForFlavor
Adds a mapping from the specifiedDataFlavor
(and allDataFlavor
s equal to the specifiedDataFlavor
) to the specifiedString
native. UnlikegetNativesForFlavor
, the mapping will only be established in one direction, and the native will not be encoded. To establish a two-way mapping, calladdFlavorForUnencodedNative
as well. The new mapping will be of lower priority than any existing mapping. This method has no effect if a mapping from the specified or equalDataFlavor
to the specifiedString
native already exists.- Parameters:
flav
- theDataFlavor
key for the mappingnat
- theString
native value for the mapping- Throws:
NullPointerException
- if flav or nat isnull
- Since:
- 1.4
- See Also:
addFlavorForUnencodedNative(java.lang.String, java.awt.datatransfer.DataFlavor)
-
setNativesForFlavor
Discards the current mappings for the specifiedDataFlavor
and allDataFlavor
s equal to the specifiedDataFlavor
, and creates new mappings to the specifiedString
natives. UnlikegetNativesForFlavor
, the mappings will only be established in one direction, and the natives will not be encoded. To establish two-way mappings, callsetFlavorsForNative
as well. The first native in the array will represent the highest priority mapping. Subsequent natives will represent mappings of decreasing priority.If the array contains several elements that reference equal
String
natives, this method will establish new mappings for the first of those elements and ignore the rest of them.It is recommended that client code not reset mappings established by the data transfer subsystem. This method should only be used for application-level mappings.
- Parameters:
flav
- theDataFlavor
key for the mappingsnatives
- theString
native values for the mappings- Throws:
NullPointerException
- if flav or natives isnull
or if natives containsnull
elements- Since:
- 1.4
- See Also:
setFlavorsForNative(java.lang.String, java.awt.datatransfer.DataFlavor[])
-
addFlavorForUnencodedNative
Adds a mapping from a singleString
native to a singleDataFlavor
. UnlikegetFlavorsForNative
, the mapping will only be established in one direction, and the native will not be encoded. To establish a two-way mapping, calladdUnencodedNativeForFlavor
as well. The new mapping will be of lower priority than any existing mapping. This method has no effect if a mapping from the specifiedString
native to the specified or equalDataFlavor
already exists.- Parameters:
nat
- theString
native key for the mappingflav
- theDataFlavor
value for the mapping- Throws:
NullPointerException
- ifnat
orflav
isnull
- Since:
- 1.4
- See Also:
addUnencodedNativeForFlavor(java.awt.datatransfer.DataFlavor, java.lang.String)
-
setFlavorsForNative
Discards the current mappings for the specifiedString
native, and creates new mappings to the specifiedDataFlavor
s. UnlikegetFlavorsForNative
, the mappings will only be established in one direction, and the natives need not be encoded. To establish two-way mappings, callsetNativesForFlavor
as well. The firstDataFlavor
in the array will represent the highest priority mapping. SubsequentDataFlavor
s will represent mappings of decreasing priority.If the array contains several elements that reference equal
DataFlavor
s, this method will establish new mappings for the first of those elements and ignore the rest of them.It is recommended that client code not reset mappings established by the data transfer subsystem. This method should only be used for application-level mappings.
- Parameters:
nat
- theString
native key for the mappingsflavors
- theDataFlavor
values for the mappings- Throws:
NullPointerException
- ifnat
orflavors
isnull
or ifflavors
containsnull
elements- Since:
- 1.4
- See Also:
setNativesForFlavor(java.awt.datatransfer.DataFlavor, java.lang.String[])
-
encodeJavaMIMEType
Encodes a MIME type for use as aString
native. The format of an encoded representation of a MIME type is implementation-dependent. The only restrictions are:- The encoded representation is
null
if and only if the MIME typeString
isnull
- The encoded representations for two non-
null
MIME typeString
s are equal if and only if theseString
s are equal according toString.equals(Object)
String
prefixed withJAVA_DATAFLAVOR:
.- Parameters:
mimeType
- the MIME type to encode- Returns:
- the encoded
String
, ornull
ifmimeType
isnull
- The encoded representation is
-
encodeDataFlavor
Encodes aDataFlavor
for use as aString
native. The format of an encodedDataFlavor
is implementation-dependent. The only restrictions are:- The encoded representation is
null
if and only if the specifiedDataFlavor
isnull
or its MIME typeString
isnull
- The encoded representations for two non-
null
DataFlavor
s with non-null
MIME typeString
s are equal if and only if the MIME typeString
s of theseDataFlavor
s are equal according toString.equals(Object)
String
of the specifiedDataFlavor
prefixed withJAVA_DATAFLAVOR:
.- Parameters:
flav
- theDataFlavor
to encode- Returns:
- the encoded
String
, ornull
ifflav
isnull
or has anull
MIME type
- The encoded representation is
-
isJavaMIMEType
Returns whether the specifiedString
is an encoded Java MIME type.- Parameters:
str
- theString
to test- Returns:
true
if theString
is encoded;false
otherwise
-
decodeJavaMIMEType
Decodes aString
native for use as a Java MIME type.- Parameters:
nat
- theString
to decode- Returns:
- the decoded Java MIME type, or
null
ifnat
is not an encodedString
native
-
decodeDataFlavor
Decodes aString
native for use as aDataFlavor
.- Parameters:
nat
- theString
to decode- Returns:
- the decoded
DataFlavor
, ornull
ifnat
is not an encodedString
native - Throws:
ClassNotFoundException
- if the class of the data flavor is not loaded
-