- 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.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 propertyAWT.DnD.flavorMapFileURL
. Seeflavormap.properties
for details.- Since:
- 1.2
-
-
Method Summary
Methods Modifier and Type Method and Description void
addFlavorForUnencodedNative(String nat, DataFlavor flav)
Adds a mapping from a singleString
native to a singleDataFlavor
.void
addUnencodedNativeForFlavor(DataFlavor flav, String nat)
Adds a mapping from the specifiedDataFlavor
(and allDataFlavor
s equal to the specifiedDataFlavor
) to the specifiedString
native.static DataFlavor
decodeDataFlavor(String nat)
Decodes aString
native for use as aDataFlavor
.static String
decodeJavaMIMEType(String nat)
Decodes aString
native for use as a Java MIME type.static String
encodeDataFlavor(DataFlavor flav)
Encodes aDataFlavor
for use as aString
native.static String
encodeJavaMIMEType(String mimeType)
Encodes a MIME type for use as aString
native.static FlavorMap
getDefaultFlavorMap()
Returns the default FlavorMap for this thread's ClassLoader.List<DataFlavor>
getFlavorsForNative(String nat)
Returns aList
ofDataFlavor
s to which the specifiedString
native can be translated by the data transfer subsystem.Map<String,DataFlavor>
getFlavorsForNatives(String[] natives)
Returns aMap
of the specifiedString
natives to their most preferredDataFlavor
.List<String>
getNativesForFlavor(DataFlavor flav)
Returns aList
ofString
natives to which the specifiedDataFlavor
can be translated by the data transfer subsystem.Map<DataFlavor,String>
getNativesForFlavors(DataFlavor[] flavors)
Returns aMap
of the specifiedDataFlavor
s to their most preferredString
native.static boolean
isJavaMIMEType(String str)
Returns whether the specifiedString
is an encoded Java MIME type.void
setFlavorsForNative(String nat, DataFlavor[] flavors)
Discards the current mappings for the specifiedString
native, and creates new mappings to the specifiedDataFlavor
s.void
setNativesForFlavor(DataFlavor flav, String[] natives)
Discards the current mappings for the specifiedDataFlavor
and allDataFlavor
s equal to the specifiedDataFlavor
, and creates new mappings to the specifiedString
natives.
-
-
-
Method Detail
-
getDefaultFlavorMap
public static FlavorMap getDefaultFlavorMap()
Returns the default FlavorMap for this thread's ClassLoader.
-
getNativesForFlavor
public List<String> getNativesForFlavor(DataFlavor flav)
Returns aList
ofString
natives to which the specifiedDataFlavor
can be translated by the data transfer subsystem. TheList
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 and the data transfer subsystem is unable to translate thisDataFlavor
to any existing native, then invoking this method will establish a mapping in both directions between the specifiedDataFlavor
and an encoded version of its MIME type as its native.- Specified by:
getNativesForFlavor
in interfaceFlavorTable
- Parameters:
flav
- theDataFlavor
whose corresponding natives should be returned. Ifnull
is specified, all natives currently known to the data transfer subsystem are returned in a non-deterministic order.- Returns:
- a
java.util.List
ofjava.lang.String
objects which are platform-specific representations of platform- specific data formats - Since:
- 1.4
- See Also:
encodeDataFlavor(java.awt.datatransfer.DataFlavor)
-
getFlavorsForNative
public List<DataFlavor> getFlavorsForNative(String nat)
Returns aList
ofDataFlavor
s 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.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 theList
is platform dependent, butnull
cannot be returned.- Specified by:
getFlavorsForNative
in interfaceFlavorTable
- Parameters:
nat
- the native whose correspondingDataFlavor
s should be returned. Ifnull
is specified, allDataFlavor
s currently known to the data transfer subsystem are returned in a non-deterministic order.- Returns:
- a
java.util.List
ofDataFlavor
objects into which platform-specific data in the specified, platform-specific native can be translated - Since:
- 1.4
- See Also:
encodeJavaMIMEType(java.lang.String)
-
getNativesForFlavors
public Map<DataFlavor,String> getNativesForFlavors(DataFlavor[] flavors)
Returns aMap
of the specifiedDataFlavor
s to their most preferredString
native. Each native value will be the same as the first native in the List returned bygetNativesForFlavor
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 specifiedDataFlavor
and an encoded version of its MIME type as its native.- Specified by:
getNativesForFlavors
in interfaceFlavorMap
- Parameters:
flavors
- an array ofDataFlavor
s which will be the key set of the returnedMap
. Ifnull
is specified, a mapping of allDataFlavor
s known to the data transfer subsystem to their most preferredString
natives will be returned.- Returns:
- a
java.util.Map
ofDataFlavor
s toString
natives - See Also:
getNativesForFlavor(java.awt.datatransfer.DataFlavor)
,encodeDataFlavor(java.awt.datatransfer.DataFlavor)
-
getFlavorsForNatives
public Map<String,DataFlavor> getFlavorsForNatives(String[] natives)
Returns aMap
of the specifiedString
natives to their most preferredDataFlavor
. EachDataFlavor
value will be the same as the firstDataFlavor
in the List returned bygetFlavorsForNative
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.- Specified by:
getFlavorsForNatives
in interfaceFlavorMap
- Parameters:
natives
- an array ofString
s which will be the key set of the returnedMap
. Ifnull
is specified, a mapping of all supportedString
natives to their most preferredDataFlavor
s will be returned.- Returns:
- a
java.util.Map
ofString
natives toDataFlavor
s - See Also:
getFlavorsForNative(java.lang.String)
,encodeJavaMIMEType(java.lang.String)
-
addUnencodedNativeForFlavor
public void addUnencodedNativeForFlavor(DataFlavor flav, String nat)
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:
flav
- theDataFlavor
key for the mappingnat
- theString
native value for the mapping- Throws:
NullPointerException
- if flav or nat isnull
- Since:
- 1.4
- See Also:
addFlavorForUnencodedNative(java.lang.String, java.awt.datatransfer.DataFlavor)
-
setNativesForFlavor
public void setNativesForFlavor(DataFlavor flav, 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:
flav
- 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
- See Also:
setFlavorsForNative(java.lang.String, java.awt.datatransfer.DataFlavor[])
-
addFlavorForUnencodedNative
public void addFlavorForUnencodedNative(String nat, DataFlavor flav)
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:
nat
- theString
native key for the mappingflav
- theDataFlavor
value for the mapping- Throws:
NullPointerException
- if nat or flav isnull
- Since:
- 1.4
- See Also:
addUnencodedNativeForFlavor(java.awt.datatransfer.DataFlavor, java.lang.String)
-
setFlavorsForNative
public void setFlavorsForNative(String nat, 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:
nat
- 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
- See Also:
setNativesForFlavor(java.awt.datatransfer.DataFlavor, java.lang.String[])
-
encodeJavaMIMEType
public static String encodeJavaMIMEType(String mimeType)
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)
.
Sun's reference implementation of this method returns the specified MIME type
String
prefixed withJAVA_DATAFLAVOR:
.- Parameters:
mimeType
- the MIME type to encode- Returns:
- the encoded
String
, ornull
if mimeType isnull
- The encoded representation is
-
encodeDataFlavor
public static String encodeDataFlavor(DataFlavor flav)
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)
.
Sun's reference implementation of this method returns the MIME type
String
of the specifiedDataFlavor
prefixed withJAVA_DATAFLAVOR:
.- Parameters:
flav
- theDataFlavor
to encode- Returns:
- the encoded
String
, ornull
if flav isnull
or has anull
MIME type
- The encoded representation is
-
isJavaMIMEType
public static boolean isJavaMIMEType(String str)
Returns whether the specifiedString
is an encoded Java MIME type.- Parameters:
str
- theString
to test- Returns:
true
if theString
is encoded;false
otherwise
-
decodeJavaMIMEType
public static String decodeJavaMIMEType(String nat)
Decodes aString
native for use as a Java MIME type.- Parameters:
nat
- theString
to decode- Returns:
- the decoded Java MIME type, or
null
if nat is not an encodedString
native
-
decodeDataFlavor
public static DataFlavor decodeDataFlavor(String nat) throws ClassNotFoundException
Decodes aString
native for use as aDataFlavor
.- Parameters:
nat
- theString
to decode- Returns:
- the decoded
DataFlavor
, ornull
if nat is not an encodedString
native - Throws:
ClassNotFoundException
-
-
Deutsche Übersetzung
Sie haben gebeten, diese Seite auf Deutsch zu besuchen. Momentan ist nur die Oberfläche übersetzt, aber noch nicht der gesamte Inhalt.Wenn Sie mir bei Übersetzungen helfen wollen, ist Ihr Beitrag willkommen. Alles, was Sie tun müssen, ist, sich auf der Website zu registrieren und mir eine Nachricht zu schicken, in der Sie gebeten werden, Sie der Gruppe der Übersetzer hinzuzufügen, die Ihnen die Möglichkeit gibt, die gewünschten Seiten zu übersetzen. Ein Link am Ende jeder übersetzten Seite zeigt an, dass Sie der Übersetzer sind und einen Link zu Ihrem Profil haben.
Vielen Dank im Voraus.
Dokument erstellt 11/06/2005, zuletzt geändert 04/03/2020
Quelle des gedruckten Dokuments:https://www.gaudry.be/de/java-api-rf-java/awt/datatransfer/systemflavormap.html
Die Infobro ist eine persönliche Seite, deren Inhalt in meiner alleinigen Verantwortung liegt. Der Text ist unter der CreativeCommons-Lizenz (BY-NC-SA) verfügbar. Weitere Informationen auf die Nutzungsbedingungen und dem Autor.
Referenzen
Diese Verweise und Links verweisen auf Dokumente, die während des Schreibens dieser Seite konsultiert wurden, oder die zusätzliche Informationen liefern können, aber die Autoren dieser Quellen können nicht für den Inhalt dieser Seite verantwortlich gemacht werden.
Der Autor Diese Website ist allein dafür verantwortlich, wie die verschiedenen Konzepte und Freiheiten, die mit den Nachschlagewerken gemacht werden, hier dargestellt werden. Denken Sie daran, dass Sie mehrere Quellinformationen austauschen müssen, um das Risiko von Fehlern zu reduzieren.