src/solaris/classes/sun/awt/X11/XDataTransferer.java

Print this page

        

*** 27,37 **** import java.awt.Image; import java.awt.datatransfer.DataFlavor; import java.awt.datatransfer.Transferable; - import java.awt.datatransfer.UnsupportedFlavorException; import java.awt.image.BufferedImage; import java.awt.image.ColorModel; import java.awt.image.WritableRaster; --- 27,36 ----
*** 44,66 **** import java.net.URISyntaxException; import java.util.ArrayList; import java.util.Iterator; import java.util.LinkedHashSet; - import java.util.List; import javax.imageio.ImageIO; import javax.imageio.ImageReader; import javax.imageio.ImageTypeSpecifier; import javax.imageio.ImageWriter; import javax.imageio.spi.ImageWriterSpi; import sun.awt.datatransfer.DataTransferer; import sun.awt.datatransfer.ToolkitThreadBlockedHandler; import java.io.ByteArrayOutputStream; - import java.util.stream.Stream; /** * Platform-specific support for the data transfer subsystem. */ public class XDataTransferer extends DataTransferer { --- 43,64 ---- import java.net.URISyntaxException; import java.util.ArrayList; import java.util.Iterator; import java.util.LinkedHashSet; import javax.imageio.ImageIO; import javax.imageio.ImageReader; import javax.imageio.ImageTypeSpecifier; import javax.imageio.ImageWriter; import javax.imageio.spi.ImageWriterSpi; + import sun.datatransfer.DataFlavorUtil; import sun.awt.datatransfer.DataTransferer; import sun.awt.datatransfer.ToolkitThreadBlockedHandler; import java.io.ByteArrayOutputStream; /** * Platform-specific support for the data transfer subsystem. */ public class XDataTransferer extends DataTransferer {
*** 85,125 **** transferer = new XDataTransferer(); } return transferer; } public String getDefaultUnicodeEncoding() { return "iso-10646-ucs-2"; } public boolean isLocaleDependentTextFormat(long format) { return false; } public boolean isTextFormat(long format) { return super.isTextFormat(format) || isMimeFormat(format, "text"); } protected String getCharsetForTextFormat(Long lFormat) { ! long format = lFormat.longValue(); ! if (isMimeFormat(format, "text")) { ! String nat = getNativeForFormat(format); DataFlavor df = new DataFlavor(nat, null); // Ignore the charset parameter of the MIME type if the subtype // doesn't support charset. ! if (!DataTransferer.doesSubtypeSupportCharset(df)) { return null; } String charset = df.getParameter("charset"); if (charset != null) { return charset; } } return super.getCharsetForTextFormat(lFormat); } protected boolean isURIListFormat(long format) { String nat = getNativeForFormat(format); if (nat == null) { return false; } --- 83,127 ---- transferer = new XDataTransferer(); } return transferer; } + @Override public String getDefaultUnicodeEncoding() { return "iso-10646-ucs-2"; } + @Override public boolean isLocaleDependentTextFormat(long format) { return false; } + @Override public boolean isTextFormat(long format) { return super.isTextFormat(format) || isMimeFormat(format, "text"); } + @Override protected String getCharsetForTextFormat(Long lFormat) { ! if (isMimeFormat(lFormat, "text")) { ! String nat = getNativeForFormat(lFormat); DataFlavor df = new DataFlavor(nat, null); // Ignore the charset parameter of the MIME type if the subtype // doesn't support charset. ! if (!DataFlavorUtil.doesSubtypeSupportCharset(df)) { return null; } String charset = df.getParameter("charset"); if (charset != null) { return charset; } } return super.getCharsetForTextFormat(lFormat); } + @Override protected boolean isURIListFormat(long format) { String nat = getNativeForFormat(format); if (nat == null) { return false; }
*** 132,159 **** // Not a MIME format. } return false; } public boolean isFileFormat(long format) { return format == FILE_NAME_ATOM.getAtom() || format == DT_NET_FILE_ATOM.getAtom(); } public boolean isImageFormat(long format) { return format == PNG_ATOM.getAtom() || format == JFIF_ATOM.getAtom() || isMimeFormat(format, "image"); } protected Long getFormatForNativeAsLong(String str) { // Just get the atom. If it has already been retrived // once, we'll get a copy so this should be very fast. ! long atom = XAtom.get(str).getAtom(); ! return Long.valueOf(atom); } protected String getNativeForFormat(long format) { return getTargetNameForAtom(format); } public ToolkitThreadBlockedHandler getToolkitThreadBlockedHandler() { --- 134,164 ---- // Not a MIME format. } return false; } + @Override public boolean isFileFormat(long format) { return format == FILE_NAME_ATOM.getAtom() || format == DT_NET_FILE_ATOM.getAtom(); } + @Override public boolean isImageFormat(long format) { return format == PNG_ATOM.getAtom() || format == JFIF_ATOM.getAtom() || isMimeFormat(format, "image"); } + @Override protected Long getFormatForNativeAsLong(String str) { // Just get the atom. If it has already been retrived // once, we'll get a copy so this should be very fast. ! return XAtom.get(str).getAtom(); } + @Override protected String getNativeForFormat(long format) { return getTargetNameForAtom(format); } public ToolkitThreadBlockedHandler getToolkitThreadBlockedHandler() {
*** 165,174 **** --- 170,180 ---- */ private String getTargetNameForAtom(long atom) { return XAtom.get(atom).getName(); } + @Override protected byte[] imageToPlatformBytes(Image image, long format) throws IOException { String mimeType = null; if (format == PNG_ATOM.getAtom()) { mimeType = "image/png";
*** 194,203 **** --- 200,210 ---- throw new IOException("Translation to " + nativeFormat + " is not supported."); } } + @Override protected ByteArrayOutputStream convertFileListToBytes(ArrayList<String> fileList) throws IOException { ByteArrayOutputStream bos = new ByteArrayOutputStream(); for (int i = 0; i < fileList.size(); i++)
*** 211,220 **** --- 218,228 ---- /** * Translates either a byte array or an input stream which contain * platform-specific image data in the given format into an Image. */ + @Override protected Image platformImageBytesToImage( byte[] bytes, long format) throws IOException { String mimeType = null; if (format == PNG_ATOM.getAtom()) {
*** 315,326 **** if (nat == null) { return flavors; } ! DataFlavor df = null; ! try { df = new DataFlavor(nat); } catch (Exception e) { // The string doesn't constitute a valid MIME type. return flavors; --- 323,333 ---- if (nat == null) { return flavors; } ! DataFlavor df; try { df = new DataFlavor(nat); } catch (Exception e) { // The string doesn't constitute a valid MIME type. return flavors;
*** 381,391 **** String charset = df.getParameter("charset"); String baseType = df.getPrimaryType() + "/" + df.getSubType(); String mimeType = baseType; ! if (charset != null && DataTransferer.isFlavorCharsetTextType(df)) { mimeType += ";charset=" + charset; } // Add a mapping to the MIME native whenever the representation class // doesn't require translation. --- 388,398 ---- String charset = df.getParameter("charset"); String baseType = df.getPrimaryType() + "/" + df.getSubType(); String mimeType = baseType; ! if (charset != null && DataFlavorUtil.isFlavorCharsetTextType(df)) { mimeType += ";charset=" + charset; } // Add a mapping to the MIME native whenever the representation class // doesn't require translation.
*** 411,428 **** break; } } } } ! } else if (DataTransferer.isFlavorCharsetTextType(df)) { // stringFlavor is semantically equivalent to the standard // "text/plain" MIME type. if (DataFlavor.stringFlavor.equals(df)) { baseType = "text/plain"; } ! for (String encoding : DataTransferer.standardEncodings()) { if (!encoding.equals(charset)) { natives.add(baseType + ";charset=" + encoding); } } --- 418,435 ---- break; } } } } ! } else if (DataFlavorUtil.isFlavorCharsetTextType(df)) { // stringFlavor is semantically equivalent to the standard // "text/plain" MIME type. if (DataFlavor.stringFlavor.equals(df)) { baseType = "text/plain"; } ! for (String encoding : DataFlavorUtil.standardEncodings()) { if (!encoding.equals(charset)) { natives.add(baseType + ";charset=" + encoding); } }