|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.awt.datatransfer.SystemFlavorMap
Safe: 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.
In the Sun reference implementation, the default SystemFlavorMap is
initialized by the file jre/lib/flavormap.properties
and the
contents of the URL referenced by the AWT property
AWT.DnD.flavorMapFileURL
. See flavormap.properties
for details.
Field Summary | |
private Set |
disabledMappingGenerationKeys
Dynamic mapping generation used for text mappings should not be applied to the DataFlavors and String natives for which the mappings have been explicitly specified with setFlavorsForNative() or setNativesForFlavor(). |
private static String[] |
ENCODED_TEXT_CLASSES
The list of valid, encoded text flavor representation classes, in order from best to worst. |
private static WeakHashMap |
flavorMaps
System singleton which maps a thread's ClassLoader to a SystemFlavorMap. |
private Map |
flavorToNative
Maps DataFlavors (or base type Strings for text DataFlavors) to Lists of native Strings. |
private Map |
getFlavorsForNativeCache
Caches the result getFlavorsForNative(). |
private Map |
getNativesForFlavorCache
Caches the result of getNativesForFlavor(). |
private static String |
JavaMIME
Constant prefix used to tag Java types converted to native platform type. |
private static String |
keyValueSeparators
Copied from java.util.Properties. |
private Map |
nativeToFlavor
Maps native Strings to Lists of DataFlavors (or base type Strings for text DataFlavors). |
private static String |
strictKeyValueSeparators
|
private static boolean |
SYNTHESIZE_IF_NOT_FOUND
This constant is passed to flavorToNativeLookup() to indicate that a a native should be synthesized, stored, and returned by encoding the DataFlavor's MIME type in case if the DataFlavor is not found in 'flavorToNative' map. |
private static String |
TEXT_PLAIN_BASE_TYPE
A String representing text/plain MIME type. |
private static String[] |
UNICODE_TEXT_CLASSES
The list of valid, decoded text flavor representation classes, in order from best to worst. |
private static String |
whiteSpaceChars
|
Constructor Summary | |
private |
SystemFlavorMap()
Constructs a SystemFlavorMap by reading flavormap.properties and AWT.DnD.flavorMapFileURL. |
Method Summary | |
void |
addFlavorForUnencodedNative(String nat,
DataFlavor flav)
Suppressed: Adds a mapping from a single String native to a single
DataFlavor . |
void |
addUnencodedNativeForFlavor(DataFlavor flav,
String nat)
Suppressed: Adds a mapping from the specified DataFlavor (and all
DataFlavor s equal to the specified DataFlavor )
to the specified String native. |
private boolean |
continueLine(String line)
Copied from java.util.Properties. |
static DataFlavor |
decodeDataFlavor(String nat)
Suppressed: Decodes a String native for use as a
DataFlavor . |
static String |
decodeJavaMIMEType(String nat)
Suppressed: Decodes a String native for use as a Java MIME type. |
static String |
encodeDataFlavor(DataFlavor flav)
Suppressed: Encodes a DataFlavor for use as a String
native. |
static String |
encodeJavaMIMEType(String mimeType)
Suppressed: Encodes a MIME type for use as a String native. |
private List |
flavorToNativeLookup(DataFlavor flav,
boolean synthesize)
Semantically equivalent to 'flavorToNative.get(flav)'. |
static FlavorMap |
getDefaultFlavorMap()
Enabled: Returns the default FlavorMap for this thread's ClassLoader. |
List |
getFlavorsForNative(String nat)
Enabled: Returns a List of DataFlavor s to which the
specified String native can be translated by the data
transfer subsystem. |
Map |
getFlavorsForNatives(String[] natives)
Suppressed: Returns a Map of the specified String natives
to their most preferred DataFlavor . |
List |
getNativesForFlavor(DataFlavor flav)
Enabled: Returns a List of String natives to which the
specified DataFlavor can be translated by the data transfer
subsystem. |
Map |
getNativesForFlavors(DataFlavor[] flavors)
Enabled: Returns a Map of the specified DataFlavor s to
their most preferred String native. |
static boolean |
isJavaMIMEType(String str)
Suppressed: Returns whether the specified String is an encoded Java
MIME type. |
private String |
loadConvert(String theString)
Copied from java.util.Properties. |
private List |
nativeToFlavorLookup(String nat)
Semantically equivalent to 'nativeToFlavor.get(nat)'. |
private void |
parseAndStoreReader(BufferedReader in)
Copied code from java.util.Properties. |
void |
setFlavorsForNative(String nat,
DataFlavor[] flavors)
Suppressed: Discards the current mappings for the specified String
native, and creates new mappings to the specified
DataFlavor s. |
void |
setNativesForFlavor(DataFlavor flav,
String[] natives)
Suppressed: Discards the current mappings for the specified DataFlavor
and all DataFlavor s equal to the specified
DataFlavor , and creates new mappings to the
specified String natives. |
private void |
store(Object hashed,
Object listed,
Map map)
Stores the listed object under the specified hash key in map. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private static String JavaMIME
private static final WeakHashMap flavorMaps
private static final String keyValueSeparators
private static final String strictKeyValueSeparators
private static final String whiteSpaceChars
private static final String[] UNICODE_TEXT_CLASSES
private static final String[] ENCODED_TEXT_CLASSES
private static final String TEXT_PLAIN_BASE_TYPE
private static final boolean SYNTHESIZE_IF_NOT_FOUND
private Map nativeToFlavor
private Map flavorToNative
private Map getNativesForFlavorCache
private Map getFlavorsForNativeCache
private Set disabledMappingGenerationKeys
Constructor Detail |
private SystemFlavorMap()
Method Detail |
public static FlavorMap getDefaultFlavorMap()
private void parseAndStoreReader(BufferedReader in) throws IOException
IOException
private boolean continueLine(String line)
private String loadConvert(String theString)
private void store(Object hashed, Object listed, Map map)
private List nativeToFlavorLookup(String nat)
private List flavorToNativeLookup(DataFlavor flav, boolean synthesize)
public List getNativesForFlavor(DataFlavor flav)
List
of String
natives to which the
specified DataFlavor
can be translated by the data transfer
subsystem. The List
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, then invoking this method will establish a
mapping in both directions between the specified DataFlavor
and an encoded version of its MIME type as its native.
getNativesForFlavor
in interface FlavorTable
flav
- the DataFlavor
whose corresponding natives
should be returned. If null
is specified, all
natives currently known to the data transfer subsystem are
returned in a non-deterministic order.
java.util.List
of java.lang.String
objects which are platform-specific representations of platform-
specific data formatsencodeDataFlavor(java.awt.datatransfer.DataFlavor)
public List getFlavorsForNative(String nat)
List
of DataFlavor
s to which the
specified String
native can be translated by the data
transfer subsystem. The List
will be sorted from best
DataFlavor
to worst. That is, the first
DataFlavor
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.
getFlavorsForNative
in interface FlavorTable
nat
- the native whose corresponding DataFlavor
s
should be returned. If null
is specified, all
DataFlavor
s currently known to the data transfer
subsystem are returned in a non-deterministic order.
java.util.List
of DataFlavor
objects into which platform-specific data in the specified,
platform-specific native can be translatedencodeJavaMIMEType(java.lang.String)
public Map getNativesForFlavors(DataFlavor[] flavors)
Map
of the specified DataFlavor
s to
their most preferred String
native. Each native value will
be the same as the first native in the List returned by
getNativesForFlavor
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 specified DataFlavor
and an encoded version of its MIME type as its native.
getNativesForFlavors
in interface FlavorMap
flavors
- an array of DataFlavor
s which will be the
key set of the returned Map
. If null
is
specified, a mapping of all DataFlavor
s known to the
data transfer subsystem to their most preferred
String
natives will be returned.
java.util.Map
of DataFlavor
s to
String
nativesgetNativesForFlavor(java.awt.datatransfer.DataFlavor)
,
encodeDataFlavor(java.awt.datatransfer.DataFlavor)
public Map getFlavorsForNatives(String[] natives)
Map
of the specified String
natives
to their most preferred DataFlavor
. Each
DataFlavor
value will be the same as the first
DataFlavor
in the List returned by
getFlavorsForNative
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.
getFlavorsForNatives
in interface FlavorMap
natives
- an array of String
s which will be the
key set of the returned Map
. If null
is
specified, a mapping of all supported String
natives
to their most preferred DataFlavor
s will be
returned.
java.util.Map
of String
natives to
DataFlavor
sgetFlavorsForNative(java.lang.String)
,
encodeJavaMIMEType(java.lang.String)
public void addUnencodedNativeForFlavor(DataFlavor flav, String nat)
DataFlavor
(and all
DataFlavor
s equal to the specified DataFlavor
)
to the specified String
native.
Unlike getNativesForFlavor
, the mapping will only be
established in one direction, and the native will not be encoded. To
establish a two-way mapping, call
addFlavorForUnencodedNative
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 equal
DataFlavor
to the specified String
native
already exists.
flav
- the DataFlavor
key for the mappingnat
- the String
native value for the mapping
NullPointerException
- if flav or nat is null
addFlavorForUnencodedNative(java.lang.String, java.awt.datatransfer.DataFlavor)
public void setNativesForFlavor(DataFlavor flav, String[] natives)
DataFlavor
and all DataFlavor
s equal to the specified
DataFlavor
, and creates new mappings to the
specified String
natives.
Unlike getNativesForFlavor
, the mappings will only be
established in one direction, and the natives will not be encoded. To
establish two-way mappings, call setFlavorsForNative
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.
flav
- the DataFlavor
key for the mappings
NullPointerException
- if flav or natives is null
or if natives contains null
elementssetFlavorsForNative(java.lang.String, java.awt.datatransfer.DataFlavor[])
public void addFlavorForUnencodedNative(String nat, DataFlavor flav)
String
native to a single
DataFlavor
. Unlike getFlavorsForNative
, the
mapping will only be established in one direction, and the native will
not be encoded. To establish a two-way mapping, call
addUnencodedNativeForFlavor
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
String
native to the specified or equal
DataFlavor
already exists.
nat
- the String
native key for the mappingflav
- the DataFlavor
value for the mapping
NullPointerException
- if nat or flav is null
addUnencodedNativeForFlavor(java.awt.datatransfer.DataFlavor, java.lang.String)
public void setFlavorsForNative(String nat, DataFlavor[] flavors)
String
native, and creates new mappings to the specified
DataFlavor
s. Unlike getFlavorsForNative
, the
mappings will only be established in one direction, and the natives need
not be encoded. To establish two-way mappings, call
setNativesForFlavor
as well. The first
DataFlavor
in the array will represent the highest priority
mapping. Subsequent DataFlavor
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.
nat
- the String
native key for the mappings
NullPointerException
- if nat or flavors is null
or if flavors contains null
elementssetNativesForFlavor(java.awt.datatransfer.DataFlavor, java.lang.String[])
public static String encodeJavaMIMEType(String mimeType)
String
native. The format
of an encoded representation of a MIME type is implementation-dependent.
The only restrictions are:
null
if and only if the
MIME type String
is null
.null
MIME type
String
s are equal if and only if these String
s
are equal according to String.equals(Object)
.
Sun's reference implementation of this method returns the specified MIME
type String
prefixed with JAVA_DATAFLAVOR:
.
mimeType
- the MIME type to encode
String
, or null
if
mimeType is null
public static String encodeDataFlavor(DataFlavor flav)
DataFlavor
for use as a String
native. The format of an encoded DataFlavor
is
implementation-dependent. The only restrictions are:
null
if and only if the
specified DataFlavor
is null
or its MIME type
String
is null
.null
DataFlavor
s with non-null
MIME type
String
s are equal if and only if the MIME type
String
s of these DataFlavor
s are equal
according to String.equals(Object)
.
Sun's reference implementation of this method returns the MIME type
String
of the specified DataFlavor
prefixed
with JAVA_DATAFLAVOR:
.
flav
- the DataFlavor
to encode
String
, or null
if
flav is null
or has a null
MIME typepublic static boolean isJavaMIMEType(String str)
String
is an encoded Java
MIME type.
str
- the String
to test
true
if the String
is encoded;
false
otherwisepublic static String decodeJavaMIMEType(String nat)
String
native for use as a Java MIME type.
nat
- the String
to decode
null
if nat is not
an encoded String
nativepublic static DataFlavor decodeDataFlavor(String nat) throws ClassNotFoundException
String
native for use as a
DataFlavor
.
nat
- the String
to decode
DataFlavor
, or null
if
nat is not an encoded String
native
ClassNotFoundException
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |