Home » openjdk-7 » sun » awt » datatransfer » [javadoc | source]
sun.awt.datatransfer
abstract public class: DataTransferer [javadoc | source]
java.lang.Object
   sun.awt.datatransfer.DataTransferer

Direct Known Subclasses:
    XDataTransferer, MDataTransferer, WDataTransferer

Provides a set of functions to be shared among the DataFlavor class and platform-specific data transfer implementations. The concept of "flavors" and "natives" is extended to include "formats", which are the numeric values Win32 and X11 use to express particular data types. Like FlavorMap, which provides getNativesForFlavors(DataFlavor[]) and getFlavorsForNatives(String[]) functions, DataTransferer provides a set of getFormatsFor(Transferable|Flavor|Flavors) and getFlavorsFor(Format|Formats) functions. Also provided are functions for translating a Transferable into a byte array, given a source DataFlavor and a target format, and for translating a byte array or InputStream into an Object, given a source format and a target DataFlavor.
Nested Class Summary:
public class  DataTransferer.ReencodingInputStream  Used for decoding and reencoding an InputStream on demand so that we can strip NUL terminators and perform EOLN search-and-replace. 
abstract public static class  DataTransferer.IndexedComparator  A Comparator which includes a helper function for comparing two Objects which are likely to be keys in the specified Map. 
public static class  DataTransferer.CharsetComparator  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. 
public static class  DataTransferer.DataFlavorComparator  An IndexedComparator which compares two DataFlavors. For text flavors, the comparison follows the rules outlined in DataFlavor.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' native formats are compared, with greater long values taking precedence. 
public static class  DataTransferer.IndexOrderComparator   
Field Summary
public static final  Class charArrayClass    Cached value of Class.forName("[C"); 
public static final  Class byteArrayClass    Cached value of Class.forName("[B"); 
public static final  DataFlavor plainTextStringFlavor    The DataFlavor representing plain text with Unicode encoding, where:
    representationClass = java.lang.String
    mimeType            = "text/plain; charset=Unicode"
 
