- java.lang.Object
- 
- java.awt.datatransfer.SystemFlavorMap
 
- 
- All Implemented Interfaces:
- FlavorMap,- FlavorTable
 
 public final class SystemFlavorMap extends Object implements FlavorMap, FlavorTable The SystemFlavorMap is a configurable map between "natives" (Strings), which correspond to platform-specific data formats, and "flavors" (DataFlavors), which correspond to platform-independent MIME types. This mapping is used by the data transfer subsystem to transfer data between Java and native applications, and between Java applications in separate VMs.- Since:
- 1.2
 
- 
- 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddFlavorForUnencodedNative(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 FlavorMapgetDefaultFlavorMap()Returns the default FlavorMap for this thread's ClassLoader.List<DataFlavor>getFlavorsForNative(String nat)Returns aListofDataFlavors to which the specifiedStringnative can be translated by the data transfer subsystem.Map<String,DataFlavor>getFlavorsForNatives(String[] natives)Returns aMapof the specifiedStringnatives to their most preferredDataFlavor.List<String>getNativesForFlavor(DataFlavor flav)Returns aListofStringnatives to which the specifiedDataFlavorcan be translated by the data transfer subsystem.Map<DataFlavor,String>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 Detail- 
getDefaultFlavorMappublic static FlavorMap getDefaultFlavorMap() Returns the default FlavorMap for this thread's ClassLoader.- Returns:
- the default FlavorMap for this thread's ClassLoader
 
 - 
getNativesForFlavorpublic List<String> getNativesForFlavor(DataFlavor flav) 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 interface- FlavorTable
- Parameters:
- flav- the- DataFlavorwhose corresponding natives should be returned. If- nullis 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:
- encodeDataFlavor(java.awt.datatransfer.DataFlavor)
 
 - 
getFlavorsForNativepublic List<DataFlavor> getFlavorsForNative(String nat) 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 interface- FlavorTable
- Parameters:
- nat- the native whose corresponding- DataFlavors should be returned. If- nullis specified, all- DataFlavors 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:
- encodeJavaMIMEType(java.lang.String)
 
 - 
getNativesForFlavorspublic Map<DataFlavor,String> getNativesForFlavors(DataFlavor[] flavors) 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 interface- FlavorMap
- Parameters:
- flavors- an array of- DataFlavors which will be the key set of the returned- Map. If- nullis specified, a mapping of all- DataFlavors known to the data transfer subsystem to their most preferred- Stringnatives will be returned.
- Returns:
- a java.util.MapofDataFlavors toStringnatives
- See Also:
- getNativesForFlavor(java.awt.datatransfer.DataFlavor),- encodeDataFlavor(java.awt.datatransfer.DataFlavor)
 
 - 
getFlavorsForNativespublic Map<String,DataFlavor> getFlavorsForNatives(String[] natives) 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 interface- FlavorMap
- Parameters:
- natives- an array of- Strings which will be the key set of the returned- Map. If- nullis specified, a mapping of all supported- Stringnatives to their most preferred- DataFlavors will be returned.
- Returns:
- a java.util.MapofStringnatives toDataFlavors
- See Also:
- getFlavorsForNative(java.lang.String),- encodeJavaMIMEType(java.lang.String)
 
 - 
addUnencodedNativeForFlavorpublic void addUnencodedNativeForFlavor(DataFlavor flav, String nat) 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- the- DataFlavorkey for the mapping
- nat- the- Stringnative value for the mapping
- Throws:
- NullPointerException- if flav or nat is- null
- Since:
- 1.4
- See Also:
- addFlavorForUnencodedNative(java.lang.String, java.awt.datatransfer.DataFlavor)
 
 - 
setNativesForFlavorpublic void setNativesForFlavor(DataFlavor flav, String[] natives) 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- the- DataFlavorkey for the mappings
- natives- the- Stringnative values for the mappings
- Throws:
- NullPointerException- if flav or natives is- nullor if natives contains- nullelements
- Since:
- 1.4
- See Also:
- setFlavorsForNative(java.lang.String, java.awt.datatransfer.DataFlavor[])
 
 - 
addFlavorForUnencodedNativepublic void addFlavorForUnencodedNative(String nat, DataFlavor flav) 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- the- Stringnative key for the mapping
- flav- the- DataFlavorvalue for the mapping
- Throws:
- NullPointerException- if- nator- flavis- null
- Since:
- 1.4
- See Also:
- addUnencodedNativeForFlavor(java.awt.datatransfer.DataFlavor, java.lang.String)
 
 - 
setFlavorsForNativepublic void setFlavorsForNative(String nat, DataFlavor[] flavors) 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- the- Stringnative key for the mappings
- flavors- the- DataFlavorvalues for the mappings
- Throws:
- NullPointerException- if- nator- flavorsis- nullor if- flavorscontains- nullelements
- Since:
- 1.4
- See Also:
- setNativesForFlavor(java.awt.datatransfer.DataFlavor, java.lang.String[])
 
 - 
encodeJavaMIMETypepublic static String encodeJavaMIMEType(String mimeType) 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 
 - 
encodeDataFlavorpublic static String encodeDataFlavor(DataFlavor flav) 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- the- DataFlavorto encode
- Returns:
- the encoded String, ornullifflavisnullor has anullMIME type
 
- The encoded representation is 
 - 
isJavaMIMETypepublic static boolean isJavaMIMEType(String str) Returns whether the specifiedStringis an encoded Java MIME type.- Parameters:
- str- the- Stringto test
- Returns:
- trueif the- Stringis encoded;- falseotherwise
 
 - 
decodeJavaMIMETypepublic static String decodeJavaMIMEType(String nat) Decodes aStringnative for use as a Java MIME type.- Parameters:
- nat- the- Stringto decode
- Returns:
- the decoded Java MIME type, or nullifnatis not an encodedStringnative
 
 - 
decodeDataFlavorpublic static DataFlavor decodeDataFlavor(String nat) throws ClassNotFoundException Decodes aStringnative for use as aDataFlavor.- Parameters:
- nat- the- Stringto decode
- Returns:
- the decoded DataFlavor, ornullifnatis not an encodedStringnative
- Throws:
- ClassNotFoundException- if the class of the data flavor is not loaded
 
 
- 
 
-