Class SystemFlavorMap
- All Implemented Interfaces:
FlavorMap,FlavorTable
- Since:
- 1.2
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddFlavorForUnencodedNative(String nat, DataFlavor flav) Adds a mapping from a singleStringnative to a singleDataFlavor.voidaddUnencodedNativeForFlavor(DataFlavor flav, String nat) Adds a mapping from the specifiedDataFlavor(and allDataFlavors equal to the specifiedDataFlavor) to the specifiedStringnative.static DataFlavordecodeDataFlavor(String nat) Decodes aStringnative for use as aDataFlavor.static StringdecodeJavaMIMEType(String nat) Decodes aStringnative for use as a Java MIME type.static StringencodeDataFlavor(DataFlavor flav) Encodes aDataFlavorfor use as aStringnative.static StringencodeJavaMIMEType(String mimeType) Encodes a MIME type for use as aStringnative.static FlavorMapReturns the default FlavorMap for this thread's ClassLoader.Returns aListofDataFlavors to which the specifiedStringnative can be translated by the data transfer subsystem.getFlavorsForNatives(String[] natives) Returns aMapof the specifiedStringnatives to their most preferredDataFlavor.Returns aListofStringnatives to which the specifiedDataFlavorcan be translated by the data transfer subsystem.getNativesForFlavors(DataFlavor[] flavors) Returns aMapof the specifiedDataFlavors to their most preferredStringnative.static booleanisJavaMIMEType(String str) Returns whether the specifiedStringis an encoded Java MIME type.voidsetFlavorsForNative(String nat, DataFlavor[] flavors) Discards the current mappings for the specifiedStringnative, and creates new mappings to the specifiedDataFlavors.voidsetNativesForFlavor(DataFlavor flav, String[] natives) Discards the current mappings for the specifiedDataFlavorand allDataFlavors equal to the specifiedDataFlavor, and creates new mappings to the specifiedStringnatives.
-
Method Details
-
getDefaultFlavorMap
Returns the default FlavorMap for this thread's ClassLoader.- Returns:
- the default FlavorMap for this thread's ClassLoader
-
getNativesForFlavor
Returns aListofStringnatives to which the specifiedDataFlavorcan be translated by the data transfer subsystem. TheListwill 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
DataFlavoris previously unknown to the data transfer subsystem and the data transfer subsystem is unable to translate thisDataFlavorto any existing native, then invoking this method will establish a mapping in both directions between the specifiedDataFlavorand an encoded version of its MIME type as its native.- Specified by:
getNativesForFlavorin interfaceFlavorTable- Parameters:
flav- theDataFlavorwhose corresponding natives should be returned. Ifnullis specified, all natives currently known to the data transfer subsystem are returned in a non-deterministic order.- Returns:
- a
java.util.Listofjava.lang.Stringobjects which are platform-specific representations of platform-specific data formats - Since:
- 1.4
- See Also:
-
getFlavorsForNative
Returns aListofDataFlavors to which the specifiedStringnative can be translated by the data transfer subsystem. TheListwill be sorted from bestDataFlavorto worst. That is, the firstDataFlavorwill 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
DataFlavorwhose 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 theListis platform dependent, butnullcannot be returned.- Specified by:
getFlavorsForNativein interfaceFlavorTable- Parameters:
nat- the native whose correspondingDataFlavors should be returned. Ifnullis specified, allDataFlavors currently known to the data transfer subsystem are returned in a non-deterministic order.- Returns:
- a
java.util.ListofDataFlavorobjects into which platform-specific data in the specified, platform-specific native can be translated - Since:
- 1.4
- See Also:
-
getNativesForFlavors
Returns aMapof the specifiedDataFlavors to their most preferredStringnative. Each native value will be the same as the first native in the List returned bygetNativesForFlavorfor the specified flavor.If a specified
DataFlavoris previously unknown to the data transfer subsystem, then invoking this method will establish a mapping in both directions between the specifiedDataFlavorand an encoded version of its MIME type as its native.- Specified by:
getNativesForFlavorsin interfaceFlavorMap- Parameters:
flavors- an array ofDataFlavors which will be the key set of the returnedMap. Ifnullis specified, a mapping of allDataFlavors known to the data transfer subsystem to their most preferredStringnatives will be returned.- Returns:
- a
java.util.MapofDataFlavors toStringnatives - See Also:
-
getFlavorsForNatives
Returns aMapof the specifiedStringnatives to their most preferredDataFlavor. EachDataFlavorvalue will be the same as the firstDataFlavorin the List returned bygetFlavorsForNativefor 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
DataFlavorwhose MIME type is a decoded version of the native.- Specified by:
getFlavorsForNativesin interfaceFlavorMap- Parameters:
natives- an array ofStrings which will be the key set of the returnedMap. Ifnullis specified, a mapping of all supportedStringnatives to their most preferredDataFlavors will be returned.- Returns:
- a
java.util.MapofStringnatives toDataFlavors - See Also:
-
addUnencodedNativeForFlavor
Adds a mapping from the specifiedDataFlavor(and allDataFlavors equal to the specifiedDataFlavor) to the specifiedStringnative. UnlikegetNativesForFlavor, the mapping will only be established in one direction, and the native will not be encoded. To establish a two-way mapping, calladdFlavorForUnencodedNativeas 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 equalDataFlavorto the specifiedStringnative already exists.- Parameters:
flav- theDataFlavorkey for the mappingnat- theStringnative value for the mapping- Throws:
NullPointerException- if flav or nat isnull- Since:
- 1.4
- See Also:
-
setNativesForFlavor
Discards the current mappings for the specifiedDataFlavorand allDataFlavors equal to the specifiedDataFlavor, and creates new mappings to the specifiedStringnatives. UnlikegetNativesForFlavor, the mappings will only be established in one direction, and the natives will not be encoded. To establish two-way mappings, callsetFlavorsForNativeas 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
Stringnatives, 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- theDataFlavorkey for the mappingsnatives- theStringnative values for the mappings- Throws:
NullPointerException- if flav or natives isnullor if natives containsnullelements- Since:
- 1.4
- See Also:
-
addFlavorForUnencodedNative
Adds a mapping from a singleStringnative 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, calladdUnencodedNativeForFlavoras well. The new mapping will be of lower priority than any existing mapping. This method has no effect if a mapping from the specifiedStringnative to the specified or equalDataFlavoralready exists.- Parameters:
nat- theStringnative key for the mappingflav- theDataFlavorvalue for the mapping- Throws:
NullPointerException- ifnatorflavisnull- Since:
- 1.4
- See Also:
-
setFlavorsForNative
Discards the current mappings for the specifiedStringnative, and creates new mappings to the specifiedDataFlavors. UnlikegetFlavorsForNative, the mappings will only be established in one direction, and the natives need not be encoded. To establish two-way mappings, callsetNativesForFlavoras well. The firstDataFlavorin the array will represent the highest priority mapping. SubsequentDataFlavors will represent mappings of decreasing priority.If the array contains several elements that reference equal
DataFlavors, 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- theStringnative key for the mappingsflavors- theDataFlavorvalues for the mappings- Throws:
NullPointerException- ifnatorflavorsisnullor ifflavorscontainsnullelements- Since:
- 1.4
- See Also:
-
encodeJavaMIMEType
Encodes a MIME type for use as aStringnative. The format of an encoded representation of a MIME type is implementation-dependent. The only restrictions are:- The encoded representation is
nullif and only if the MIME typeStringisnull - The encoded representations for two non-
nullMIME typeStrings are equal if and only if theseStrings are equal according toString.equals(Object)
Stringprefixed withJAVA_DATAFLAVOR:.- Parameters:
mimeType- the MIME type to encode- Returns:
- the encoded
String, ornullifmimeTypeisnull
- The encoded representation is
-
encodeDataFlavor
Encodes aDataFlavorfor use as aStringnative. The format of an encodedDataFlavoris implementation-dependent. The only restrictions are:- The encoded representation is
nullif and only if the specifiedDataFlavorisnullor its MIME typeStringisnull - The encoded representations for two non-
nullDataFlavors with non-nullMIME typeStrings are equal if and only if the MIME typeStrings of theseDataFlavors are equal according toString.equals(Object)
Stringof the specifiedDataFlavorprefixed withJAVA_DATAFLAVOR:.- Parameters:
flav- theDataFlavorto encode- Returns:
- the encoded
String, ornullifflavisnullor has anullMIME type
- The encoded representation is
-
isJavaMIMEType
Returns whether the specifiedStringis an encoded Java MIME type.- Parameters:
str- theStringto test- Returns:
trueif theStringis encoded;falseotherwise
-
decodeJavaMIMEType
-
decodeDataFlavor
Decodes aStringnative for use as aDataFlavor.- Parameters:
nat- theStringto decode- Returns:
- the decoded
DataFlavor, ornullifnatis not an encodedStringnative - Throws:
ClassNotFoundException- if the class of the data flavor is not loaded
-