src/solaris/classes/sun/awt/X11/XDataTransferer.java
Print this page
@@ -210,14 +210,13 @@
/**
* Translates either a byte array or an input stream which contain
* platform-specific image data in the given format into an Image.
*/
- protected Image platformImageBytesOrStreamToImage(InputStream inputStream,
- byte[] bytes,
- long format)
- throws IOException {
+ protected Image platformImageBytesToImage(
+ byte[] bytes, long format) throws IOException
+ {
String mimeType = null;
if (format == PNG_ATOM.getAtom()) {
mimeType = "image/png";
} else if (format == JFIF_ATOM.getAtom()) {
mimeType = "image/jpeg";
@@ -233,11 +232,11 @@
} catch (Exception e) {
// Not an image MIME format.
}
}
if (mimeType != null) {
- return standardImageBytesOrStreamToImage(inputStream, bytes, mimeType);
+ return standardImageBytesToImage(bytes, mimeType);
} else {
String nativeFormat = getNativeForFormat(format);
throw new IOException("Translation from " + nativeFormat +
" is not supported.");
}
@@ -328,12 +327,12 @@
* types.
* To meet this requirement we check if the passed native format constitutes
* a valid MIME and return a list of flavors to which the data in this MIME
* type can be translated by the Data Transfer subsystem.
*/
- public List getPlatformMappingsForNative(String nat) {
- List flavors = new ArrayList();
+ public List <DataFlavor> getPlatformMappingsForNative(String nat) {
+ List <DataFlavor> flavors = new ArrayList();
if (nat == null) {
return flavors;
}
@@ -344,20 +343,18 @@
} catch (Exception e) {
// The string doesn't constitute a valid MIME type.
return flavors;
}
- Object value = df;
+ DataFlavor value = df;
final String primaryType = df.getPrimaryType();
final String baseType = primaryType + "/" + df.getSubType();
// For text formats we map natives to MIME strings instead of data
// flavors to enable dynamic text native-to-flavor mapping generation.
// See SystemFlavorMap.getFlavorsForNative() for details.
- if ("text".equals(primaryType)) {
- value = primaryType + "/" + df.getSubType();
- } else if ("image".equals(primaryType)) {
+ if ("image".equals(primaryType)) {
Iterator readers = ImageIO.getImageReadersByMIMEType(baseType);
if (readers.hasNext()) {
flavors.add(DataFlavor.imageFlavor);
}
}
@@ -436,20 +433,17 @@
}
}
}
}
} else if (DataTransferer.isFlavorCharsetTextType(df)) {
- final Iterator iter = DataTransferer.standardEncodings();
-
// stringFlavor is semantically equivalent to the standard
// "text/plain" MIME type.
if (DataFlavor.stringFlavor.equals(df)) {
baseType = "text/plain";
}
- while (iter.hasNext()) {
- String encoding = (String)iter.next();
+ for (String encoding : DataTransferer.standardEncodings()) {
if (!encoding.equals(charset)) {
natives.add(baseType + ";charset=" + encoding);
}
}