607 final LinkedHashSet<DataFlavor> flavors = nativeToFlavorLookup(nat);
608 if (disabledMappingGenerationKeys.contains(nat)) {
609 return new ArrayList<>(flavors);
610 }
611
612 final LinkedHashSet<DataFlavor> flavorsWithSynthesized =
613 nativeToFlavorLookup(nat);
614
615 for (DataFlavor df : flavorsWithSynthesized) {
616 returnValue.add(df);
617 if ("text".equals(df.getPrimaryType())) {
618 String baseType = df.mimeType.getBaseType();
619 returnValue.addAll(convertMimeTypeToDataFlavors(baseType));
620 }
621 }
622 }
623 flavorsForNativeCache.put(nat, returnValue);
624 return new ArrayList<>(returnValue);
625 }
626
627 private static Set<DataFlavor> convertMimeTypeToDataFlavors(
628 final String baseType) {
629
630 final Set<DataFlavor> returnValue = new LinkedHashSet<>();
631
632 String subType = null;
633
634 try {
635 final MimeType mimeType = new MimeType(baseType);
636 subType = mimeType.getSubType();
637 } catch (MimeTypeParseException mtpe) {
638 // Cannot happen, since we checked all mappings
639 // on load from flavormap.properties.
640 }
641
642 if (DataFlavorUtil.doesSubtypeSupportCharset(subType, null)) {
643 if (TEXT_PLAIN_BASE_TYPE.equals(baseType))
644 {
645 returnValue.add(DataFlavor.stringFlavor);
646 }
|
607 final LinkedHashSet<DataFlavor> flavors = nativeToFlavorLookup(nat);
608 if (disabledMappingGenerationKeys.contains(nat)) {
609 return new ArrayList<>(flavors);
610 }
611
612 final LinkedHashSet<DataFlavor> flavorsWithSynthesized =
613 nativeToFlavorLookup(nat);
614
615 for (DataFlavor df : flavorsWithSynthesized) {
616 returnValue.add(df);
617 if ("text".equals(df.getPrimaryType())) {
618 String baseType = df.mimeType.getBaseType();
619 returnValue.addAll(convertMimeTypeToDataFlavors(baseType));
620 }
621 }
622 }
623 flavorsForNativeCache.put(nat, returnValue);
624 return new ArrayList<>(returnValue);
625 }
626
627 @SuppressWarnings("deprecation")
628 private static Set<DataFlavor> convertMimeTypeToDataFlavors(
629 final String baseType) {
630
631 final Set<DataFlavor> returnValue = new LinkedHashSet<>();
632
633 String subType = null;
634
635 try {
636 final MimeType mimeType = new MimeType(baseType);
637 subType = mimeType.getSubType();
638 } catch (MimeTypeParseException mtpe) {
639 // Cannot happen, since we checked all mappings
640 // on load from flavormap.properties.
641 }
642
643 if (DataFlavorUtil.doesSubtypeSupportCharset(subType, null)) {
644 if (TEXT_PLAIN_BASE_TYPE.equals(baseType))
645 {
646 returnValue.add(DataFlavor.stringFlavor);
647 }
|