src/share/classes/sun/awt/datatransfer/DataTransferer.java

Print this page




  53 import java.net.URISyntaxException;
  54 
  55 import java.nio.ByteBuffer;
  56 import java.nio.CharBuffer;
  57 import java.nio.charset.Charset;
  58 import java.nio.charset.CharsetEncoder;
  59 import java.nio.charset.IllegalCharsetNameException;
  60 import java.nio.charset.UnsupportedCharsetException;
  61 
  62 import java.lang.reflect.Constructor;
  63 import java.lang.reflect.InvocationTargetException;
  64 import java.lang.reflect.Method;
  65 import java.lang.reflect.Modifier;
  66 
  67 import java.security.AccessController;
  68 import java.security.PrivilegedAction;
  69 import java.security.PrivilegedActionException;
  70 import java.security.PrivilegedExceptionAction;
  71 import java.security.ProtectionDomain;
  72 
  73 import java.util.AbstractMap;
  74 import java.util.ArrayList;
  75 import java.util.Arrays;
  76 import java.util.Collections;
  77 import java.util.Comparator;
  78 import java.util.HashMap;
  79 import java.util.HashSet;
  80 import java.util.Iterator;
  81 import java.util.List;
  82 import java.util.Map;
  83 import java.util.SortedMap;
  84 import java.util.SortedSet;
  85 import java.util.Set;
  86 import java.util.Stack;
  87 import java.util.TreeMap;
  88 import java.util.TreeSet;
  89 
  90 import sun.util.logging.PlatformLogger;
  91 
  92 import sun.awt.AppContext;
  93 import sun.awt.SunToolkit;
  94 
  95 import java.awt.image.BufferedImage;
  96 import java.awt.image.ImageObserver;
  97 import java.awt.image.RenderedImage;
  98 import java.awt.image.WritableRaster;
  99 import java.awt.image.ColorModel;
 100 
 101 import javax.imageio.ImageIO;
 102 import javax.imageio.ImageReader;
 103 import javax.imageio.ImageReadParam;
 104 import javax.imageio.ImageWriter;
 105 import javax.imageio.ImageTypeSpecifier;
 106 
 107 import javax.imageio.spi.ImageWriterSpi;
 108 


2250     protected static byte[] inputStreamToByteArray(InputStream str)
2251         throws IOException
2252     {
2253         try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
2254             int len = 0;
2255             byte[] buf = new byte[8192];
2256 
2257             while ((len = str.read(buf)) != -1) {
2258                 baos.write(buf, 0, len);
2259             }
2260 
2261             return baos.toByteArray();
2262         }
2263     }
2264 
2265     /**
2266      * Returns platform-specific mappings for the specified native.
2267      * If there are no platform-specific mappings for this native, the method
2268      * returns an empty <code>List</code>.
2269      */
2270     public List<DataFlavor> getPlatformMappingsForNative(String nat) {
2271         return new ArrayList<>();
2272     }
2273 
2274     /**
2275      * Returns platform-specific mappings for the specified flavor.
2276      * If there are no platform-specific mappings for this flavor, the method
2277      * returns an empty <code>List</code>.
2278      */
2279     public List<String> getPlatformMappingsForFlavor(DataFlavor df) {
2280         return new ArrayList<>();
2281     }
2282 
2283     /**
2284      * A Comparator which includes a helper function for comparing two Objects
2285      * which are likely to be keys in the specified Map.
2286      */
2287     public abstract static class IndexedComparator<T> implements Comparator<T> {
2288 
2289         /**
2290          * The best Object (e.g., DataFlavor) will be the last in sequence.
2291          */
2292         public static final boolean SELECT_BEST = true;
2293 
2294         /**
2295          * The best Object (e.g., DataFlavor) will be the first in sequence.
2296          */
2297         public static final boolean SELECT_WORST = false;
2298 
2299         final boolean order;
2300 




  53 import java.net.URISyntaxException;
  54 
  55 import java.nio.ByteBuffer;
  56 import java.nio.CharBuffer;
  57 import java.nio.charset.Charset;
  58 import java.nio.charset.CharsetEncoder;
  59 import java.nio.charset.IllegalCharsetNameException;
  60 import java.nio.charset.UnsupportedCharsetException;
  61 
  62 import java.lang.reflect.Constructor;
  63 import java.lang.reflect.InvocationTargetException;
  64 import java.lang.reflect.Method;
  65 import java.lang.reflect.Modifier;
  66 
  67 import java.security.AccessController;
  68 import java.security.PrivilegedAction;
  69 import java.security.PrivilegedActionException;
  70 import java.security.PrivilegedExceptionAction;
  71 import java.security.ProtectionDomain;
  72 
  73 import java.util.*;















  74 
  75 import sun.util.logging.PlatformLogger;
  76 
  77 import sun.awt.AppContext;
  78 import sun.awt.SunToolkit;
  79 
  80 import java.awt.image.BufferedImage;
  81 import java.awt.image.ImageObserver;
  82 import java.awt.image.RenderedImage;
  83 import java.awt.image.WritableRaster;
  84 import java.awt.image.ColorModel;
  85 
  86 import javax.imageio.ImageIO;
  87 import javax.imageio.ImageReader;
  88 import javax.imageio.ImageReadParam;
  89 import javax.imageio.ImageWriter;
  90 import javax.imageio.ImageTypeSpecifier;
  91 
  92 import javax.imageio.spi.ImageWriterSpi;
  93 


2235     protected static byte[] inputStreamToByteArray(InputStream str)
2236         throws IOException
2237     {
2238         try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
2239             int len = 0;
2240             byte[] buf = new byte[8192];
2241 
2242             while ((len = str.read(buf)) != -1) {
2243                 baos.write(buf, 0, len);
2244             }
2245 
2246             return baos.toByteArray();
2247         }
2248     }
2249 
2250     /**
2251      * Returns platform-specific mappings for the specified native.
2252      * If there are no platform-specific mappings for this native, the method
2253      * returns an empty <code>List</code>.
2254      */
2255     public LinkedHashSet<DataFlavor> getPlatformMappingsForNative(String nat) {
2256         return new LinkedHashSet<>();
2257     }
2258 
2259     /**
2260      * Returns platform-specific mappings for the specified flavor.
2261      * If there are no platform-specific mappings for this flavor, the method
2262      * returns an empty <code>List</code>.
2263      */
2264     public LinkedHashSet<String> getPlatformMappingsForFlavor(DataFlavor df) {
2265         return new LinkedHashSet<>();
2266     }
2267 
2268     /**
2269      * A Comparator which includes a helper function for comparing two Objects
2270      * which are likely to be keys in the specified Map.
2271      */
2272     public abstract static class IndexedComparator<T> implements Comparator<T> {
2273 
2274         /**
2275          * The best Object (e.g., DataFlavor) will be the last in sequence.
2276          */
2277         public static final boolean SELECT_BEST = true;
2278 
2279         /**
2280          * The best Object (e.g., DataFlavor) will be the first in sequence.
2281          */
2282         public static final boolean SELECT_WORST = false;
2283 
2284         final boolean order;
2285