APIdia Launch Partner
Top Description Inners Fields Constructors Methods
sun.datatransfer

public Class DataFlavorUtil

extends Object
Class Inheritance
Imports
java.awt.datatransfer.DataFlavor, .FlavorMap, java.io.IOException, .InputStream, .Reader, java.lang.reflect.Constructor, .InvocationTargetException, .Method, java.nio.ByteBuffer, .CharBuffer, java.nio.charset.Charset, .IllegalCharsetNameException, .StandardCharsets, .UnsupportedCharsetException, java.util.Collections, .Comparator, .HashMap, .Iterator, .LinkedHashSet, .Map, .ServiceLoader, .Set, .SortedSet, .TreeSet, java.util.function.Supplier

Utility class with different datatransfer helper functions.
Since
9

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
DataFlavorUtil.CharsetComparator

An IndexedComparator which compares two String charsets.

private static class
DataFlavorUtil.DataFlavorComparator

An IndexedComparator which compares two DataFlavors.

private static class
DataFlavorUtil.DefaultDesktopDatatransferService

A fallback implementation of DesktopDatatransferService used if there is no desktop.

private static class
DataFlavorUtil.IndexOrderComparator

Given the Map that maps objects to Integer indices and a boolean value, this Comparator imposes a direct or reverse order on set of objects.

public static class
DataFlavorUtil.RMI

A class that provides access to java.rmi.Remote and java.rmi.MarshalledObject without creating a static dependency.

private static class
DataFlavorUtil.StandardEncodingsHolder

Lazy initialization of Standard Encodings.

private static class

Field Summary

Modifier and TypeField and Description
private static final Map<String, Boolean>
textMIMESubtypeCharsetSupport

