Java Code Examples for java.awt.datatransfer.DataFlavor#isRepresentationClassByteBuffer()
The following examples show how to use
java.awt.datatransfer.DataFlavor#isRepresentationClassByteBuffer() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TransferableDataURL.java From wandora with GNU General Public License v3.0 | 6 votes |
@Override public Object getTransferData( DataFlavor flavor ) throws UnsupportedFlavorException, IOException { if(transferableData != null) { if(flavor.getMimeType().contains(transferableData.getMimetype())) { return transferableData.getData(); } else if(flavor.equals( DataFlavor.stringFlavor )) { return transferableData.toExternalForm(Base64.DONT_BREAK_LINES); } else if(flavor.isRepresentationClassByteBuffer()) { return ByteBuffer.wrap(transferableData.getData()); } else { // Warning, returning dataurl as a string if flavor is not recognized. return transferableData.toExternalForm(Base64.DONT_BREAK_LINES); } } throw new UnsupportedFlavorException( flavor ); }
Example 2
Source File: DataTransferer.java From hottub with GNU General Public License v2.0 | 5 votes |
/** * Returns whether this flavor is a text type which does not support the * 'charset' parameter. */ public static boolean isFlavorNoncharsetTextType(DataFlavor flavor) { if (!"text".equals(flavor.getPrimaryType()) || doesSubtypeSupportCharset(flavor)) { return false; } return (flavor.isRepresentationClassInputStream() || flavor.isRepresentationClassByteBuffer() || byte[].class.equals(flavor.getRepresentationClass())); }
Example 3
Source File: DataFlavorUtil.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Returns whether this flavor is a text type which does not support the * 'charset' parameter. */ public static boolean isFlavorNoncharsetTextType(DataFlavor flavor) { if (!"text".equals(flavor.getPrimaryType()) || doesSubtypeSupportCharset(flavor)) { return false; } return (flavor.isRepresentationClassInputStream() || flavor.isRepresentationClassByteBuffer() || byte[].class.equals(flavor.getRepresentationClass())); }
Example 4
Source File: DataTransferer.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
/** * Returns whether this flavor is a text type which does not support the * 'charset' parameter. */ public static boolean isFlavorNoncharsetTextType(DataFlavor flavor) { if (!"text".equals(flavor.getPrimaryType()) || doesSubtypeSupportCharset(flavor)) { return false; } return (flavor.isRepresentationClassInputStream() || flavor.isRepresentationClassByteBuffer() || byte[].class.equals(flavor.getRepresentationClass())); }
Example 5
Source File: DataFlavorUtil.java From Bytecoder with Apache License 2.0 | 5 votes |
/** * Returns whether this flavor is a text type which does not support the * 'charset' parameter. */ public static boolean isFlavorNoncharsetTextType(DataFlavor flavor) { if (!"text".equals(flavor.getPrimaryType()) || doesSubtypeSupportCharset(flavor)) { return false; } return (flavor.isRepresentationClassInputStream() || flavor.isRepresentationClassByteBuffer() || byte[].class.equals(flavor.getRepresentationClass())); }
Example 6
Source File: DataFlavorUtil.java From Bytecoder with Apache License 2.0 | 5 votes |
/** * Returns whether this flavor is a text type which supports the 'charset' * parameter. */ public static boolean isFlavorCharsetTextType(DataFlavor flavor) { // Although stringFlavor doesn't actually support the charset // parameter (because its primary MIME type is not "text"), it should // be treated as though it does. stringFlavor is semantically // equivalent to "text/plain" data. if (DataFlavor.stringFlavor.equals(flavor)) { return true; } if (!"text".equals(flavor.getPrimaryType()) || !doesSubtypeSupportCharset(flavor)) { return false; } Class<?> rep_class = flavor.getRepresentationClass(); if (flavor.isRepresentationClassReader() || String.class.equals(rep_class) || flavor.isRepresentationClassCharBuffer() || char[].class.equals(rep_class)) { return true; } if (!(flavor.isRepresentationClassInputStream() || flavor.isRepresentationClassByteBuffer() || byte[].class.equals(rep_class))) { return false; } String charset = flavor.getParameter("charset"); // null equals default encoding which is always supported return (charset == null) || isEncodingSupported(charset); }
Example 7
Source File: DataTransferer.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
/** * Returns whether this flavor is a text type which supports the * 'charset' parameter. */ public static boolean isFlavorCharsetTextType(DataFlavor flavor) { // Although stringFlavor doesn't actually support the charset // parameter (because its primary MIME type is not "text"), it should // be treated as though it does. stringFlavor is semantically // equivalent to "text/plain" data. if (DataFlavor.stringFlavor.equals(flavor)) { return true; } if (!"text".equals(flavor.getPrimaryType()) || !doesSubtypeSupportCharset(flavor)) { return false; } Class rep_class = flavor.getRepresentationClass(); if (flavor.isRepresentationClassReader() || String.class.equals(rep_class) || flavor.isRepresentationClassCharBuffer() || char[].class.equals(rep_class)) { return true; } if (!(flavor.isRepresentationClassInputStream() || flavor.isRepresentationClassByteBuffer() || byte[].class.equals(rep_class))) { return false; } String charset = flavor.getParameter("charset"); return (charset != null) ? DataTransferer.isEncodingSupported(charset) : true; // null equals default encoding which is always supported }
Example 8
Source File: DataTransferer.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * Returns whether this flavor is a text type which supports the * 'charset' parameter. */ public static boolean isFlavorCharsetTextType(DataFlavor flavor) { // Although stringFlavor doesn't actually support the charset // parameter (because its primary MIME type is not "text"), it should // be treated as though it does. stringFlavor is semantically // equivalent to "text/plain" data. if (DataFlavor.stringFlavor.equals(flavor)) { return true; } if (!"text".equals(flavor.getPrimaryType()) || !doesSubtypeSupportCharset(flavor)) { return false; } Class rep_class = flavor.getRepresentationClass(); if (flavor.isRepresentationClassReader() || String.class.equals(rep_class) || flavor.isRepresentationClassCharBuffer() || char[].class.equals(rep_class)) { return true; } if (!(flavor.isRepresentationClassInputStream() || flavor.isRepresentationClassByteBuffer() || byte[].class.equals(rep_class))) { return false; } String charset = flavor.getParameter("charset"); return (charset != null) ? DataTransferer.isEncodingSupported(charset) : true; // null equals default encoding which is always supported }
Example 9
Source File: DataTransferer.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * Returns whether this flavor is a text type which does not support the * 'charset' parameter. */ public static boolean isFlavorNoncharsetTextType(DataFlavor flavor) { if (!"text".equals(flavor.getPrimaryType()) || doesSubtypeSupportCharset(flavor)) { return false; } return (flavor.isRepresentationClassInputStream() || flavor.isRepresentationClassByteBuffer() || byte[].class.equals(flavor.getRepresentationClass())); }
Example 10
Source File: DataTransferer.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * Returns whether this flavor is a text type which supports the * 'charset' parameter. */ public static boolean isFlavorCharsetTextType(DataFlavor flavor) { // Although stringFlavor doesn't actually support the charset // parameter (because its primary MIME type is not "text"), it should // be treated as though it does. stringFlavor is semantically // equivalent to "text/plain" data. if (DataFlavor.stringFlavor.equals(flavor)) { return true; } if (!"text".equals(flavor.getPrimaryType()) || !doesSubtypeSupportCharset(flavor)) { return false; } Class rep_class = flavor.getRepresentationClass(); if (flavor.isRepresentationClassReader() || String.class.equals(rep_class) || flavor.isRepresentationClassCharBuffer() || char[].class.equals(rep_class)) { return true; } if (!(flavor.isRepresentationClassInputStream() || flavor.isRepresentationClassByteBuffer() || byte[].class.equals(rep_class))) { return false; } String charset = flavor.getParameter("charset"); return (charset != null) ? DataTransferer.isEncodingSupported(charset) : true; // null equals default encoding which is always supported }
Example 11
Source File: DataTransferer.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * Returns whether this flavor is a text type which does not support the * 'charset' parameter. */ public static boolean isFlavorNoncharsetTextType(DataFlavor flavor) { if (!"text".equals(flavor.getPrimaryType()) || doesSubtypeSupportCharset(flavor)) { return false; } return (flavor.isRepresentationClassInputStream() || flavor.isRepresentationClassByteBuffer() || byte[].class.equals(flavor.getRepresentationClass())); }
Example 12
Source File: DataTransferer.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
/** * Returns whether this flavor is a text type which does not support the * 'charset' parameter. */ public static boolean isFlavorNoncharsetTextType(DataFlavor flavor) { if (!"text".equals(flavor.getPrimaryType()) || doesSubtypeSupportCharset(flavor)) { return false; } return (flavor.isRepresentationClassInputStream() || flavor.isRepresentationClassByteBuffer() || byte[].class.equals(flavor.getRepresentationClass())); }
Example 13
Source File: DataTransferer.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
/** * Returns whether this flavor is a text type which does not support the * 'charset' parameter. */ public static boolean isFlavorNoncharsetTextType(DataFlavor flavor) { if (!"text".equals(flavor.getPrimaryType()) || doesSubtypeSupportCharset(flavor)) { return false; } return (flavor.isRepresentationClassInputStream() || flavor.isRepresentationClassByteBuffer() || byte[].class.equals(flavor.getRepresentationClass())); }
Example 14
Source File: XDataTransferer.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
public LinkedHashSet<String> getPlatformMappingsForFlavor(DataFlavor df) { LinkedHashSet<String> natives = new LinkedHashSet<>(1); if (df == null) { return natives; } 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. if (df.getRepresentationClass() != null && (df.isRepresentationClassInputStream() || df.isRepresentationClassByteBuffer() || byte[].class.equals(df.getRepresentationClass()))) { natives.add(mimeType); } if (DataFlavor.imageFlavor.equals(df)) { String[] mimeTypes = ImageIO.getWriterMIMETypes(); if (mimeTypes != null) { for (int i = 0; i < mimeTypes.length; i++) { Iterator writers = ImageIO.getImageWritersByMIMEType(mimeTypes[i]); while (writers.hasNext()) { ImageWriter imageWriter = (ImageWriter)writers.next(); ImageWriterSpi writerSpi = imageWriter.getOriginatingProvider(); if (writerSpi != null && writerSpi.canEncodeImage(getDefaultImageTypeSpecifier())) { natives.add(mimeTypes[i]); 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); } } // Add a MIME format without specified charset. if (!natives.contains(baseType)) { natives.add(baseType); } } return natives; }
Example 15
Source File: XDataTransferer.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
public LinkedHashSet<String> getPlatformMappingsForFlavor(DataFlavor df) { LinkedHashSet<String> natives = new LinkedHashSet<>(1); if (df == null) { return natives; } 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. if (df.getRepresentationClass() != null && (df.isRepresentationClassInputStream() || df.isRepresentationClassByteBuffer() || byte[].class.equals(df.getRepresentationClass()))) { natives.add(mimeType); } if (DataFlavor.imageFlavor.equals(df)) { String[] mimeTypes = ImageIO.getWriterMIMETypes(); if (mimeTypes != null) { for (int i = 0; i < mimeTypes.length; i++) { Iterator writers = ImageIO.getImageWritersByMIMEType(mimeTypes[i]); while (writers.hasNext()) { ImageWriter imageWriter = (ImageWriter)writers.next(); ImageWriterSpi writerSpi = imageWriter.getOriginatingProvider(); if (writerSpi != null && writerSpi.canEncodeImage(getDefaultImageTypeSpecifier())) { natives.add(mimeTypes[i]); 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); } } // Add a MIME format without specified charset. if (!natives.contains(baseType)) { natives.add(baseType); } } return natives; }
Example 16
Source File: XDataTransferer.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
public LinkedHashSet<String> getPlatformMappingsForFlavor(DataFlavor df) { LinkedHashSet<String> natives = new LinkedHashSet<>(1); if (df == null) { return natives; } 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. if (df.getRepresentationClass() != null && (df.isRepresentationClassInputStream() || df.isRepresentationClassByteBuffer() || byte[].class.equals(df.getRepresentationClass()))) { natives.add(mimeType); } if (DataFlavor.imageFlavor.equals(df)) { String[] mimeTypes = ImageIO.getWriterMIMETypes(); if (mimeTypes != null) { for (int i = 0; i < mimeTypes.length; i++) { Iterator writers = ImageIO.getImageWritersByMIMEType(mimeTypes[i]); while (writers.hasNext()) { ImageWriter imageWriter = (ImageWriter)writers.next(); ImageWriterSpi writerSpi = imageWriter.getOriginatingProvider(); if (writerSpi != null && writerSpi.canEncodeImage(getDefaultImageTypeSpecifier())) { natives.add(mimeTypes[i]); 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); } } // Add a MIME format without specified charset. if (!natives.contains(baseType)) { natives.add(baseType); } } return natives; }
Example 17
Source File: XDataTransferer.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
public List getPlatformMappingsForFlavor(DataFlavor df) { List natives = new ArrayList(1); if (df == null) { return natives; } 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. if (df.getRepresentationClass() != null && (df.isRepresentationClassInputStream() || df.isRepresentationClassByteBuffer() || byteArrayClass.equals(df.getRepresentationClass()))) { natives.add(mimeType); } if (DataFlavor.imageFlavor.equals(df)) { String[] mimeTypes = ImageIO.getWriterMIMETypes(); if (mimeTypes != null) { for (int i = 0; i < mimeTypes.length; i++) { Iterator writers = ImageIO.getImageWritersByMIMEType(mimeTypes[i]); while (writers.hasNext()) { ImageWriter imageWriter = (ImageWriter)writers.next(); ImageWriterSpi writerSpi = imageWriter.getOriginatingProvider(); if (writerSpi != null && writerSpi.canEncodeImage(getDefaultImageTypeSpecifier())) { natives.add(mimeTypes[i]); 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); } } // Add a MIME format without specified charset. if (!natives.contains(baseType)) { natives.add(baseType); } } return natives; }
Example 18
Source File: XDataTransferer.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
public LinkedHashSet<String> getPlatformMappingsForFlavor(DataFlavor df) { LinkedHashSet<String> natives = new LinkedHashSet<>(1); if (df == null) { return natives; } 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. if (df.getRepresentationClass() != null && (df.isRepresentationClassInputStream() || df.isRepresentationClassByteBuffer() || byte[].class.equals(df.getRepresentationClass()))) { natives.add(mimeType); } if (DataFlavor.imageFlavor.equals(df)) { String[] mimeTypes = ImageIO.getWriterMIMETypes(); if (mimeTypes != null) { for (int i = 0; i < mimeTypes.length; i++) { Iterator writers = ImageIO.getImageWritersByMIMEType(mimeTypes[i]); while (writers.hasNext()) { ImageWriter imageWriter = (ImageWriter)writers.next(); ImageWriterSpi writerSpi = imageWriter.getOriginatingProvider(); if (writerSpi != null && writerSpi.canEncodeImage(getDefaultImageTypeSpecifier())) { natives.add(mimeTypes[i]); 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); } } // Add a MIME format without specified charset. if (!natives.contains(baseType)) { natives.add(baseType); } } return natives; }
Example 19
Source File: XDataTransferer.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
public List getPlatformMappingsForFlavor(DataFlavor df) { List natives = new ArrayList(1); if (df == null) { return natives; } 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. if (df.getRepresentationClass() != null && (df.isRepresentationClassInputStream() || df.isRepresentationClassByteBuffer() || byteArrayClass.equals(df.getRepresentationClass()))) { natives.add(mimeType); } if (DataFlavor.imageFlavor.equals(df)) { String[] mimeTypes = ImageIO.getWriterMIMETypes(); if (mimeTypes != null) { for (int i = 0; i < mimeTypes.length; i++) { Iterator writers = ImageIO.getImageWritersByMIMEType(mimeTypes[i]); while (writers.hasNext()) { ImageWriter imageWriter = (ImageWriter)writers.next(); ImageWriterSpi writerSpi = imageWriter.getOriginatingProvider(); if (writerSpi != null && writerSpi.canEncodeImage(getDefaultImageTypeSpecifier())) { natives.add(mimeTypes[i]); 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); } } // Add a MIME format without specified charset. if (!natives.contains(baseType)) { natives.add(baseType); } } return natives; }
Example 20
Source File: XDataTransferer.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
public LinkedHashSet<String> getPlatformMappingsForFlavor(DataFlavor df) { LinkedHashSet<String> natives = new LinkedHashSet<>(1); if (df == null) { return natives; } 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. if (df.getRepresentationClass() != null && (df.isRepresentationClassInputStream() || df.isRepresentationClassByteBuffer() || byte[].class.equals(df.getRepresentationClass()))) { natives.add(mimeType); } if (DataFlavor.imageFlavor.equals(df)) { String[] mimeTypes = ImageIO.getWriterMIMETypes(); if (mimeTypes != null) { for (int i = 0; i < mimeTypes.length; i++) { Iterator writers = ImageIO.getImageWritersByMIMEType(mimeTypes[i]); while (writers.hasNext()) { ImageWriter imageWriter = (ImageWriter)writers.next(); ImageWriterSpi writerSpi = imageWriter.getOriginatingProvider(); if (writerSpi != null && writerSpi.canEncodeImage(getDefaultImageTypeSpecifier())) { natives.add(mimeTypes[i]); 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); } } // Add a MIME format without specified charset. if (!natives.contains(baseType)) { natives.add(baseType); } } return natives; }