public static final  DataFlavor javaTextEncodingFlavor    The DataFlavor representing a Java text encoding String encoded in UTF-8, where
    representationClass = [B
    mimeType            = "application/x-java-text-encoding"
 
Method from sun.awt.datatransfer.DataTransferer Summary:
adaptFlavorMap,   canonicalName,   convertData,   convertFileListToBytes,   doesSubtypeSupportCharset,   doesSubtypeSupportCharset,   dragQueryFile,   dragQueryURIs,   getCharsetForTextFormat,   getDefaultTextCharset,   getDefaultUnicodeEncoding,   getFlavorsForFormat,   getFlavorsForFormatAsArray,   getFlavorsForFormats,   getFlavorsForFormatsAsArray,   getFlavorsForFormatsAsSet,   getFormatForNativeAsLong,   getFormatsForFlavor,   getFormatsForFlavorAsArray,   getFormatsForFlavors,   getFormatsForFlavorsAsArray,   getFormatsForTransferable,   getFormatsForTransferableAsArray,   getInstance,   getNativeForFormat,   getPlatformMappingsForFlavor,   getPlatformMappingsForNative,   getTextCharset,   getToolkitThreadBlockedHandler,   imageToPlatformBytes,   imageToStandardBytes,   imageToStandardBytesImpl,   inputStreamToByteArray,   isEncodingSupported,   isFileFormat,   isFlavorCharsetTextType,   isFlavorNoncharsetTextType,   isImageFormat,   isLocaleDependentTextFormat,   isRemote,   isTextFormat,   isURIListFormat,   keysToDataFlavorArray,   keysToLongArray,   platformImageBytesOrStreamToImage,   processDataConversionRequests,   registerTextFlavorProperties,   setToSortedDataFlavorArray,   setToSortedDataFlavorArray,   standardEncodings,   standardImageBytesOrStreamToImage,   translateBytes,   translateBytesOrStream,   translateStream,   translateTransferable
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from sun.awt.datatransfer.DataTransferer Detail:
 public static FlavorTable adaptFlavorMap(FlavorMap map) 
    Converts a FlavorMap to a FlavorTable.
 public static String canonicalName(String encoding) 
    Converts an arbitrary text encoding to its canonical name.
 public byte[] convertData(Object source,
    Transferable contents,
    long format,
    Map formatMap,
    boolean isToolkitThread) throws IOException 
 abstract protected ByteArrayOutputStream convertFileListToBytes(ArrayList<String> fileList) throws IOException
 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".
 public static boolean doesSubtypeSupportCharset(String subType,
    String charset) 
 abstract protected String[] dragQueryFile(byte[] bytes)
    Decodes a byte array into a set of String filenames.
 protected URI[] dragQueryURIs(InputStream stream,
    byte[] bytes,
    long format,
    Transferable localeTransferable) throws IOException 
    Decodes URIs from either a byte array or a stream.
 protected String getCharsetForTextFormat(Long lFormat) 
 public static String getDefaultTextCharset() 
    Returns the platform's default character encoding.
 abstract public String getDefaultUnicodeEncoding()
    Returns the default Unicode encoding for the platform. The encoding need not be canonical. This method is only used by the archaic function DataFlavor.getTextPlainUnicodeFlavor().
 public Map getFlavorsForFormat(long format,
    FlavorTable map) 
    Returns a Map whose keys are all of the possible DataFlavors into which data in the specified format can be translated. The value of each key is the format in which the Clipboard or dropped data should be requested when converting to the DataFlavor.
 public DataFlavor[] getFlavorsForFormatAsArray(long format,
    FlavorTable map) 
    Returns an array of all DataFlavors for which 1) a mapping from the specified format exists in the specified map and 2) the data translation for this mapping can be performed by the data transfer subsystem. The array will be sorted according to a DataFlavorComparator created with the specified map as an argument.
 public Map getFlavorsForFormats(long[] formats,
    FlavorTable map) 
    Returns a Map whose keys are all of the possible DataFlavors into which data in the specified formats can be translated. The value of each key is the format in which the Clipboard or dropped data should be requested when converting to the DataFlavor.
 public DataFlavor[] getFlavorsForFormatsAsArray(long[] formats,
    FlavorTable map) 
    Returns an array of all DataFlavors for which 1) a mapping from at least one of the specified formats exists in the specified map and 2) the data translation for this mapping can be performed by the data transfer subsystem. The array will be sorted according to a DataFlavorComparator created with the specified map as an argument.
 public Set getFlavorsForFormatsAsSet(long[] formats,
    FlavorTable map) 
    Returns a Set of all DataFlavors for which 1) a mapping from at least one of the specified formats exists in the specified map and 2) the data translation for this mapping can be performed by the data transfer subsystem.
 abstract protected Long getFormatForNativeAsLong(String str)
    Looks-up or registers the String native with the native data transfer system and returns a long format corresponding to that native.
 public SortedMap getFormatsForFlavor(DataFlavor flavor,
    FlavorTable map) 
    Returns a Map whose keys are all of the possible formats into which data in the specified DataFlavor can be translated. The value of each key is the DataFlavor in which a Transferable's data should be requested when converting to the format.

    The map keys are sorted according to the native formats preference order.

 public long[] getFormatsForFlavorAsArray(DataFlavor flavor,
    FlavorTable map) 
 public SortedMap getFormatsForFlavors(DataFlavor[] flavors,
    FlavorTable map) 
    Returns a Map whose keys are all of the possible formats into which data in the specified DataFlavors can be translated. The value of each key is the DataFlavor in which the Transferable's data should be requested when converting to the format.

    The map keys are sorted according to the native formats preference order.

 public long[] getFormatsForFlavorsAsArray(DataFlavor[] flavors,
    FlavorTable map) 
 public SortedMap getFormatsForTransferable(Transferable contents,
    FlavorTable map) 
    Returns a Map whose keys are all of the possible formats into which the Transferable's transfer data flavors can be translated. The value of each key is the DataFlavor in which the Transferable's data should be requested when converting to the format.

    The map keys are sorted according to the native formats preference order.

 public long[] getFormatsForTransferableAsArray(Transferable contents,
    FlavorTable map) 
    Reduces the Map output for the root function to an array of the Map's keys.
 public static DataTransferer getInstance() 
    The accessor method for the singleton DataTransferer instance. Note that in a headless environment, there may be no DataTransferer instance; instead, null will be returned.
 abstract protected String getNativeForFormat(long format)
    Looks-up the String native corresponding to the specified long format in the native data transfer system.
 public List getPlatformMappingsForFlavor(DataFlavor df) 
    Returns platform-specific mappings for the specified flavor. If there are no platform-specific mappings for this flavor, the method returns an empty List.
 public List getPlatformMappingsForNative(String nat) 
    Returns platform-specific mappings for the specified native. If there are no platform-specific mappings for this native, the method returns an empty List.
 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.
 abstract public ToolkitThreadBlockedHandler getToolkitThreadBlockedHandler()
 abstract protected byte[] imageToPlatformBytes(Image image,
    long format) throws IOException
    Translates a Java Image into a byte array which contains platform- specific image data in the given format.
 protected byte[] imageToStandardBytes(Image image,
    String mimeType) throws IOException 
    Translates a Java Image into a byte array which contains an image data in the given standard format.
 protected byte[] imageToStandardBytesImpl(RenderedImage renderedImage,
    String mimeType) throws IOException 
 protected static byte[] inputStreamToByteArray(InputStream str) throws IOException 
    Helper function to convert an InputStream to a byte[] array.
 public static boolean isEncodingSupported(String encoding) 
    Determines whether this JRE can both encode and decode text in the specified encoding.
 abstract public boolean isFileFormat(long format)
    Determines whether the DataFlavor corresponding to the specified long format is DataFlavor.javaFileListFlavor.
 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.
 abstract public boolean isImageFormat(long format)
    Determines whether the DataFlavor corresponding to the specified long format is DataFlavor.imageFlavor.
 abstract public boolean isLocaleDependentTextFormat(long format)
    Specifies whether text imported from the native system in the specified format is locale-dependent. If so, when decoding such text, 'nativeCharsets' should be ignored, and instead, the Transferable should be queried for its javaTextEncodingFlavor data for the correct encoding.
 public static boolean isRemote(Class<?> type) 
    Returns {@code true} if the given type is a java.rmi.Remote.
 protected boolean isTextFormat(long format) 
    Determines whether the native corresponding to the specified long format was listed in the flavormap.properties file.
 protected boolean isURIListFormat(long format) 
    Determines whether the format is a URI list we can convert to a DataFlavor.javaFileListFlavor.
 public static DataFlavor[] keysToDataFlavorArray(Map map) 
    Helper function to reduce a Map with DataFlavor keys to a DataFlavor array. The array will be sorted according to DataFlavorComparator.
 public static long[] keysToLongArray(SortedMap map) 
    Helper function to reduce a Map with Long keys to a long array.

    The map keys are sorted according to the native formats preference order.

 abstract protected Image platformImageBytesOrStreamToImage(InputStream str,
    byte[] bytes,
    long format) throws IOException
    Translates either a byte array or an input stream which contain platform-specific image data in the given format into an Image.
 public  void processDataConversionRequests() 
 public  void registerTextFlavorProperties(String nat,
    String charset,
    String eoln,
    String terminators) 
    This method is called for text flavor mappings established while parsing the flavormap.properties 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.
 public static DataFlavor[] setToSortedDataFlavorArray(Set flavorsSet) 
    Helper function to convert a Set of DataFlavors to a sorted array. The array will be sorted according to DataFlavorComparator.
 public static DataFlavor[] setToSortedDataFlavorArray(Set flavorsSet,
    Map flavorToNativeMap) 
    Helper function to convert a Set of DataFlavors to a sorted array. The array will be sorted according to a DataFlavorComparator created with the specified flavor-to-native map as an argument.
 public static Iterator standardEncodings() 
    Returns an Iterator which traverses 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. So as to avoid loading all available character converters, optional, non-standard, character sets are not included.
 protected Image standardImageBytesOrStreamToImage(InputStream inputStream,
    byte[] bytes,
    String mimeType) throws IOException 
    Translates either a byte array or an input stream which contain an image data in the given standard format into an Image.
 public Object translateBytes(byte[] bytes,
    DataFlavor flavor,
    long format,
    Transferable localeTransferable) throws IOException 
 protected Object translateBytesOrStream(InputStream str,
    byte[] bytes,
    DataFlavor flavor,
    long format,
    Transferable localeTransferable) throws IOException 
    Primary translation function for translating either a byte array or an InputStream into an Object, given a source format and a target DataFlavor. One of str/bytes is non-null; the other is null. The conversion from byte[] to InputStream is cheap, so do that immediately if necessary. The opposite conversion is expensive, so avoid it if possible.
 public Object translateStream(InputStream str,
    DataFlavor flavor,
    long format,
    Transferable localeTransferable) throws IOException 
 public byte[] translateTransferable(Transferable contents,
    DataFlavor flavor,
    long format) throws IOException 
    Primary translation function for translating a Transferable into a byte array, given a source DataFlavor and target format.