/** * 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. * * @param formats the data formats * @param map the FlavorTable which contains mappings between * DataFlavors and data formats * @throws NullPointerException if formats or map is {@code null} */ public Set<DataFlavor> getFlavorsForFormatsAsSet(long[] formats, FlavorTable map) { Set<DataFlavor> flavorSet = new HashSet<>(formats.length); for (long format : formats) { List<DataFlavor> flavors = map.getFlavorsForNative(getNativeForFormat(format)); for (DataFlavor flavor : flavors) { // Don't explicitly test for String, since it is just a special // case of Serializable if (flavor.isFlavorTextType() || flavor.isFlavorJavaFileListType() || DataFlavor.imageFlavor.equals(flavor) || flavor.isRepresentationClassSerializable() || flavor.isRepresentationClassInputStream() || flavor.isRepresentationClassRemote()) { flavorSet.add(flavor); } } } return flavorSet; }
/** * 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. * <p> * The map keys are sorted according to the native formats preference * order. */ public SortedMap<Long,DataFlavor> getFormatsForTransferable( Transferable contents, FlavorTable map) { DataFlavor[] flavors = contents.getTransferDataFlavors(); if (flavors == null) { return new TreeMap(); } return getFormatsForFlavors(flavors, 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. * * @param formats the data formats * @param map the FlavorTable which contains mappings between * DataFlavors and data formats * @throws NullPointerException if formats or map is <code>null</code> */ public Set getFlavorsForFormatsAsSet(long[] formats, FlavorTable map) { Set flavorSet = new HashSet(formats.length); for (int i = 0; i < formats.length; i++) { String nat = getNativeForFormat(formats[i]); List flavors = map.getFlavorsForNative(nat); for (Iterator iter = flavors.iterator(); iter.hasNext(); ) { DataFlavor flavor = (DataFlavor)iter.next(); // Don't explicitly test for String, since it is just a special // case of Serializable if (flavor.isFlavorTextType() || flavor.isFlavorJavaFileListType() || DataFlavor.imageFlavor.equals(flavor) || flavor.isRepresentationClassSerializable() || flavor.isRepresentationClassInputStream() || flavor.isRepresentationClassRemote()) { flavorSet.add(flavor); } } } return flavorSet; }
@Override public SortedMap <Long, DataFlavor> getFormatsForFlavors( DataFlavor[] flavors, FlavorTable map) { SortedMap <Long, DataFlavor> retval = super.getFormatsForFlavors(flavors, map); // The Win32 native code does not support exporting LOCALE data, nor // should it. retval.remove(L_CF_LOCALE); return retval; }
public SortedMap getFormatsForFlavors(DataFlavor[] flavors, FlavorTable map) { SortedMap retval = super.getFormatsForFlavors(flavors, map); // The Win32 native code does not support exporting LOCALE data, nor // should it. retval.remove(L_CF_LOCALE); return retval; }
static public DataFlavor getByteDataFlavorForNative(String[] nats) { FlavorTable flavorTable = (FlavorTable) SystemFlavorMap.getDefaultFlavorMap(); for (String nat : nats) { java.util.List<DataFlavor> flavors = flavorTable.getFlavorsForNative(nat); for (DataFlavor flavor : flavors) { if (flavor != null && flavor.getRepresentationClass().equals(byte[].class)) { return flavor; } } } throw new RuntimeException("No data flavor was found for natives: " + Arrays.toString(nats)); }
/** * 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. * <p> * The map keys are sorted according to the native formats preference * order. */ public SortedMap<Long,DataFlavor> getFormatsForTransferable(Transferable contents, FlavorTable map) { DataFlavor[] flavors = contents.getTransferDataFlavors(); if (flavors == null) { return Collections.emptySortedMap(); } return getFormatsForFlavors(flavors, map); }
public SortedMap <Long, DataFlavor> getFormatsForFlavors( DataFlavor[] flavors, FlavorTable map) { SortedMap <Long, DataFlavor> retval = super.getFormatsForFlavors(flavors, map); // The Win32 native code does not support exporting LOCALE data, nor // should it. retval.remove(L_CF_LOCALE); return retval; }