|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.datatransfer.SystemFlavorMap
public final class SystemFlavorMap
This class maps between native platform type names and DataFlavors. XXX - The current implementation does no mapping at all.
Method Summary | |
---|---|
void |
addFlavorForUnencodedNative(String nativeStr,
DataFlavor flavor)
Adds a mapping from a single String native to a single
DataFlavor . |
void |
addUnencodedNativeForFlavor(DataFlavor flavor,
String nativeStr)
Adds a mapping from the specified DataFlavor (and all
DataFlavor s equal to the specified DataFlavor )
to the specified String native. |
static DataFlavor |
decodeDataFlavor(String name)
Returns the data flavor given the native type name or null when no such data flavor exists. |
static String |
decodeJavaMIMEType(String name)
Decodes a String native for use as a Java MIME type. |
static String |
encodeDataFlavor(DataFlavor df)
Encodes a DataFlavor for use as a String
native. |
static String |
encodeJavaMIMEType(String mime)
Encodes a MIME type for use as a String native. |
static FlavorMap |
getDefaultFlavorMap()
Returns the (System)FlavorMap for the current thread's ClassLoader. |
List<DataFlavor> |
getFlavorsForNative(String nat)
Returns a List of DataFlavors to which the specified
String native can be translated by the data transfer
subsystem. |
Map<String,DataFlavor> |
getFlavorsForNatives(String[] natives)
Maps the specified native type names to DataFlavor 's. |
List<String> |
getNativesForFlavor(DataFlavor flav)
Returns a list of String natives corresponding to the given flavor. |
Map<DataFlavor,String> |
getNativesForFlavors(DataFlavor[] flavors)
Maps the specified DataFlavor objects to the native
data type name. |
static boolean |
isJavaMIMEType(String name)
Returns true if the native type name can be represented as a java mime type. |
void |
setFlavorsForNative(String nativeStr,
DataFlavor[] flavors)
Discards the current mappings for the specified String
native, and creates new mappings to the specified
DataFlavor s. |
void |
setNativesForFlavor(DataFlavor flavor,
String[] natives)
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public Map<DataFlavor,String> getNativesForFlavors(DataFlavor[] flavors)
DataFlavor
objects to the native
data type name. The returned Map
has keys that are
the data flavors and values that are strings. The returned map
may be modified. This can be useful for implementing nested mappings.
getNativesForFlavors
in interface FlavorMap
flavors
- An array of data flavors to map
or null for all data flavors.
Map
of native data types to data flavors.public Map<String,DataFlavor> getFlavorsForNatives(String[] natives)
DataFlavor
's.
The returned Map
has keys that are strings and values
that are DataFlavor
's. The returned map may be
modified. This can be useful for implementing nested mappings.
getFlavorsForNatives
in interface FlavorMap
natives
- An array of native types to map
or null for all native types.
Map
of data flavors to native type names.public static FlavorMap getDefaultFlavorMap()
public static String encodeJavaMIMEType(String mime)
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)
.
The present implementation of this method returns the specified MIME
type String
prefixed with gnu.java:
.
mime
- the MIME type to encode
String
, or null
if
mimeType is null
public static String encodeDataFlavor(DataFlavor df)
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)
.
The present implementation of this method returns the MIME type
String
of the specified DataFlavor
prefixed
with gnu.java:
.
df
- the DataFlavor
to encode
String
, or null
if
flav is null
or has a null
MIME typepublic static boolean isJavaMIMEType(String name)
false
if parameter is
null
.
public static String decodeJavaMIMEType(String name)
String
native for use as a Java MIME type.
name
- the String
to decode
null
if nat
is not an encoded String
nativepublic static DataFlavor decodeDataFlavor(String name) throws ClassNotFoundException
ClassNotFoundException
public List<DataFlavor> getFlavorsForNative(String nat)
DataFlavors
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 name to look up, or null to return all flavors
public List<String> getNativesForFlavor(DataFlavor flav)
FlavorTable
getNativesForFlavor
in interface FlavorTable
flav
- the flavor to look up, or null to return all natives
public void addFlavorForUnencodedNative(String nativeStr, DataFlavor flavor)
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.
nativeStr
- the String
native key for the mappingflavor
- the DataFlavor
value for the mapping
NullPointerException
- if nat or flav is null
addUnencodedNativeForFlavor(java.awt.datatransfer.DataFlavor, java.lang.String)
public void addUnencodedNativeForFlavor(DataFlavor flavor, String nativeStr)
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.
flavor
- the DataFlavor
key for the mappingnativeStr
- 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 flavor, 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.
flavor
- the DataFlavor
key for the mappingsnatives
- the String
native values 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 setFlavorsForNative(String nativeStr, 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.
nativeStr
- the String
native key for the mappingsflavors
- the DataFlavor
values for the mappings
NullPointerException
- if nat or flavors is null
or if flavors contains null
elementssetNativesForFlavor(java.awt.datatransfer.DataFlavor, java.lang.String[])
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |