src/share/classes/java/awt/datatransfer/SystemFlavorMap.java

Print this page

        

*** 68,78 **** private static String JavaMIME = "JAVA_DATAFLAVOR:"; /** * System singleton which maps a thread's ClassLoader to a SystemFlavorMap. */ ! private static final WeakHashMap flavorMaps = new WeakHashMap(); /** * Copied from java.util.Properties. */ private static final String keyValueSeparators = "=: \t\r\n\f"; --- 68,78 ---- private static String JavaMIME = "JAVA_DATAFLAVOR:"; /** * System singleton which maps a thread's ClassLoader to a SystemFlavorMap. */ ! private static final WeakHashMap<ClassLoader, FlavorMap> flavorMaps = new WeakHashMap<>(); /** * Copied from java.util.Properties. */ private static final String keyValueSeparators = "=: \t\r\n\f";
*** 137,156 **** /** * Maps DataFlavors (or base type Strings for text DataFlavors) to Lists of * native Strings. * Do not use the field directly, use getFlavorToNative() instead. */ ! private final Map flavorToNative = new HashMap(); /** * Accessor to flavorToNative map. Since we use lazy initialization we must * use this accessor instead of direct access to the field which may not be * initialized yet. This method will initialize the field if needed. * * @return flavorToNative */ ! private synchronized Map getFlavorToNative() { if (!isMapInitialized) { initSystemFlavorMap(); } return flavorToNative; } --- 137,156 ---- /** * Maps DataFlavors (or base type Strings for text DataFlavors) to Lists of * native Strings. * Do not use the field directly, use getFlavorToNative() instead. */ ! private final Map<DataFlavor, List<String>> flavorToNative = new HashMap<>(); /** * Accessor to flavorToNative map. Since we use lazy initialization we must * use this accessor instead of direct access to the field which may not be * initialized yet. This method will initialize the field if needed. * * @return flavorToNative */ ! private synchronized Map<DataFlavor, List<String>> getFlavorToNative() { if (!isMapInitialized) { initSystemFlavorMap(); } return flavorToNative; }
*** 162,178 **** /** * Caches the result of getNativesForFlavor(). Maps DataFlavors to * SoftReferences which reference Lists of String natives. */ ! private Map getNativesForFlavorCache = new HashMap(); /** * Caches the result getFlavorsForNative(). Maps String natives to * SoftReferences which reference Lists of DataFlavors. */ ! private Map getFlavorsForNativeCache = new HashMap(); /** * Dynamic mapping generation used for text mappings should not be applied * to the DataFlavors and String natives for which the mappings have been * explicitly specified with setFlavorsForNative() or --- 162,178 ---- /** * Caches the result of getNativesForFlavor(). Maps DataFlavors to * SoftReferences which reference Lists of String natives. */ ! private Map<DataFlavor, SoftReference<List<String>>> getNativesForFlavorCache = new HashMap<>(); /** * Caches the result getFlavorsForNative(). Maps String natives to * SoftReferences which reference Lists of DataFlavors. */ ! private Map<String, SoftReference<List<DataFlavor>>> getFlavorsForNativeCache = new HashMap<>(); /** * Dynamic mapping generation used for text mappings should not be applied * to the DataFlavors and String natives for which the mappings have been * explicitly specified with setFlavorsForNative() or
*** 191,201 **** } FlavorMap fm; synchronized(flavorMaps) { ! fm = (FlavorMap)flavorMaps.get(contextClassLoader); if (fm == null) { fm = new SystemFlavorMap(); flavorMaps.put(contextClassLoader, fm); } } --- 191,201 ---- } FlavorMap fm; synchronized(flavorMaps) { ! fm = flavorMaps.get(contextClassLoader); if (fm == null) { fm = new SystemFlavorMap(); flavorMaps.put(contextClassLoader, fm); } }
*** 518,531 **** * Stores the listed object under the specified hash key in map. Unlike a * standard map, the listed object will not replace any object already at * the appropriate Map location, but rather will be appended to a List * stored in that location. */ ! private void store(Object hashed, Object listed, Map map) { ! List list = (List)map.get(hashed); if (list == null) { ! list = new ArrayList(1); map.put(hashed, list); } if (!list.contains(listed)) { list.add(listed); } --- 518,531 ---- * Stores the listed object under the specified hash key in map. Unlike a * standard map, the listed object will not replace any object already at * the appropriate Map location, but rather will be appended to a List * stored in that location. */ ! private <H, L> void store(H hashed, L listed, Map<H, List<L>> map) { ! List<L> list = map.get(hashed); if (list == null) { ! list = new ArrayList<>(1); map.put(hashed, list); } if (!list.contains(listed)) { list.add(listed); }
*** 535,555 **** * Semantically equivalent to 'nativeToFlavor.get(nat)'. This method * handles the case where 'nat' is not found in 'nativeToFlavor'. In that * case, a new DataFlavor is synthesized, stored, and returned, if and * only if the specified native is encoded as a Java MIME type. */ ! private List nativeToFlavorLookup(String nat) { List<DataFlavor> flavors = getNativeToFlavor().get(nat); if (nat != null && !disabledMappingGenerationKeys.contains(nat)) { DataTransferer transferer = DataTransferer.getInstance(); if (transferer != null) { ! List platformFlavors = transferer.getPlatformMappingsForNative(nat); if (!platformFlavors.isEmpty()) { if (flavors != null) { ! platformFlavors.removeAll(new HashSet(flavors)); // Prepending the platform-specific mappings ensures // that the flavors added with // addFlavorForUnencodedNative() are at the end of // list. platformFlavors.addAll(flavors); --- 535,555 ---- * Semantically equivalent to 'nativeToFlavor.get(nat)'. This method * handles the case where 'nat' is not found in 'nativeToFlavor'. In that * case, a new DataFlavor is synthesized, stored, and returned, if and * only if the specified native is encoded as a Java MIME type. */ ! private List<DataFlavor> nativeToFlavorLookup(String nat) { List<DataFlavor> flavors = getNativeToFlavor().get(nat); if (nat != null && !disabledMappingGenerationKeys.contains(nat)) { DataTransferer transferer = DataTransferer.getInstance(); if (transferer != null) { ! List<DataFlavor> platformFlavors = transferer.getPlatformMappingsForNative(nat); if (!platformFlavors.isEmpty()) { if (flavors != null) { ! platformFlavors.removeAll(new HashSet<>(flavors)); // Prepending the platform-specific mappings ensures // that the flavors added with // addFlavorForUnencodedNative() are at the end of // list. platformFlavors.addAll(flavors);
*** 571,620 **** "\"while constructing DataFlavor for: " + decoded); } if (flavor != null) { ! flavors = new ArrayList(1); getNativeToFlavor().put(nat, flavors); flavors.add(flavor); getFlavorsForNativeCache.remove(nat); getFlavorsForNativeCache.remove(null); ! List natives = (List)getFlavorToNative().get(flavor); if (natives == null) { ! natives = new ArrayList(1); getFlavorToNative().put(flavor, natives); } natives.add(nat); getNativesForFlavorCache.remove(flavor); getNativesForFlavorCache.remove(null); } } ! return (flavors != null) ? flavors : new ArrayList(0); } /** * Semantically equivalent to 'flavorToNative.get(flav)'. This method * handles the case where 'flav' is not found in 'flavorToNative' depending * on the value of passes 'synthesize' parameter. If 'synthesize' is * SYNTHESIZE_IF_NOT_FOUND a native is synthesized, stored, and returned by * encoding the DataFlavor's MIME type. Otherwise an empty List is returned * and 'flavorToNative' remains unaffected. */ ! private List flavorToNativeLookup(final DataFlavor flav, final boolean synthesize) { ! List natives = (List)getFlavorToNative().get(flav); if (flav != null && !disabledMappingGenerationKeys.contains(flav)) { DataTransferer transferer = DataTransferer.getInstance(); if (transferer != null) { ! List platformNatives = transferer.getPlatformMappingsForFlavor(flav); if (!platformNatives.isEmpty()) { if (natives != null) { ! platformNatives.removeAll(new HashSet(natives)); // Prepend the platform-specific mappings to ensure // that the natives added with // addUnencodedNativeForFlavor() are at the end of // list. platformNatives.addAll(natives); --- 571,620 ---- "\"while constructing DataFlavor for: " + decoded); } if (flavor != null) { ! flavors = new ArrayList<>(1); getNativeToFlavor().put(nat, flavors); flavors.add(flavor); getFlavorsForNativeCache.remove(nat); getFlavorsForNativeCache.remove(null); ! List<String> natives = getFlavorToNative().get(flavor); if (natives == null) { ! natives = new ArrayList<>(1); getFlavorToNative().put(flavor, natives); } natives.add(nat); getNativesForFlavorCache.remove(flavor); getNativesForFlavorCache.remove(null); } } ! return (flavors != null) ? flavors : new ArrayList<>(0); } /** * Semantically equivalent to 'flavorToNative.get(flav)'. This method * handles the case where 'flav' is not found in 'flavorToNative' depending * on the value of passes 'synthesize' parameter. If 'synthesize' is * SYNTHESIZE_IF_NOT_FOUND a native is synthesized, stored, and returned by * encoding the DataFlavor's MIME type. Otherwise an empty List is returned * and 'flavorToNative' remains unaffected. */ ! private List<String> flavorToNativeLookup(final DataFlavor flav, final boolean synthesize) { ! List<String> natives = getFlavorToNative().get(flav); if (flav != null && !disabledMappingGenerationKeys.contains(flav)) { DataTransferer transferer = DataTransferer.getInstance(); if (transferer != null) { ! List<String> platformNatives = transferer.getPlatformMappingsForFlavor(flav); if (!platformNatives.isEmpty()) { if (natives != null) { ! platformNatives.removeAll(new HashSet<>(natives)); // Prepend the platform-specific mappings to ensure // that the natives added with // addUnencodedNativeForFlavor() are at the end of // list. platformNatives.addAll(natives);
*** 625,650 **** } if (natives == null) { if (synthesize) { String encoded = encodeDataFlavor(flav); ! natives = new ArrayList(1); getFlavorToNative().put(flav, natives); natives.add(encoded); getNativesForFlavorCache.remove(flav); getNativesForFlavorCache.remove(null); List<DataFlavor> flavors = getNativeToFlavor().get(encoded); if (flavors == null) { ! flavors = new ArrayList(1); getNativeToFlavor().put(encoded, flavors); } flavors.add(flav); getFlavorsForNativeCache.remove(encoded); getFlavorsForNativeCache.remove(null); } else { ! natives = new ArrayList(0); } } return natives; } --- 625,650 ---- } if (natives == null) { if (synthesize) { String encoded = encodeDataFlavor(flav); ! natives = new ArrayList<>(1); getFlavorToNative().put(flav, natives); natives.add(encoded); getNativesForFlavorCache.remove(flav); getNativesForFlavorCache.remove(null); List<DataFlavor> flavors = getNativeToFlavor().get(encoded); if (flavors == null) { ! flavors = new ArrayList<>(1); getNativeToFlavor().put(encoded, flavors); } flavors.add(flav); getFlavorsForNativeCache.remove(encoded); getFlavorsForNativeCache.remove(null); } else { ! natives = new ArrayList<>(0); } } return natives; }
*** 673,723 **** * * @see #encodeDataFlavor * @since 1.4 */ public synchronized List<String> getNativesForFlavor(DataFlavor flav) { ! List retval = null; // Check cache, even for null flav ! SoftReference ref = (SoftReference)getNativesForFlavorCache.get(flav); if (ref != null) { ! retval = (List)ref.get(); if (retval != null) { // Create a copy, because client code can modify the returned // list. ! return new ArrayList(retval); } } if (flav == null) { ! retval = new ArrayList<String>(getNativeToFlavor().keySet()); } else if (disabledMappingGenerationKeys.contains(flav)) { // In this case we shouldn't synthesize a native for this flavor, // since its mappings were explicitly specified. retval = flavorToNativeLookup(flav, !SYNTHESIZE_IF_NOT_FOUND); } else if (DataTransferer.isFlavorCharsetTextType(flav)) { // For text/* flavors, flavor-to-native mappings specified in // flavormap.properties are stored per flavor's base type. if ("text".equals(flav.getPrimaryType())) { ! retval = (List)getFlavorToNative().get(flav.mimeType.getBaseType()); if (retval != null) { // To prevent the List stored in the map from modification. retval = new ArrayList(retval); } } // Also include text/plain natives, but don't duplicate Strings ! List textPlainList = (List)getFlavorToNative().get(TEXT_PLAIN_BASE_TYPE); if (textPlainList != null && !textPlainList.isEmpty()) { // To prevent the List stored in the map from modification. // This also guarantees that removeAll() is supported. ! textPlainList = new ArrayList(textPlainList); if (retval != null && !retval.isEmpty()) { // Use HashSet to get constant-time performance for search. ! textPlainList.removeAll(new HashSet(retval)); retval.addAll(textPlainList); } else { retval = textPlainList; } } --- 673,723 ---- * * @see #encodeDataFlavor * @since 1.4 */ public synchronized List<String> getNativesForFlavor(DataFlavor flav) { ! List<String> retval = null; // Check cache, even for null flav ! SoftReference<List<String>> ref = getNativesForFlavorCache.get(flav); if (ref != null) { ! retval = ref.get(); if (retval != null) { // Create a copy, because client code can modify the returned // list. ! return new ArrayList<>(retval); } } if (flav == null) { ! retval = new ArrayList<>(getNativeToFlavor().keySet()); } else if (disabledMappingGenerationKeys.contains(flav)) { // In this case we shouldn't synthesize a native for this flavor, // since its mappings were explicitly specified. retval = flavorToNativeLookup(flav, !SYNTHESIZE_IF_NOT_FOUND); } else if (DataTransferer.isFlavorCharsetTextType(flav)) { // For text/* flavors, flavor-to-native mappings specified in // flavormap.properties are stored per flavor's base type. if ("text".equals(flav.getPrimaryType())) { ! retval = getAllNativesForType(flav.mimeType.getBaseType()); if (retval != null) { // To prevent the List stored in the map from modification. retval = new ArrayList(retval); } } // Also include text/plain natives, but don't duplicate Strings ! List<String> textPlainList = getAllNativesForType(TEXT_PLAIN_BASE_TYPE); if (textPlainList != null && !textPlainList.isEmpty()) { // To prevent the List stored in the map from modification. // This also guarantees that removeAll() is supported. ! textPlainList = new ArrayList<>(textPlainList); if (retval != null && !retval.isEmpty()) { // Use HashSet to get constant-time performance for search. ! textPlainList.removeAll(new HashSet<>(retval)); retval.addAll(textPlainList); } else { retval = textPlainList; } }
*** 726,780 **** retval = flavorToNativeLookup(flav, SYNTHESIZE_IF_NOT_FOUND); } else { // In this branch it is guaranteed that natives explicitly // listed for flav's MIME type were added with // addUnencodedNativeForFlavor(), so they have lower priority. ! List explicitList = flavorToNativeLookup(flav, !SYNTHESIZE_IF_NOT_FOUND); // flavorToNativeLookup() never returns null. // It can return an empty List, however. if (!explicitList.isEmpty()) { // To prevent the List stored in the map from modification. // This also guarantees that removeAll() is supported. ! explicitList = new ArrayList(explicitList); // Use HashSet to get constant-time performance for search. ! explicitList.removeAll(new HashSet(retval)); retval.addAll(explicitList); } } } else if (DataTransferer.isFlavorNoncharsetTextType(flav)) { ! retval = (List)getFlavorToNative().get(flav.mimeType.getBaseType()); if (retval == null || retval.isEmpty()) { retval = flavorToNativeLookup(flav, SYNTHESIZE_IF_NOT_FOUND); } else { // In this branch it is guaranteed that natives explicitly // listed for flav's MIME type were added with // addUnencodedNativeForFlavor(), so they have lower priority. ! List explicitList = flavorToNativeLookup(flav, !SYNTHESIZE_IF_NOT_FOUND); // flavorToNativeLookup() never returns null. // It can return an empty List, however. if (!explicitList.isEmpty()) { // To prevent the List stored in the map from modification. // This also guarantees that add/removeAll() are supported. ! retval = new ArrayList(retval); ! explicitList = new ArrayList(explicitList); // Use HashSet to get constant-time performance for search. ! explicitList.removeAll(new HashSet(retval)); retval.addAll(explicitList); } } } else { retval = flavorToNativeLookup(flav, SYNTHESIZE_IF_NOT_FOUND); } ! getNativesForFlavorCache.put(flav, new SoftReference(retval)); // Create a copy, because client code can modify the returned list. ! return new ArrayList(retval); } /** * Returns a <code>List</code> of <code>DataFlavor</code>s to which the * specified <code>String</code> native can be translated by the data --- 726,780 ---- retval = flavorToNativeLookup(flav, SYNTHESIZE_IF_NOT_FOUND); } else { // In this branch it is guaranteed that natives explicitly // listed for flav's MIME type were added with // addUnencodedNativeForFlavor(), so they have lower priority. ! List<String> explicitList = flavorToNativeLookup(flav, !SYNTHESIZE_IF_NOT_FOUND); // flavorToNativeLookup() never returns null. // It can return an empty List, however. if (!explicitList.isEmpty()) { // To prevent the List stored in the map from modification. // This also guarantees that removeAll() is supported. ! explicitList = new ArrayList<>(explicitList); // Use HashSet to get constant-time performance for search. ! explicitList.removeAll(new HashSet<>(retval)); retval.addAll(explicitList); } } } else if (DataTransferer.isFlavorNoncharsetTextType(flav)) { ! retval = getAllNativesForType(flav.mimeType.getBaseType()); if (retval == null || retval.isEmpty()) { retval = flavorToNativeLookup(flav, SYNTHESIZE_IF_NOT_FOUND); } else { // In this branch it is guaranteed that natives explicitly // listed for flav's MIME type were added with // addUnencodedNativeForFlavor(), so they have lower priority. ! List<String> explicitList = flavorToNativeLookup(flav, !SYNTHESIZE_IF_NOT_FOUND); // flavorToNativeLookup() never returns null. // It can return an empty List, however. if (!explicitList.isEmpty()) { // To prevent the List stored in the map from modification. // This also guarantees that add/removeAll() are supported. ! retval = new ArrayList<>(retval); ! explicitList = new ArrayList<>(explicitList); // Use HashSet to get constant-time performance for search. ! explicitList.removeAll(new HashSet<>(retval)); retval.addAll(explicitList); } } } else { retval = flavorToNativeLookup(flav, SYNTHESIZE_IF_NOT_FOUND); } ! getNativesForFlavorCache.put(flav, new SoftReference<>(retval)); // Create a copy, because client code can modify the returned list. ! return new ArrayList<>(retval); } /** * Returns a <code>List</code> of <code>DataFlavor</code>s to which the * specified <code>String</code> native can be translated by the data
*** 807,821 **** * @since 1.4 */ public synchronized List<DataFlavor> getFlavorsForNative(String nat) { // Check cache, even for null nat ! SoftReference ref = (SoftReference)getFlavorsForNativeCache.get(nat); if (ref != null) { ! ArrayList retval = (ArrayList)ref.get(); if (retval != null) { ! return (List)retval.clone(); } } final LinkedHashSet <DataFlavor> returnValue = new LinkedHashSet<>(); --- 807,821 ---- * @since 1.4 */ public synchronized List<DataFlavor> getFlavorsForNative(String nat) { // Check cache, even for null nat ! SoftReference<List<DataFlavor>> ref = getFlavorsForNativeCache.get(nat); if (ref != null) { ! List<DataFlavor> retval = ref.get(); if (retval != null) { ! return new ArrayList<>(retval); } } final LinkedHashSet <DataFlavor> returnValue = new LinkedHashSet<>();
*** 857,876 **** } } } ! final ArrayList arrayList = new ArrayList(returnValue); ! getFlavorsForNativeCache.put(nat, new SoftReference(arrayList)); ! return (List)arrayList.clone(); } ! private static LinkedHashSet<DataFlavor> convertMimeTypeToDataFlavors( final String baseType) { ! final LinkedHashSet<DataFlavor> returnValue = ! new LinkedHashSet<DataFlavor>(); String subType = null; try { final MimeType mimeType = new MimeType(baseType); --- 857,875 ---- } } } ! final List<DataFlavor> arrayList = new ArrayList<>(returnValue); ! getFlavorsForNativeCache.put(nat, new SoftReference<>(arrayList)); ! return new ArrayList<>(arrayList); } ! private static Set<DataFlavor> convertMimeTypeToDataFlavors( final String baseType) { ! final Set<DataFlavor> returnValue = new LinkedHashSet<>(); String subType = null; try { final MimeType mimeType = new MimeType(baseType);
*** 1007,1021 **** List flavor_list = getFlavorsForNative(null); flavors = new DataFlavor[flavor_list.size()]; flavor_list.toArray(flavors); } ! HashMap retval = new HashMap(flavors.length, 1.0f); ! for (int i = 0; i < flavors.length; i++) { ! List natives = getNativesForFlavor(flavors[i]); ! String nat = (natives.isEmpty()) ? null : (String)natives.get(0); ! retval.put(flavors[i], nat); } return retval; } --- 1006,1020 ---- List flavor_list = getFlavorsForNative(null); flavors = new DataFlavor[flavor_list.size()]; flavor_list.toArray(flavors); } ! Map<DataFlavor, String> retval = new HashMap<>(flavors.length, 1.0f); ! for (DataFlavor flavor : flavors) { ! List<String> natives = getNativesForFlavor(flavor); ! String nat = (natives.isEmpty()) ? null : natives.get(0); ! retval.put(flavor, nat); } return retval; }
*** 1052,1067 **** List native_list = getNativesForFlavor(null); natives = new String[native_list.size()]; native_list.toArray(natives); } ! HashMap retval = new HashMap(natives.length, 1.0f); ! for (int i = 0; i < natives.length; i++) { ! List flavors = getFlavorsForNative(natives[i]); ! DataFlavor flav = (flavors.isEmpty()) ! ? null : (DataFlavor)flavors.get(0); ! retval.put(natives[i], flav); } return retval; } --- 1051,1065 ---- List native_list = getNativesForFlavor(null); natives = new String[native_list.size()]; native_list.toArray(natives); } ! Map<String, DataFlavor> retval = new HashMap<>(natives.length, 1.0f); ! for (String aNative : natives) { ! List<DataFlavor> flavors = getFlavorsForNative(aNative); ! DataFlavor flav = (flavors.isEmpty())? null : flavors.get(0); ! retval.put(aNative, flav); } return retval; }
*** 1089,1101 **** String nat) { if (flav == null || nat == null) { throw new NullPointerException("null arguments not permitted"); } ! List natives = (List)getFlavorToNative().get(flav); if (natives == null) { ! natives = new ArrayList(1); getFlavorToNative().put(flav, natives); } else if (natives.contains(nat)) { return; } natives.add(nat); --- 1087,1099 ---- String nat) { if (flav == null || nat == null) { throw new NullPointerException("null arguments not permitted"); } ! List<String> natives = getFlavorToNative().get(flav); if (natives == null) { ! natives = new ArrayList<>(1); getFlavorToNative().put(flav, natives); } else if (natives.contains(nat)) { return; } natives.add(nat);
*** 1136,1147 **** if (flav == null || natives == null) { throw new NullPointerException("null arguments not permitted"); } getFlavorToNative().remove(flav); ! for (int i = 0; i < natives.length; i++) { ! addUnencodedNativeForFlavor(flav, natives[i]); } disabledMappingGenerationKeys.add(flav); // Clear the cache to handle the case of empty natives. getNativesForFlavorCache.remove(flav); getNativesForFlavorCache.remove(null); --- 1134,1145 ---- if (flav == null || natives == null) { throw new NullPointerException("null arguments not permitted"); } getFlavorToNative().remove(flav); ! for (String aNative : natives) { ! addUnencodedNativeForFlavor(flav, aNative); } disabledMappingGenerationKeys.add(flav); // Clear the cache to handle the case of empty natives. getNativesForFlavorCache.remove(flav); getNativesForFlavorCache.remove(null);
*** 1169,1181 **** DataFlavor flav) { if (nat == null || flav == null) { throw new NullPointerException("null arguments not permitted"); } ! List flavors = (List)getNativeToFlavor().get(nat); if (flavors == null) { ! flavors = new ArrayList(1); getNativeToFlavor().put(nat, flavors); } else if (flavors.contains(flav)) { return; } flavors.add(flav); --- 1167,1179 ---- DataFlavor flav) { if (nat == null || flav == null) { throw new NullPointerException("null arguments not permitted"); } ! List<DataFlavor> flavors = getNativeToFlavor().get(nat); if (flavors == null) { ! flavors = new ArrayList<>(1); getNativeToFlavor().put(nat, flavors); } else if (flavors.contains(flav)) { return; } flavors.add(flav);
*** 1215,1226 **** if (nat == null || flavors == null) { throw new NullPointerException("null arguments not permitted"); } getNativeToFlavor().remove(nat); ! for (int i = 0; i < flavors.length; i++) { ! addFlavorForUnencodedNative(nat, flavors[i]); } disabledMappingGenerationKeys.add(nat); // Clear the cache to handle the case of empty flavors. getFlavorsForNativeCache.remove(nat); getFlavorsForNativeCache.remove(null); --- 1213,1224 ---- if (nat == null || flavors == null) { throw new NullPointerException("null arguments not permitted"); } getNativeToFlavor().remove(nat); ! for (DataFlavor flavor : flavors) { ! addFlavorForUnencodedNative(nat, flavor); } disabledMappingGenerationKeys.add(nat); // Clear the cache to handle the case of empty flavors. getFlavorsForNativeCache.remove(nat); getFlavorsForNativeCache.remove(null);
*** 1319,1324 **** --- 1317,1336 ---- String retval_str = SystemFlavorMap.decodeJavaMIMEType(nat); return (retval_str != null) ? new DataFlavor(retval_str) : null; } + + private List<String> getAllNativesForType(String type) { + List<String> retval = null; + for (DataFlavor dataFlavor : convertMimeTypeToDataFlavors(type)) { + List<String> natives = getFlavorToNative().get(dataFlavor); + if (!natives.isEmpty()) { + if (retval == null) { + retval = new ArrayList<>(); + } + retval.addAll(natives); + } + } + return retval; + } }