Tracks whether a particular text/* MIME type supports the charset parameter.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static String
canonicalName(String encoding)

Converts an arbitrary text encoding to its canonical name.

pack-priv static <T> int

Returns:

a negative integer, zero, or a positive integer as the first object is mapped to a less, equal to, or greater index than the second
compareIndices
(Map<T, Integer>
the map which maps objects into Integer indexes
indexMap
,
T
the first object to be compared
obj1
,
T
the second object to be compared
obj2
,
Integer
the Integer to be used as a fallback index
fallbackIndex
)

Helper method to compare two objects by their Integer indices in the given map.

public static boolean
doesSubtypeSupportCharset(DataFlavor flavor)

Tests only whether the flavor's MIME type supports the charset parameter.

public static boolean
private static Comparator<String>
public static Comparator<DataFlavor>
public static DesktopDatatransferService
public static Comparator<Long>
public static String
getTextCharset(DataFlavor flavor)

If the specified flavor is a text flavor which supports the "charset" parameter, then this method returns that parameter, or the default charset if no such parameter was specified at construction.

public static Comparator<DataFlavor>
private static boolean
isEncodingSupported(String encoding)

Determines whether this JRE can both encode and decode text in the specified encoding.

public static boolean
isFlavorCharsetTextType(DataFlavor flavor)

Returns whether this flavor is a text type which supports the 'charset' parameter.

public static boolean
isFlavorNoncharsetTextType(DataFlavor flavor)

Returns whether this flavor is a text type which does not support the 'charset' parameter.

public static Set<String>
standardEncodings()

Returns a SortedSet of Strings which are a total order of the standard character sets supported by the JRE.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

textMIMESubtypeCharsetSupportback to summary
private static final Map<String, Boolean> textMIMESubtypeCharsetSupport

Tracks whether a particular text/* MIME type supports the charset parameter. The Map is initialized with all of the standard MIME types listed in the DataFlavor.selectBestTextFlavor method comment. Additional entries may be added during the life of the JRE for text/<other> types.

Constructor Detail

DataFlavorUtilback to summary
private DataFlavorUtil()

Method Detail

canonicalNameback to summary
public static String canonicalName(String encoding)

Converts an arbitrary text encoding to its canonical name.

compareIndicesback to summary
pack-priv static <T> int compareIndices(Map<T, Integer> indexMap, T obj1, T obj2, Integer fallbackIndex)

Helper method to compare two objects by their Integer indices in the given map. If the map doesn't contain an entry for either of the objects, the fallback index will be used for the object instead.

Parameters
indexMap:Map<T, Integer>

the map which maps objects into Integer indexes

obj1:T

the first object to be compared

obj2:T

the second object to be compared

fallbackIndex:Integer

the Integer to be used as a fallback index

Returns:int

a negative integer, zero, or a positive integer as the first object is mapped to a less, equal to, or greater index than the second

doesSubtypeSupportCharsetback to summary
public static boolean doesSubtypeSupportCharset(DataFlavor flavor)

Tests only whether the flavor's MIME type supports the charset parameter. Must only be called for flavors with a primary type of "text".

doesSubtypeSupportCharsetback to summary
public static boolean doesSubtypeSupportCharset(String subType, String charset)
getCharsetComparatorback to summary
private static Comparator<String> getCharsetComparator()
getDataFlavorComparatorback to summary
public static Comparator<DataFlavor> getDataFlavorComparator()
getDesktopServiceback to summary
public static DesktopDatatransferService getDesktopService()
getIndexOrderComparatorback to summary
public static Comparator<Long> getIndexOrderComparator(Map<Long, Integer> indexMap)
getTextCharsetback to summary
public static String getTextCharset(DataFlavor flavor)

If the specified flavor is a text flavor which supports the "charset" parameter, then this method returns that parameter, or the default charset if no such parameter was specified at construction. For non-text DataFlavors, and for non-charset text flavors, this method returns null.

getTextFlavorComparatorback to summary
public static Comparator<DataFlavor> getTextFlavorComparator()
isEncodingSupportedback to summary
private static boolean isEncodingSupported(String encoding)

Determines whether this JRE can both encode and decode text in the specified encoding.

isFlavorCharsetTextTypeback to summary
public static boolean isFlavorCharsetTextType(DataFlavor flavor)

Returns whether this flavor is a text type which supports the 'charset' parameter.

isFlavorNoncharsetTextTypeback to summary
public static boolean isFlavorNoncharsetTextType(DataFlavor flavor)

Returns whether this flavor is a text type which does not support the 'charset' parameter.

standardEncodingsback to summary
public static Set<String> standardEncodings()

Returns a SortedSet of Strings which are a total order of the standard character sets supported by the JRE. The ordering follows the same principles as DataFlavor#selectBestTextFlavor(DataFlavor[]). So as to avoid loading all available character converters, optional, non-standard, character sets are not included.

sun.datatransfer back to summary

private Class DataFlavorUtil.CharsetComparator

extends Object
implements Comparator<String>
Class Inheritance
All Implemented Interfaces
java.util.Comparator

An IndexedComparator which compares two String charsets. The comparison follows the rules outlined in DataFlavor.selectBestTextFlavor. In order to ensure that non-Unicode, non-ASCII, non-default charsets are sorted in alphabetical order, charsets are not automatically converted to their canonical forms.

Field Summary

Modifier and TypeField and Description
private static final Map<String, Integer>
private static final Integer
pack-priv static final DataFlavorUtil.CharsetComparator
private static final Integer
private static final String
private static final Integer
private static final Integer

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public int

Returns:

a negative integer, zero, or a positive integer as the first argument is worse, equal to, or better than the second
compare
(String
the first charset to be compared
charset1
,
String
the second charset to be compared
charset2
)

Implements java.util.Comparator.compare.

Compares charsets.

pack-priv static String

Returns:

an encoding for this charset
getEncoding
(String
the charset
charset
)

Returns encoding for the specified charset according to the following rules:

  • If the charset is null, then null will be returned
  • Iff the charset specifies an encoding unsupported by this JRE, UNSUPPORTED_CHARSET will be returned
  • If the charset specifies an alias name, the corresponding canonical name will be returned iff the charset is a known Unicode, ASCII, or default charset
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

charsetsback to summary
private static final Map<String, Integer> charsets
DEFAULT_CHARSET_INDEXback to summary
private static final Integer DEFAULT_CHARSET_INDEX
INSTANCEback to summary
pack-priv static final DataFlavorUtil.CharsetComparator INSTANCE
OTHER_CHARSET_INDEXback to summary
private static final Integer OTHER_CHARSET_INDEX
UNSUPPORTED_CHARSETback to summary
private static final String UNSUPPORTED_CHARSET
UNSUPPORTED_CHARSET_INDEXback to summary
private static final Integer UNSUPPORTED_CHARSET_INDEX
WORST_CHARSET_INDEXback to summary
private static final Integer WORST_CHARSET_INDEX

Constructor Detail

CharsetComparatorback to summary
private CharsetComparator()

Method Detail

compareback to summary
public int compare(String charset1, String charset2)

Implements java.util.Comparator.compare.

Compares charsets. Returns a negative integer, zero, or a positive integer as the first charset is worse than, equal to, or better than the second.

Charsets are ordered according to the following rules:

  • All unsupported charsets are equal
  • Any unsupported charset is worse than any supported charset.
  • Unicode charsets, such as "UTF-16", "UTF-8", "UTF-16BE" and "UTF-16LE", are considered best
  • After them, platform default charset is selected
  • "US-ASCII" is the worst of supported charsets
  • For all other supported charsets, the lexicographically less one is considered the better
Parameters
charset1:String

the first charset to be compared

charset2:String

the second charset to be compared

Returns:int

a negative integer, zero, or a positive integer as the first argument is worse, equal to, or better than the second

getEncodingback to summary
pack-priv static String getEncoding(String charset)

Returns encoding for the specified charset according to the following rules:

  • If the charset is null, then null will be returned
  • Iff the charset specifies an encoding unsupported by this JRE, UNSUPPORTED_CHARSET will be returned
  • If the charset specifies an alias name, the corresponding canonical name will be returned iff the charset is a known Unicode, ASCII, or default charset
Parameters
charset:String

the charset

Returns:String

an encoding for this charset

sun.datatransfer back to summary

private Class DataFlavorUtil.DataFlavorComparator

extends Object
implements Comparator<DataFlavor>
Class Inheritance
All Implemented Interfaces
java.util.Comparator
Known Direct Subclasses
sun.datatransfer.DataFlavorUtil.TextFlavorComparator

An IndexedComparator which compares two DataFlavors. For text flavors, the comparison follows the rules outlined in selectBestTextFlavor. For non-text flavors, unknown application MIME types are preferred, followed by known application/x-java-* MIME types. Unknown application types are preferred because if the user provides his own data flavor, it will likely be the most descriptive one. For flavors which are otherwise equal, the flavors' string representation are compared in the alphabetical order.

Field Summary

Modifier and TypeField and Description
private static final Map<Class<?>, Integer>
private static final Map<Class<?>, Integer>
private static final Map<String, Integer>
pack-priv static final DataFlavorUtil.DataFlavorComparator
private static final Map<Class<?>, Integer>
private static final Map<String, Integer>
private static final Map<String, Integer>
private static final Integer
private static final Integer

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public int
compare(DataFlavor flavor1, DataFlavor flavor2)

Implements java.util.Comparator.compare.

Compares its two arguments for order.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

decodedTextRepresentationsback to summary
private static final Map<Class<?>, Integer> decodedTextRepresentations
encodedTextRepresentationsback to summary
private static final Map<Class<?>, Integer> encodedTextRepresentations
exactTypesback to summary
private static final Map<String, Integer> exactTypes
INSTANCEback to summary
pack-priv static final DataFlavorUtil.DataFlavorComparator INSTANCE
nonTextRepresentationsback to summary
private static final Map<Class<?>, Integer> nonTextRepresentations
primaryTypesback to summary
private static final Map<String, Integer> primaryTypes
textTypesback to summary
private static final Map<String, Integer> textTypes
UNKNOWN_OBJECT_LOSESback to summary
private static final Integer UNKNOWN_OBJECT_LOSES
UNKNOWN_OBJECT_WINSback to summary
private static final Integer UNKNOWN_OBJECT_WINS

Constructor Detail

DataFlavorComparatorback to summary
private DataFlavorComparator()

Method Detail

compareback to summary
public int compare(DataFlavor flavor1, DataFlavor flavor2)

Implements java.util.Comparator.compare.

Doc from java.util.Comparator.compare.

Compares its two arguments for order. Returns a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.

The implementor must ensure that signum(compare(x, y)) == -signum(compare(y, x)) for all x and y. (This implies that compare(x, y) must throw an exception if and only if compare(y, x) throws an exception.)

The implementor must also ensure that the relation is transitive: ((compare(x, y)>0) && (compare(y, z)>0)) implies compare(x, z)>0.

Finally, the implementor must ensure that compare(x, y)==0 implies that signum(compare(x, z))==signum(compare(y, z)) for all z.

sun.datatransfer back to summary

private final Class DataFlavorUtil.DefaultDesktopDatatransferService

extends Object
implements DesktopDatatransferService
Class Inheritance
  • java.lang.Object
  • sun.datatransfer.DataFlavorUtil.DefaultDesktopDatatransferService
All Implemented Interfaces
sun.datatransfer.DesktopDatatransferService

A fallback implementation of DesktopDatatransferService used if there is no desktop.

Field Summary

Modifier and TypeField and Description
private volatile FlavorMap
flavorMap

System singleton FlavorTable.

pack-priv static final DesktopDatatransferService

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public String
getDefaultUnicodeEncoding()

Implements sun.datatransfer.DesktopDatatransferService.getDefaultUnicodeEncoding.

Get a platform-dependent default unicode encoding to use in datatransfer system.

private static DesktopDatatransferService
public FlavorMap
getFlavorMap(Supplier<FlavorMap> supplier)

Implements sun.datatransfer.DesktopDatatransferService.getFlavorMap.

Takes an appropriate FlavorMap from the desktop.

public LinkedHashSet<String>
getPlatformMappingsForFlavor(DataFlavor df)

Implements sun.datatransfer.DesktopDatatransferService.getPlatformMappingsForFlavor.

Returns platform-specific mappings for the specified flavor.

public LinkedHashSet<DataFlavor>
getPlatformMappingsForNative(String nat)

Implements sun.datatransfer.DesktopDatatransferService.getPlatformMappingsForNative.

Returns platform-specific mappings for the specified native format.

public void
invokeOnEventThread(Runnable r)

Implements sun.datatransfer.DesktopDatatransferService.invokeOnEventThread.

If desktop is present - invokes a Runnable on the event dispatch thread.

public boolean
public void
registerTextFlavorProperties(String nat, String charset, String eoln, String terminators)

Implements sun.datatransfer.DesktopDatatransferService.registerTextFlavorProperties.

This method is called for text flavor mappings established while parsing the default flavor mappings file.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

flavorMapback to summary
private volatile FlavorMap flavorMap

System singleton FlavorTable. Only used if there is no desktop to provide an appropriate FlavorMap.

INSTANCEback to summary
pack-priv static final DesktopDatatransferService INSTANCE

Constructor Detail

DefaultDesktopDatatransferServiceback to summary
private DefaultDesktopDatatransferService()

Method Detail

getDefaultUnicodeEncodingback to summary
public String getDefaultUnicodeEncoding()

Implements sun.datatransfer.DesktopDatatransferService.getDefaultUnicodeEncoding.

Doc from sun.datatransfer.DesktopDatatransferService.getDefaultUnicodeEncoding.

Get a platform-dependent default unicode encoding to use in datatransfer system.

Annotations
@Override
getDesktopServiceback to summary
private static DesktopDatatransferService getDesktopService()
getFlavorMapback to summary
public FlavorMap getFlavorMap(Supplier<FlavorMap> supplier)

Implements sun.datatransfer.DesktopDatatransferService.getFlavorMap.

Doc from sun.datatransfer.DesktopDatatransferService.getFlavorMap.

Takes an appropriate FlavorMap from the desktop. If no appropriate table is found - uses a provided supplier to instantiate a table. If the desktop is absent - creates and returns a system singleton.

Annotations
@Override
getPlatformMappingsForFlavorback to summary
public LinkedHashSet<String> getPlatformMappingsForFlavor(DataFlavor df)

Implements sun.datatransfer.DesktopDatatransferService.getPlatformMappingsForFlavor.

Doc from sun.datatransfer.DesktopDatatransferService.getPlatformMappingsForFlavor.

Returns platform-specific mappings for the specified flavor. If there are no platform-specific mappings for this flavor, the method returns an empty Set.

Annotations
@Override
getPlatformMappingsForNativeback to summary
public LinkedHashSet<DataFlavor> getPlatformMappingsForNative(String nat)

Implements sun.datatransfer.DesktopDatatransferService.getPlatformMappingsForNative.

Doc from sun.datatransfer.DesktopDatatransferService.getPlatformMappingsForNative.

Returns platform-specific mappings for the specified native format. If there are no platform-specific mappings for this native, the method returns an empty Set.

Annotations
@Override
invokeOnEventThreadback to summary
public void invokeOnEventThread(Runnable r)

Implements sun.datatransfer.DesktopDatatransferService.invokeOnEventThread.

Doc from sun.datatransfer.DesktopDatatransferService.invokeOnEventThread.

If desktop is present - invokes a Runnable on the event dispatch thread. Otherwise invokes a run() method directly.

Annotations
@Override
isDesktopPresentback to summary
public boolean isDesktopPresent()

Implements sun.datatransfer.DesktopDatatransferService.isDesktopPresent.

Doc from sun.datatransfer.DesktopDatatransferService.isDesktopPresent.

Checks if desktop is present.

Annotations
@Override
registerTextFlavorPropertiesback to summary
public void registerTextFlavorProperties(String nat, String charset, String eoln, String terminators)

Implements sun.datatransfer.DesktopDatatransferService.registerTextFlavorProperties.

Doc from sun.datatransfer.DesktopDatatransferService.registerTextFlavorProperties.

This method is called for text flavor mappings established while parsing the default flavor mappings file. It stores the "eoln" and "terminators" parameters which are not officially part of the MIME type. They are MIME parameters specific to the flavormap.properties file format.

Annotations
@Override
sun.datatransfer back to summary

private Class DataFlavorUtil.IndexOrderComparator

extends Object
implements Comparator<Long>
Class Inheritance
All Implemented Interfaces
java.util.Comparator

Given the Map that maps objects to Integer indices and a boolean value, this Comparator imposes a direct or reverse order on set of objects.

If the specified boolean value is SELECT_BEST, the Comparator imposes the direct index-based order: an object A is greater than an object B if and only if the index of A is greater than the index of B. An object that doesn't have an associated index is less or equal than any other object.

If the specified boolean value is SELECT_WORST, the Comparator imposes the reverse index-based order: an object A is greater than an object B if and only if A is less than B with the direct index-based order.

Field Summary

Modifier and TypeField and Description
private static final Integer
private final Map<Long, Integer>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public int
compare(Long obj1, Long obj2)

Implements java.util.Comparator.compare.

Compares its two arguments for order.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

FALLBACK_INDEXback to summary
private static final Integer FALLBACK_INDEX
indexMapback to summary
private final Map<Long, Integer> indexMap

Constructor Detail

IndexOrderComparatorback to summary
public IndexOrderComparator(Map<Long, Integer> indexMap)

Method Detail

compareback to summary
public int compare(Long obj1, Long obj2)

Implements java.util.Comparator.compare.

Doc from java.util.Comparator.compare.

Compares its two arguments for order. Returns a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.

The implementor must ensure that signum(compare(x, y)) == -signum(compare(y, x)) for all x and y. (This implies that compare(x, y) must throw an exception if and only if compare(y, x) throws an exception.)

The implementor must also ensure that the relation is transitive: ((compare(x, y)>0) && (compare(y, z)>0)) implies compare(x, z)>0.

Finally, the implementor must ensure that compare(x, y)==0 implies that signum(compare(x, z))==signum(compare(y, z)) for all z.

sun.datatransfer back to summary

public Class DataFlavorUtil.RMI

extends Object
Class Inheritance

A class that provides access to java.rmi.Remote and java.rmi.MarshalledObject without creating a static dependency.

Field Summary

Modifier and TypeField and Description
private static final Constructor<?>
private static final Method
private static final Class<?>
private static final Class<?>

Constructor Summary

AccessConstructor and Description
public
RMI()

Method Summary

Modifier and TypeMethod and Description
private static Class<?>
private static Constructor<?>
getConstructor(Class<?> c, Class<?>... types)

public static Object
getMarshalledObject(Object obj)

Returns a new copy of the contained marshalled object.

private static Method
getMethod(Class<?> c, String name, Class<?>... types)

public static boolean
isRemote(Class<?> c)

Returns true if the given class is java.rmi.Remote.

public static Object
newMarshalledObject(Object obj)

Returns a new MarshalledObject containing the serialized representation of the given object.

pack-priv static Class<?>
remoteClass()

Returns java.rmi.Remote.class if RMI is present; otherwise null.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

marshallCtorback to summary
private static final Constructor<?> marshallCtor
marshallGetback to summary
private static final Method marshallGet
marshallObjectClassback to summary
private static final Class<?> marshallObjectClass
remoteClassback to summary
private static final Class<?> remoteClass

Constructor Detail

RMIback to summary
public RMI()

Method Detail

getClassback to summary
private static Class<?> getClass(String name)
getConstructorback to summary
private static Constructor<?> getConstructor(Class<?> c, Class<?>... types)
getMarshalledObjectback to summary
public static Object getMarshalledObject(Object obj) throws IOException, ClassNotFoundException

Returns a new copy of the contained marshalled object.

getMethodback to summary
private static Method getMethod(Class<?> c, String name, Class<?>... types)
isRemoteback to summary
public static boolean isRemote(Class<?> c)

Returns true if the given class is java.rmi.Remote.

newMarshalledObjectback to summary
public static Object newMarshalledObject(Object obj) throws IOException

Returns a new MarshalledObject containing the serialized representation of the given object.

remoteClassback to summary
pack-priv static Class<?> remoteClass()

Returns java.rmi.Remote.class if RMI is present; otherwise null.

sun.datatransfer back to summary

private Class DataFlavorUtil.StandardEncodingsHolder

extends Object
Class Inheritance

Lazy initialization of Standard Encodings.

Field Summary

Modifier and TypeField and Description
private static final SortedSet<String>

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private static SortedSet<String>
load()

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

standardEncodingsback to summary
private static final SortedSet<String> standardEncodings

Constructor Detail

StandardEncodingsHolderback to summary
private StandardEncodingsHolder()

Method Detail

loadback to summary
private static SortedSet<String> load()
sun.datatransfer back to summary

private Class DataFlavorUtil.TextFlavorComparator

extends DataFlavorComparator
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv static final DataFlavorUtil.TextFlavorComparator

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public int

Returns:

a negative integer, zero, or a positive integer as the first argument is worse, equal to, or better than the second
compare
(DataFlavor
the first DataFlavor to be compared
flavor1
,
DataFlavor
the second DataFlavor to be compared
flavor2
)

Overrides sun.datatransfer.DataFlavorUtil.DataFlavorComparator.compare.

Implements java.util.Comparator.compare.

Compares two DataFlavor objects.

Field Detail

INSTANCEback to summary
pack-priv static final DataFlavorUtil.TextFlavorComparator INSTANCE

Hides sun.datatransfer.DataFlavorUtil.DataFlavorComparator.INSTANCE.

Constructor Detail

TextFlavorComparatorback to summary
private TextFlavorComparator()

Method Detail

compareback to summary
public int compare(DataFlavor flavor1, DataFlavor flavor2)

Overrides sun.datatransfer.DataFlavorUtil.DataFlavorComparator.compare.

Implements java.util.Comparator.compare.

Compares two DataFlavor objects. Returns a negative integer, zero, or a positive integer as the first DataFlavor is worse than, equal to, or better than the second.

DataFlavors are ordered according to the rules outlined for selectBestTextFlavor.

Parameters
flavor1:DataFlavor

the first DataFlavor to be compared

flavor2:DataFlavor

the second DataFlavor to be compared

Returns:int

a negative integer, zero, or a positive integer as the first argument is worse, equal to, or better than the second

Exceptions
ClassCastException:
if either of the arguments is not an instance of DataFlavor
NullPointerException:
if either of the arguments is null
See Also
DataFlavor#selectBestTextFlavor