Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
java.awt.datatransfer.SystemFlavorMap
Method Summary | |
Map |
|
Map |
|
void |
|
void |
|
static DataFlavor |
|
static String |
|
static String |
|
static String |
|
static FlavorMap |
|
List |
|
List |
|
static boolean |
|
void |
|
void |
|
Methods inherited from class java.lang.Object | |
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
public MapDataFlavor> getFlavorsForNatives (String[] natives)
Maps the specified native type names toDataFlavor
's. The returnedMap
has keys that are strings and values that areDataFlavor
's. The returned map may be modified. This can be useful for implementing nested mappings.
- Specified by:
- DataFlavor> getFlavorsForNatives in interface FlavorMap
- Parameters:
natives
- An array of native types to map or null for all native types.
- Returns:
- A
Map
of data flavors to native type names.
public MapString> getNativesForFlavors (DataFlavor[] flavors)
Maps the specifiedDataFlavor
objects to the native data type name. The returnedMap
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.
- Specified by:
- String> getNativesForFlavors in interface FlavorMap
- Parameters:
flavors
- An array of data flavors to map or null for all data flavors.
- Returns:
- A
Map
of native data types to data flavors.
public void addFlavorForUnencodedNative(String nativeStr, DataFlavor flavor)
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:
nativeStr
- theString
native key for the mappingflavor
- theDataFlavor
value for the mapping
- Throws:
NullPointerException
- if nat or flav isnull
- Since:
- 1.4
public void addUnencodedNativeForFlavor(DataFlavor flavor, String nativeStr)
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:
flavor
- theDataFlavor
key for the mappingnativeStr
- theString
native value for the mapping
- Throws:
NullPointerException
- if flav or nat isnull
- Since:
- 1.4
public static DataFlavor decodeDataFlavor(String name) throws ClassNotFoundException
Returns the data flavor given the native type name or null when no such data flavor exists.
public static String decodeJavaMIMEType(String name)
Decodes aString
native for use as a Java MIME type.
- Parameters:
name
- theString
to decode
- Returns:
- the decoded Java MIME type, or
null
if nat is not an encodedString
native
public static String encodeDataFlavor(DataFlavor df)
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)
.The present implementation of this method returns the MIME type
String
of the specifiedDataFlavor
prefixed withgnu.java:
.
- Parameters:
df
- theDataFlavor
to encode
- Returns:
- the encoded
String
, ornull
if flav isnull
or has anull
MIME type
public static String encodeJavaMIMEType(String mime)
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)
.The present implementation of this method returns the specified MIME type
String
prefixed withgnu.java:
.
- Parameters:
mime
- the MIME type to encode
- Returns:
- the encoded
String
, ornull
if mimeType isnull
public static FlavorMap getDefaultFlavorMap()
Returns the (System)FlavorMap for the current thread's ClassLoader.
public ListgetFlavorsForNative(String nat)
Returns a List ofDataFlavors
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.
- Specified by:
- getFlavorsForNative in interface FlavorTable
public ListgetNativesForFlavor(DataFlavor flav)
Returns a list of String natives corresponding to the given flavor. The list should be sorted from best to worst. The list must be modifiable without affecting this table.
- Specified by:
- getNativesForFlavor in interface FlavorTable
- Parameters:
- Returns:
- the sorted list of natives
public static boolean isJavaMIMEType(String name)
Returns true if the native type name can be represented as a java mime type. Returnsfalse
if parameter isnull
.
public void setFlavorsForNative(String nativeStr, DataFlavor[] flavors)
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:
nativeStr
- theString
native key for the mappingsflavors
- theDataFlavor
values for the mappings
- Throws:
NullPointerException
- if nat or flavors isnull
or if flavors containsnull
elements
- Since:
- 1.4
public void setNativesForFlavor(DataFlavor flavor, String[] natives)
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:
flavor
- 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