提交 bd51894e 编写于 作者: P pchelko

8024987: Copy/paste regression since JDK8 b86

Reviewed-by: serb, anthony
上级 58bdae91
...@@ -70,7 +70,7 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable { ...@@ -70,7 +70,7 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
/** /**
* System singleton which maps a thread's ClassLoader to a SystemFlavorMap. * System singleton which maps a thread's ClassLoader to a SystemFlavorMap.
*/ */
private static final WeakHashMap flavorMaps = new WeakHashMap(); private static final WeakHashMap<ClassLoader, FlavorMap> flavorMaps = new WeakHashMap<>();
/** /**
* Copied from java.util.Properties. * Copied from java.util.Properties.
...@@ -139,7 +139,7 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable { ...@@ -139,7 +139,7 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
* native Strings. * native Strings.
* Do not use the field directly, use getFlavorToNative() instead. * Do not use the field directly, use getFlavorToNative() instead.
*/ */
private final Map flavorToNative = new HashMap(); private final Map<DataFlavor, List<String>> flavorToNative = new HashMap<>();
/** /**
* Accessor to flavorToNative map. Since we use lazy initialization we must * Accessor to flavorToNative map. Since we use lazy initialization we must
...@@ -148,7 +148,7 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable { ...@@ -148,7 +148,7 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
* *
* @return flavorToNative * @return flavorToNative
*/ */
private synchronized Map getFlavorToNative() { private synchronized Map<DataFlavor, List<String>> getFlavorToNative() {
if (!isMapInitialized) { if (!isMapInitialized) {
initSystemFlavorMap(); initSystemFlavorMap();
} }
...@@ -164,13 +164,13 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable { ...@@ -164,13 +164,13 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
* Caches the result of getNativesForFlavor(). Maps DataFlavors to * Caches the result of getNativesForFlavor(). Maps DataFlavors to
* SoftReferences which reference Lists of String natives. * SoftReferences which reference Lists of String natives.
*/ */
private Map getNativesForFlavorCache = new HashMap(); private Map<DataFlavor, SoftReference<List<String>>> getNativesForFlavorCache = new HashMap<>();
/** /**
* Caches the result getFlavorsForNative(). Maps String natives to * Caches the result getFlavorsForNative(). Maps String natives to
* SoftReferences which reference Lists of DataFlavors. * SoftReferences which reference Lists of DataFlavors.
*/ */
private Map getFlavorsForNativeCache = new HashMap(); private Map<String, SoftReference<List<DataFlavor>>> getFlavorsForNativeCache = new HashMap<>();
/** /**
* Dynamic mapping generation used for text mappings should not be applied * Dynamic mapping generation used for text mappings should not be applied
...@@ -193,7 +193,7 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable { ...@@ -193,7 +193,7 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
FlavorMap fm; FlavorMap fm;
synchronized(flavorMaps) { synchronized(flavorMaps) {
fm = (FlavorMap)flavorMaps.get(contextClassLoader); fm = flavorMaps.get(contextClassLoader);
if (fm == null) { if (fm == null) {
fm = new SystemFlavorMap(); fm = new SystemFlavorMap();
flavorMaps.put(contextClassLoader, fm); flavorMaps.put(contextClassLoader, fm);
...@@ -520,10 +520,10 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable { ...@@ -520,10 +520,10 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
* the appropriate Map location, but rather will be appended to a List * the appropriate Map location, but rather will be appended to a List
* stored in that location. * stored in that location.
*/ */
private void store(Object hashed, Object listed, Map map) { private <H, L> void store(H hashed, L listed, Map<H, List<L>> map) {
List list = (List)map.get(hashed); List<L> list = map.get(hashed);
if (list == null) { if (list == null) {
list = new ArrayList(1); list = new ArrayList<>(1);
map.put(hashed, list); map.put(hashed, list);
} }
if (!list.contains(listed)) { if (!list.contains(listed)) {
...@@ -537,17 +537,17 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable { ...@@ -537,17 +537,17 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
* case, a new DataFlavor is synthesized, stored, and returned, if and * case, a new DataFlavor is synthesized, stored, and returned, if and
* only if the specified native is encoded as a Java MIME type. * only if the specified native is encoded as a Java MIME type.
*/ */
private List nativeToFlavorLookup(String nat) { private List<DataFlavor> nativeToFlavorLookup(String nat) {
List<DataFlavor> flavors = getNativeToFlavor().get(nat); List<DataFlavor> flavors = getNativeToFlavor().get(nat);
if (nat != null && !disabledMappingGenerationKeys.contains(nat)) { if (nat != null && !disabledMappingGenerationKeys.contains(nat)) {
DataTransferer transferer = DataTransferer.getInstance(); DataTransferer transferer = DataTransferer.getInstance();
if (transferer != null) { if (transferer != null) {
List platformFlavors = List<DataFlavor> platformFlavors =
transferer.getPlatformMappingsForNative(nat); transferer.getPlatformMappingsForNative(nat);
if (!platformFlavors.isEmpty()) { if (!platformFlavors.isEmpty()) {
if (flavors != null) { if (flavors != null) {
platformFlavors.removeAll(new HashSet(flavors)); platformFlavors.removeAll(new HashSet<>(flavors));
// Prepending the platform-specific mappings ensures // Prepending the platform-specific mappings ensures
// that the flavors added with // that the flavors added with
// addFlavorForUnencodedNative() are at the end of // addFlavorForUnencodedNative() are at the end of
...@@ -573,15 +573,15 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable { ...@@ -573,15 +573,15 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
} }
if (flavor != null) { if (flavor != null) {
flavors = new ArrayList(1); flavors = new ArrayList<>(1);
getNativeToFlavor().put(nat, flavors); getNativeToFlavor().put(nat, flavors);
flavors.add(flavor); flavors.add(flavor);
getFlavorsForNativeCache.remove(nat); getFlavorsForNativeCache.remove(nat);
getFlavorsForNativeCache.remove(null); getFlavorsForNativeCache.remove(null);
List natives = (List)getFlavorToNative().get(flavor); List<String> natives = getFlavorToNative().get(flavor);
if (natives == null) { if (natives == null) {
natives = new ArrayList(1); natives = new ArrayList<>(1);
getFlavorToNative().put(flavor, natives); getFlavorToNative().put(flavor, natives);
} }
natives.add(nat); natives.add(nat);
...@@ -590,7 +590,7 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable { ...@@ -590,7 +590,7 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
} }
} }
return (flavors != null) ? flavors : new ArrayList(0); return (flavors != null) ? flavors : new ArrayList<>(0);
} }
/** /**
...@@ -601,18 +601,18 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable { ...@@ -601,18 +601,18 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
* encoding the DataFlavor's MIME type. Otherwise an empty List is returned * encoding the DataFlavor's MIME type. Otherwise an empty List is returned
* and 'flavorToNative' remains unaffected. * and 'flavorToNative' remains unaffected.
*/ */
private List flavorToNativeLookup(final DataFlavor flav, private List<String> flavorToNativeLookup(final DataFlavor flav,
final boolean synthesize) { final boolean synthesize) {
List natives = (List)getFlavorToNative().get(flav); List<String> natives = getFlavorToNative().get(flav);
if (flav != null && !disabledMappingGenerationKeys.contains(flav)) { if (flav != null && !disabledMappingGenerationKeys.contains(flav)) {
DataTransferer transferer = DataTransferer.getInstance(); DataTransferer transferer = DataTransferer.getInstance();
if (transferer != null) { if (transferer != null) {
List platformNatives = List<String> platformNatives =
transferer.getPlatformMappingsForFlavor(flav); transferer.getPlatformMappingsForFlavor(flav);
if (!platformNatives.isEmpty()) { if (!platformNatives.isEmpty()) {
if (natives != null) { if (natives != null) {
platformNatives.removeAll(new HashSet(natives)); platformNatives.removeAll(new HashSet<>(natives));
// Prepend the platform-specific mappings to ensure // Prepend the platform-specific mappings to ensure
// that the natives added with // that the natives added with
// addUnencodedNativeForFlavor() are at the end of // addUnencodedNativeForFlavor() are at the end of
...@@ -627,7 +627,7 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable { ...@@ -627,7 +627,7 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
if (natives == null) { if (natives == null) {
if (synthesize) { if (synthesize) {
String encoded = encodeDataFlavor(flav); String encoded = encodeDataFlavor(flav);
natives = new ArrayList(1); natives = new ArrayList<>(1);
getFlavorToNative().put(flav, natives); getFlavorToNative().put(flav, natives);
natives.add(encoded); natives.add(encoded);
getNativesForFlavorCache.remove(flav); getNativesForFlavorCache.remove(flav);
...@@ -635,14 +635,14 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable { ...@@ -635,14 +635,14 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
List<DataFlavor> flavors = getNativeToFlavor().get(encoded); List<DataFlavor> flavors = getNativeToFlavor().get(encoded);
if (flavors == null) { if (flavors == null) {
flavors = new ArrayList(1); flavors = new ArrayList<>(1);
getNativeToFlavor().put(encoded, flavors); getNativeToFlavor().put(encoded, flavors);
} }
flavors.add(flav); flavors.add(flav);
getFlavorsForNativeCache.remove(encoded); getFlavorsForNativeCache.remove(encoded);
getFlavorsForNativeCache.remove(null); getFlavorsForNativeCache.remove(null);
} else { } else {
natives = new ArrayList(0); natives = new ArrayList<>(0);
} }
} }
...@@ -675,21 +675,21 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable { ...@@ -675,21 +675,21 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
* @since 1.4 * @since 1.4
*/ */
public synchronized List<String> getNativesForFlavor(DataFlavor flav) { public synchronized List<String> getNativesForFlavor(DataFlavor flav) {
List retval = null; List<String> retval = null;
// Check cache, even for null flav // Check cache, even for null flav
SoftReference ref = (SoftReference)getNativesForFlavorCache.get(flav); SoftReference<List<String>> ref = getNativesForFlavorCache.get(flav);
if (ref != null) { if (ref != null) {
retval = (List)ref.get(); retval = ref.get();
if (retval != null) { if (retval != null) {
// Create a copy, because client code can modify the returned // Create a copy, because client code can modify the returned
// list. // list.
return new ArrayList(retval); return new ArrayList<>(retval);
} }
} }
if (flav == null) { if (flav == null) {
retval = new ArrayList<String>(getNativeToFlavor().keySet()); retval = new ArrayList<>(getNativeToFlavor().keySet());
} else if (disabledMappingGenerationKeys.contains(flav)) { } else if (disabledMappingGenerationKeys.contains(flav)) {
// In this case we shouldn't synthesize a native for this flavor, // In this case we shouldn't synthesize a native for this flavor,
// since its mappings were explicitly specified. // since its mappings were explicitly specified.
...@@ -699,7 +699,7 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable { ...@@ -699,7 +699,7 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
// For text/* flavors, flavor-to-native mappings specified in // For text/* flavors, flavor-to-native mappings specified in
// flavormap.properties are stored per flavor's base type. // flavormap.properties are stored per flavor's base type.
if ("text".equals(flav.getPrimaryType())) { if ("text".equals(flav.getPrimaryType())) {
retval = (List)getFlavorToNative().get(flav.mimeType.getBaseType()); retval = getAllNativesForType(flav.mimeType.getBaseType());
if (retval != null) { if (retval != null) {
// To prevent the List stored in the map from modification. // To prevent the List stored in the map from modification.
retval = new ArrayList(retval); retval = new ArrayList(retval);
...@@ -707,15 +707,15 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable { ...@@ -707,15 +707,15 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
} }
// Also include text/plain natives, but don't duplicate Strings // Also include text/plain natives, but don't duplicate Strings
List textPlainList = (List)getFlavorToNative().get(TEXT_PLAIN_BASE_TYPE); List<String> textPlainList = getAllNativesForType(TEXT_PLAIN_BASE_TYPE);
if (textPlainList != null && !textPlainList.isEmpty()) { if (textPlainList != null && !textPlainList.isEmpty()) {
// To prevent the List stored in the map from modification. // To prevent the List stored in the map from modification.
// This also guarantees that removeAll() is supported. // This also guarantees that removeAll() is supported.
textPlainList = new ArrayList(textPlainList); textPlainList = new ArrayList<>(textPlainList);
if (retval != null && !retval.isEmpty()) { if (retval != null && !retval.isEmpty()) {
// Use HashSet to get constant-time performance for search. // Use HashSet to get constant-time performance for search.
textPlainList.removeAll(new HashSet(retval)); textPlainList.removeAll(new HashSet<>(retval));
retval.addAll(textPlainList); retval.addAll(textPlainList);
} else { } else {
retval = textPlainList; retval = textPlainList;
...@@ -728,7 +728,7 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable { ...@@ -728,7 +728,7 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
// In this branch it is guaranteed that natives explicitly // In this branch it is guaranteed that natives explicitly
// listed for flav's MIME type were added with // listed for flav's MIME type were added with
// addUnencodedNativeForFlavor(), so they have lower priority. // addUnencodedNativeForFlavor(), so they have lower priority.
List explicitList = List<String> explicitList =
flavorToNativeLookup(flav, !SYNTHESIZE_IF_NOT_FOUND); flavorToNativeLookup(flav, !SYNTHESIZE_IF_NOT_FOUND);
// flavorToNativeLookup() never returns null. // flavorToNativeLookup() never returns null.
...@@ -736,14 +736,14 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable { ...@@ -736,14 +736,14 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
if (!explicitList.isEmpty()) { if (!explicitList.isEmpty()) {
// To prevent the List stored in the map from modification. // To prevent the List stored in the map from modification.
// This also guarantees that removeAll() is supported. // This also guarantees that removeAll() is supported.
explicitList = new ArrayList(explicitList); explicitList = new ArrayList<>(explicitList);
// Use HashSet to get constant-time performance for search. // Use HashSet to get constant-time performance for search.
explicitList.removeAll(new HashSet(retval)); explicitList.removeAll(new HashSet<>(retval));
retval.addAll(explicitList); retval.addAll(explicitList);
} }
} }
} else if (DataTransferer.isFlavorNoncharsetTextType(flav)) { } else if (DataTransferer.isFlavorNoncharsetTextType(flav)) {
retval = (List)getFlavorToNative().get(flav.mimeType.getBaseType()); retval = getAllNativesForType(flav.mimeType.getBaseType());
if (retval == null || retval.isEmpty()) { if (retval == null || retval.isEmpty()) {
retval = flavorToNativeLookup(flav, SYNTHESIZE_IF_NOT_FOUND); retval = flavorToNativeLookup(flav, SYNTHESIZE_IF_NOT_FOUND);
...@@ -751,7 +751,7 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable { ...@@ -751,7 +751,7 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
// In this branch it is guaranteed that natives explicitly // In this branch it is guaranteed that natives explicitly
// listed for flav's MIME type were added with // listed for flav's MIME type were added with
// addUnencodedNativeForFlavor(), so they have lower priority. // addUnencodedNativeForFlavor(), so they have lower priority.
List explicitList = List<String> explicitList =
flavorToNativeLookup(flav, !SYNTHESIZE_IF_NOT_FOUND); flavorToNativeLookup(flav, !SYNTHESIZE_IF_NOT_FOUND);
// flavorToNativeLookup() never returns null. // flavorToNativeLookup() never returns null.
...@@ -759,10 +759,10 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable { ...@@ -759,10 +759,10 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
if (!explicitList.isEmpty()) { if (!explicitList.isEmpty()) {
// To prevent the List stored in the map from modification. // To prevent the List stored in the map from modification.
// This also guarantees that add/removeAll() are supported. // This also guarantees that add/removeAll() are supported.
retval = new ArrayList(retval); retval = new ArrayList<>(retval);
explicitList = new ArrayList(explicitList); explicitList = new ArrayList<>(explicitList);
// Use HashSet to get constant-time performance for search. // Use HashSet to get constant-time performance for search.
explicitList.removeAll(new HashSet(retval)); explicitList.removeAll(new HashSet<>(retval));
retval.addAll(explicitList); retval.addAll(explicitList);
} }
} }
...@@ -770,9 +770,9 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable { ...@@ -770,9 +770,9 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
retval = flavorToNativeLookup(flav, SYNTHESIZE_IF_NOT_FOUND); retval = flavorToNativeLookup(flav, SYNTHESIZE_IF_NOT_FOUND);
} }
getNativesForFlavorCache.put(flav, new SoftReference(retval)); getNativesForFlavorCache.put(flav, new SoftReference<>(retval));
// Create a copy, because client code can modify the returned list. // Create a copy, because client code can modify the returned list.
return new ArrayList(retval); return new ArrayList<>(retval);
} }
/** /**
...@@ -809,11 +809,11 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable { ...@@ -809,11 +809,11 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
public synchronized List<DataFlavor> getFlavorsForNative(String nat) { public synchronized List<DataFlavor> getFlavorsForNative(String nat) {
// Check cache, even for null nat // Check cache, even for null nat
SoftReference ref = (SoftReference)getFlavorsForNativeCache.get(nat); SoftReference<List<DataFlavor>> ref = getFlavorsForNativeCache.get(nat);
if (ref != null) { if (ref != null) {
ArrayList retval = (ArrayList)ref.get(); List<DataFlavor> retval = ref.get();
if (retval != null) { if (retval != null) {
return (List)retval.clone(); return new ArrayList<>(retval);
} }
} }
...@@ -859,16 +859,15 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable { ...@@ -859,16 +859,15 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
} }
final ArrayList arrayList = new ArrayList(returnValue); final List<DataFlavor> arrayList = new ArrayList<>(returnValue);
getFlavorsForNativeCache.put(nat, new SoftReference(arrayList)); getFlavorsForNativeCache.put(nat, new SoftReference<>(arrayList));
return (List)arrayList.clone(); return new ArrayList<>(arrayList);
} }
private static LinkedHashSet<DataFlavor> convertMimeTypeToDataFlavors( private static Set<DataFlavor> convertMimeTypeToDataFlavors(
final String baseType) { final String baseType) {
final LinkedHashSet<DataFlavor> returnValue = final Set<DataFlavor> returnValue = new LinkedHashSet<>();
new LinkedHashSet<DataFlavor>();
String subType = null; String subType = null;
...@@ -1009,11 +1008,11 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable { ...@@ -1009,11 +1008,11 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
flavor_list.toArray(flavors); flavor_list.toArray(flavors);
} }
HashMap retval = new HashMap(flavors.length, 1.0f); Map<DataFlavor, String> retval = new HashMap<>(flavors.length, 1.0f);
for (int i = 0; i < flavors.length; i++) { for (DataFlavor flavor : flavors) {
List natives = getNativesForFlavor(flavors[i]); List<String> natives = getNativesForFlavor(flavor);
String nat = (natives.isEmpty()) ? null : (String)natives.get(0); String nat = (natives.isEmpty()) ? null : natives.get(0);
retval.put(flavors[i], nat); retval.put(flavor, nat);
} }
return retval; return retval;
...@@ -1054,12 +1053,11 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable { ...@@ -1054,12 +1053,11 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
native_list.toArray(natives); native_list.toArray(natives);
} }
HashMap retval = new HashMap(natives.length, 1.0f); Map<String, DataFlavor> retval = new HashMap<>(natives.length, 1.0f);
for (int i = 0; i < natives.length; i++) { for (String aNative : natives) {
List flavors = getFlavorsForNative(natives[i]); List<DataFlavor> flavors = getFlavorsForNative(aNative);
DataFlavor flav = (flavors.isEmpty()) DataFlavor flav = (flavors.isEmpty())? null : flavors.get(0);
? null : (DataFlavor)flavors.get(0); retval.put(aNative, flav);
retval.put(natives[i], flav);
} }
return retval; return retval;
...@@ -1091,9 +1089,9 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable { ...@@ -1091,9 +1089,9 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
throw new NullPointerException("null arguments not permitted"); throw new NullPointerException("null arguments not permitted");
} }
List natives = (List)getFlavorToNative().get(flav); List<String> natives = getFlavorToNative().get(flav);
if (natives == null) { if (natives == null) {
natives = new ArrayList(1); natives = new ArrayList<>(1);
getFlavorToNative().put(flav, natives); getFlavorToNative().put(flav, natives);
} else if (natives.contains(nat)) { } else if (natives.contains(nat)) {
return; return;
...@@ -1138,8 +1136,8 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable { ...@@ -1138,8 +1136,8 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
} }
getFlavorToNative().remove(flav); getFlavorToNative().remove(flav);
for (int i = 0; i < natives.length; i++) { for (String aNative : natives) {
addUnencodedNativeForFlavor(flav, natives[i]); addUnencodedNativeForFlavor(flav, aNative);
} }
disabledMappingGenerationKeys.add(flav); disabledMappingGenerationKeys.add(flav);
// Clear the cache to handle the case of empty natives. // Clear the cache to handle the case of empty natives.
...@@ -1171,9 +1169,9 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable { ...@@ -1171,9 +1169,9 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
throw new NullPointerException("null arguments not permitted"); throw new NullPointerException("null arguments not permitted");
} }
List flavors = (List)getNativeToFlavor().get(nat); List<DataFlavor> flavors = getNativeToFlavor().get(nat);
if (flavors == null) { if (flavors == null) {
flavors = new ArrayList(1); flavors = new ArrayList<>(1);
getNativeToFlavor().put(nat, flavors); getNativeToFlavor().put(nat, flavors);
} else if (flavors.contains(flav)) { } else if (flavors.contains(flav)) {
return; return;
...@@ -1217,8 +1215,8 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable { ...@@ -1217,8 +1215,8 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
} }
getNativeToFlavor().remove(nat); getNativeToFlavor().remove(nat);
for (int i = 0; i < flavors.length; i++) { for (DataFlavor flavor : flavors) {
addFlavorForUnencodedNative(nat, flavors[i]); addFlavorForUnencodedNative(nat, flavor);
} }
disabledMappingGenerationKeys.add(nat); disabledMappingGenerationKeys.add(nat);
// Clear the cache to handle the case of empty flavors. // Clear the cache to handle the case of empty flavors.
...@@ -1321,4 +1319,18 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable { ...@@ -1321,4 +1319,18 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
? new DataFlavor(retval_str) ? new DataFlavor(retval_str)
: null; : 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;
}
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册