| Modifier and Type | Class and Description |
|---|---|
| public class | DataTransferer.
Used for decoding and reencoding an InputStream on demand so that we can strip NUL terminators and perform EOLN search-and-replace. |
| Modifier and Type | Field and Description |
|---|---|
| private static volatile Runnable | dataConverterInstance
The Runnable for pending data conversion requests. |
| public static final DataFlavor | javaTextEncodingFlavor
The
representationClass = [B
mimeType = "application/x-java-text-encoding"
|
| private static final Map | nativeCharsets
The native encodings/charsets for the Set of textNatives. |
| private static final Map | nativeEOLNs
The end-of-line markers for the Set of textNatives. |
| private static final Map | nativeTerminators
The number of terminating NUL bytes for the Set of textNatives. |
| private static final Set | textNatives
A collection of all natives listed in flavormap.properties with a primary MIME type of "text". |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public static FlavorTable | |
| private File | |
| private ArrayList | |
| private Object | Returns: a byte array or anInputStream which represents
a logical concatenation of the two arguments.the first object to be concatenated. obj1, Object the second object to be concatenated. obj2)Concatenates the data represented by two objects. |
| private Object | constructFlavoredObject(Object arg, DataFlavor flavor, Class<?> clazz)
We support representations which are exactly of the specified Class, and also arbitrary Objects which have a constructor which takes an instance of the Class as its sole parameter. |
| public byte[] | convertData(final Object source, final Transferable contents, final long format, final Map<Long, DataFlavor> formatMap, final boolean isToolkitThread)
|
| protected abstract ByteArrayOutputStream | |
| private static byte[] | |
| protected abstract String[] | |
| protected URI[] | dragQueryURIs(InputStream stream, long format, Transferable localeTransferable)
Decodes URIs from either a byte array or a stream. |
| protected String | |
| protected String | |
| public abstract String | |
| 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. |
| public DataFlavor[] | getFlavorsForFormatsAsArray(long[]
the data formats formats, FlavorTable the FlavorTable which contains mappings between
DataFlavors and data formats 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. |
| public Set | getFlavorsForFormatsAsSet(long[]
the data formats formats, FlavorTable the FlavorTable which contains mappings between
DataFlavors and data formats 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. |
| protected abstract 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 | getFormatsForFlavors(DataFlavor[]
the data flavors flavors, FlavorTable the FlavorTable which contains mappings between
DataFlavors and data formats map)Returns a Map whose keys are all of the possible formats into which data in the specified DataFlavors can be translated. |
| 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. |
| 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 synchronized DataTransferer | |
| protected abstract String | getNativeForFormat(long format)
Looks-up the String native corresponding to the specified long format in the native data transfer system. |
| public LinkedHashSet | getPlatformMappingsForFlavor(DataFlavor df)
Returns platform-specific mappings for the specified flavor. |
| public LinkedHashSet | getPlatformMappingsForNative(String nat)
Returns platform-specific mappings for the specified native. |
| public abstract ToolkitThreadBlockedHandler | |
| protected abstract byte[] | imageToPlatformBytes(Image image, long format)
Translates a Java Image into a byte array which contains platform- specific image data in the given format. |
| protected byte[] | imageToStandardBytes(Image image, String
image MIME type, such as: image/png, image/jpeg mimeType)Translates a Java Image into a byte array which contains an image data in the given standard format. |
| pack-priv byte[] | |
| protected static byte[] | |
| public abstract boolean | isFileFormat(long format)
Determines whether the DataFlavor corresponding to the specified long format is DataFlavor.javaFileListFlavor. |
| public abstract boolean | isImageFormat(long format)
Determines whether the DataFlavor corresponding to the specified long format is DataFlavor.imageFlavor. |
| public abstract boolean | isLocaleDependentTextFormat(long format)
Specifies whether text imported from the native system in the specified format is locale-dependent. |
| 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 long[] | keysToLongArray(SortedMap<Long, ?> map)
Helper function to reduce a Map with Long keys to a long array. |
| protected abstract Image | platformImageBytesToImage(byte[] bytes, long format)
Translates either a byte array or an input stream which contain platform-specific image data in the given format into an Image. |
| public void | |
| 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. |
| public static DataFlavor[] | setToSortedDataFlavorArray(Set<DataFlavor> flavorsSet)
Helper function to convert a Set of DataFlavors to a sorted array. |
| protected Image | standardImageBytesToImage(byte[] bytes, String
image MIME type, such as: image/png, image/jpeg, image/gif mimeType)Translates either a byte array or an input stream which contain an image data in the given standard format into an Image. |
| public Object | |
| private String | translateBytesToString(byte[] bytes, long format, Transferable localeTransferable)
Translating either a byte array or an InputStream into an String. |
| public Object | translateStream(InputStream str, DataFlavor flavor, long format, Transferable localeTransferable)
Primary translation function for translating an InputStream into an Object, given a source format and a target DataFlavor. |
| private Object | translateStreamToInputStream(InputStream str, DataFlavor flavor, long format, Transferable localeTransferable)
For arbitrary flavors, just use the raw InputStream. |
| public byte[] | translateTransferable(Transferable contents, DataFlavor flavor, long format)
Primary translation function for translating a Transferable into a byte array, given a source DataFlavor and target format. |
| private byte[] | translateTransferableString(String str, long format)
Translation function for converting string into a byte array. |
| dataConverterInstance | back to summary |
|---|---|
| private static volatile Runnable dataConverterInstance The Runnable for pending data conversion requests. | |
| javaTextEncodingFlavor | back to summary |
|---|---|
| public static final DataFlavor javaTextEncodingFlavor The
representationClass = [B
mimeType = "application/x-java-text-encoding"
| |
| nativeCharsets | back to summary |
|---|---|
| private static final Map<Long, String> nativeCharsets The native encodings/charsets for the Set of textNatives. | |
| nativeEOLNs | back to summary |
|---|---|
| private static final Map<Long, String> nativeEOLNs The end-of-line markers for the Set of textNatives. | |
| nativeTerminators | back to summary |
|---|---|
| private static final Map<Long, Integer> nativeTerminators The number of terminating NUL bytes for the Set of textNatives. | |
| textNatives | back to summary |
|---|---|
| private static final Set<Long> textNatives A collection of all natives listed in flavormap.properties with a primary MIME type of "text". | |
| DataTransferer | back to summary |
|---|---|
| public DataTransferer() | |
| adaptFlavorMap | back to summary |
|---|---|
| public static FlavorTable adaptFlavorMap(final FlavorMap map) Converts a FlavorMap to a FlavorTable. | |
| castToFile | back to summary |
|---|---|
| private File castToFile(Object fileObject) throws IOException | |
| castToFiles | back to summary |
|---|---|
| private ArrayList | |
| concatData | back to summary |
|---|---|
| private Object concatData(Object obj1, Object obj2) Concatenates the data represented by two objects. Objects can be either
byte arrays or instances of Currently is only called from native code to prepend palette data to platform-specific image data during image transfer on Win32.
| |
| constructFlavoredObject | back to summary |
|---|---|
| private Object constructFlavoredObject(Object arg, DataFlavor flavor, Class<?> clazz) throws IOException We support representations which are exactly of the specified Class, and also arbitrary Objects which have a constructor which takes an instance of the Class as its sole parameter. | |
| convertData | back to summary |
|---|---|
| public byte[] convertData(final Object source, final Transferable contents, final long format, final Map<Long, DataFlavor> formatMap, final boolean isToolkitThread) throws IOException | |
| convertFileListToBytes | back to summary |
|---|---|
| protected abstract ByteArrayOutputStream convertFileListToBytes(ArrayList<String> fileList) throws IOException | |
| convertObjectToBytes | back to summary |
|---|---|
| private static byte[] convertObjectToBytes(Object object) throws IOException | |
| dragQueryFile | back to summary |
|---|---|
| protected abstract String[] dragQueryFile(byte[] bytes) Decodes a byte array into a set of String filenames. | |
| dragQueryURIs | back to summary |
|---|---|
| protected URI[] dragQueryURIs(InputStream stream, long format, Transferable localeTransferable) throws IOException Decodes URIs from either a byte array or a stream. | |
| getBestCharsetForTextFormat | back to summary |
|---|---|
| protected String getBestCharsetForTextFormat(Long lFormat, Transferable localeTransferable) throws IOException | |
| getCharsetForTextFormat | back to summary |
|---|---|
| protected String getCharsetForTextFormat(Long lFormat) | |
| getDefaultUnicodeEncoding | back to summary |
|---|---|
| public abstract 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(). | |
| getFlavorsForFormats | back to summary |
|---|---|
| public 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. | |
| getFlavorsForFormatsAsArray | back to summary |
|---|---|
| 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
| |
| getFlavorsForFormatsAsSet | back to summary |
|---|---|
| public Set 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.
| |
| getFormatForNativeAsLong | back to summary |
|---|---|
| protected abstract 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. | |
| getFormatsForFlavors | back to summary |
|---|---|
| public SortedMap 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.
| |
| getFormatsForTransferable | back to summary |
|---|---|
| public SortedMap 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. | |
| getFormatsForTransferableAsArray | back to summary |
|---|---|
| public long[] getFormatsForTransferableAsArray(Transferable contents, FlavorTable map) Reduces the Map output for the root function to an array of the Map's keys. | |
| getInstance | back to summary |
|---|---|
| public static synchronized 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. | |
| getNativeForFormat | back to summary |
|---|---|
| protected abstract String getNativeForFormat(long format) Looks-up the String native corresponding to the specified long format in the native data transfer system. | |
| getPlatformMappingsForFlavor | back to summary |
|---|---|
| public LinkedHashSet Returns platform-specific mappings for the specified flavor.
If there are no platform-specific mappings for this flavor, the method
returns an empty | |
| getPlatformMappingsForNative | back to summary |
|---|---|
| public LinkedHashSet Returns platform-specific mappings for the specified native.
If there are no platform-specific mappings for this native, the method
returns an empty | |
| getToolkitThreadBlockedHandler | back to summary |
|---|---|
| public abstract ToolkitThreadBlockedHandler getToolkitThreadBlockedHandler() | |
| imageToPlatformBytes | back to summary |
|---|---|
| protected abstract 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. | |
| imageToStandardBytes | back to summary |
|---|---|
| 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.
| |
| imageToStandardBytesImpl | back to summary |
|---|---|
| pack-priv byte[] imageToStandardBytesImpl(RenderedImage renderedImage, String mimeType) throws IOException | |
| inputStreamToByteArray | back to summary |
|---|---|
| protected static byte[] inputStreamToByteArray(InputStream str) throws IOException Helper function to convert an InputStream to a byte[] array. | |
| isFileFormat | back to summary |
|---|---|
| public abstract boolean isFileFormat(long format) Determines whether the DataFlavor corresponding to the specified long format is DataFlavor.javaFileListFlavor. | |
| isImageFormat | back to summary |
|---|---|
| public abstract boolean isImageFormat(long format) Determines whether the DataFlavor corresponding to the specified long format is DataFlavor.imageFlavor. | |
| isLocaleDependentTextFormat | back to summary |
|---|---|
| public abstract 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. | |
| isTextFormat | back to summary |
|---|---|
| protected boolean isTextFormat(long format) Determines whether the native corresponding to the specified long format was listed in the flavormap.properties file. | |
| isURIListFormat | back to summary |
|---|---|
| protected boolean isURIListFormat(long format) Determines whether the format is a URI list we can convert to a DataFlavor.javaFileListFlavor. | |
| keysToLongArray | back to summary |
|---|---|
| public static long[] keysToLongArray(SortedMap<Long, ?> 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. | |
| platformImageBytesToImage | back to summary |
|---|---|
| protected abstract Image platformImageBytesToImage(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. | |
| processDataConversionRequests | back to summary |
|---|---|
| public void processDataConversionRequests() | |
| registerTextFlavorProperties | back to summary |
|---|---|
| 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. | |
| setToSortedDataFlavorArray | back to summary |
|---|---|
| public static DataFlavor[] setToSortedDataFlavorArray(Set<DataFlavor> flavorsSet) Helper function to convert a Set of DataFlavors to a sorted array.
The array will be sorted according to | |
| standardImageBytesToImage | back to summary |
|---|---|
| protected Image standardImageBytesToImage(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.
| |
| translateBytes | back to summary |
|---|---|
| public Object translateBytes(byte[] bytes, DataFlavor flavor, long format, Transferable localeTransferable) throws IOException | |
| translateBytesToString | back to summary |
|---|---|
| private String translateBytesToString(byte[] bytes, long format, Transferable localeTransferable) throws IOException Translating either a byte array or an InputStream into an String. Strip terminators and search-and-replace EOLN. Native to Java string conversion | |
| translateStream | back to summary |
|---|---|
| public Object translateStream(InputStream str, DataFlavor flavor, long format, Transferable localeTransferable) throws IOException Primary translation function for translating an InputStream into an Object, given a source format and a target DataFlavor.
| |
| translateStreamToInputStream | back to summary |
|---|---|
| private Object translateStreamToInputStream(InputStream str, DataFlavor flavor, long format, Transferable localeTransferable) throws IOException For arbitrary flavors, just use the raw InputStream. For text flavors, ReencodingInputStream will decode and reencode the InputStream on demand so that we can strip terminators and search-and-replace EOLN. | |
| translateTransferable | back to summary |
|---|---|
| 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.
| |
| translateTransferableString | back to summary |
|---|---|
| private byte[] translateTransferableString(String str, long format) throws IOException Translation function for converting string into a byte array. Search-and-replace EOLN. Encode into the target format. Append terminating NUL bytes. Java to Native string conversion | |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv CharsetEncoder | |
| pack-priv char[] | |
| pack-priv boolean | |
| pack-priv final char[] | |
| pack-priv CharBuffer | |
| pack-priv int | |
| pack-priv int | |
| pack-priv int | |
| pack-priv byte[] | |
| pack-priv ByteBuffer | |
| pack-priv BufferedReader |
| Access | Constructor and Description |
|---|---|
| public | ReencodingInputStream(InputStream bytestream, long format, String targetEncoding, Transferable localeTransferable)
|
| Modifier and Type | Method and Description |
|---|---|
| public int | available()
Overrides java. Returns an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking, which may be 0, or 0 when end of stream is detected. |
| public void | close()
Overrides java. Implements java. Closes this input stream and releases any system resources associated with the stream. |
| private boolean | matchCharArray(char[] array, int c)
Checks to see if the next array.length characters in wrapped match array. |
| public int | read()
Implements abstract java. Reads the next byte of data from the input stream. |
| private int |
| encoder | back to summary |
|---|---|
| pack-priv CharsetEncoder encoder | |
| eoln | back to summary |
|---|---|
| pack-priv char[] eoln | |
| eos | back to summary |
|---|---|
| pack-priv boolean eos | |
| in | back to summary |
|---|---|
| pack-priv final char[] in | |
| inBuf | back to summary |
|---|---|
| pack-priv CharBuffer inBuf | |
| index | back to summary |
|---|---|
| pack-priv int index | |
| limit | back to summary |
|---|---|
| pack-priv int limit | |
| numTerminators | back to summary |
|---|---|
| pack-priv int numTerminators | |
| out | back to summary |
|---|---|
| pack-priv byte[] out | |
| outBuf | back to summary |
|---|---|
| pack-priv ByteBuffer outBuf | |
| wrapped | back to summary |
|---|---|
| pack-priv BufferedReader wrapped | |
| ReencodingInputStream | back to summary |
|---|---|
| public ReencodingInputStream(InputStream bytestream, long format, String targetEncoding, Transferable localeTransferable) throws IOException | |
| available | back to summary |
|---|---|
| public int available() throws IOException Overrides java. Doc from java. Returns an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking, which may be 0, or 0 when end of stream is detected. The read might be on the same thread or another thread. A single read or skip of this many bytes will not block, but may read or skip fewer bytes. Note that while some implementations of A subclass's implementation of this method may choose to throw an
| |
| close | back to summary |
|---|---|
| public void close() throws IOException Overrides java. Implements java. Doc from java. Closes this input stream and releases any system resources associated with the stream.
| |
| matchCharArray | back to summary |
|---|---|
| private boolean matchCharArray(char[] array, int c) throws IOException Checks to see if the next array.length characters in wrapped match array. The first character is provided as c. Subsequent characters are read from wrapped itself. When this method returns, the wrapped index may be different from what it was when this method was called. | |
| read | back to summary |
|---|---|
| public int read() throws IOException Implements abstract java. Doc from java. Reads the next byte of data from the input stream. The value byte is
returned as an
| |
| readChar | back to summary |
|---|---|
| private int readChar() throws IOException | |