Java Code Examples for sun.awt.datatransfer.DataTransferer#getInstance()

The following examples show how to use sun.awt.datatransfer.DataTransferer#getInstance() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SystemFlavorMap.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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 LinkedHashSet<DataFlavor> nativeToFlavorLookup(String nat) {
    LinkedHashSet<DataFlavor> flavors = getNativeToFlavor().get(nat);


    if (nat != null && !disabledMappingGenerationKeys.contains(nat)) {
        DataTransferer transferer = DataTransferer.getInstance();
        if (transferer != null) {
            LinkedHashSet<DataFlavor> platformFlavors =
                transferer.getPlatformMappingsForNative(nat);
            if (!platformFlavors.isEmpty()) {
                if (flavors != null) {
                    // Prepending the platform-specific mappings ensures
                    // that the flavors added with
                    // addFlavorForUnencodedNative() are at the end of
                    // list.
                    platformFlavors.addAll(flavors);
                }
                flavors = platformFlavors;
            }
        }
    }

    if (flavors == null && isJavaMIMEType(nat)) {
        String decoded = decodeJavaMIMEType(nat);
        DataFlavor flavor = null;

        try {
            flavor = new DataFlavor(decoded);
        } catch (Exception e) {
            System.err.println("Exception \"" + e.getClass().getName() +
                               ": " + e.getMessage()  +
                               "\"while constructing DataFlavor for: " +
                               decoded);
        }

        if (flavor != null) {
            flavors = new LinkedHashSet<>(1);
            getNativeToFlavor().put(nat, flavors);
            flavors.add(flavor);
            flavorsForNativeCache.remove(nat);

            LinkedHashSet<String> natives = getFlavorToNative().get(flavor);
            if (natives == null) {
                natives = new LinkedHashSet<>(1);
                getFlavorToNative().put(flavor, natives);
            }
            natives.add(nat);
            nativesForFlavorCache.remove(flavor);
        }
    }

    return (flavors != null) ? flavors : new LinkedHashSet<>(0);
}
 
Example 2
Source File: SystemFlavorMap.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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 LinkedHashSet<String> flavorToNativeLookup(final DataFlavor flav,
                                                   final boolean synthesize) {

    LinkedHashSet<String> natives = getFlavorToNative().get(flav);

    if (flav != null && !disabledMappingGenerationKeys.contains(flav)) {
        DataTransferer transferer = DataTransferer.getInstance();
        if (transferer != null) {
            LinkedHashSet<String> platformNatives =
                transferer.getPlatformMappingsForFlavor(flav);
            if (!platformNatives.isEmpty()) {
                if (natives != null) {
                    // Prepend the platform-specific mappings to ensure
                    // that the natives added with
                    // addUnencodedNativeForFlavor() are at the end of
                    // list.
                    platformNatives.addAll(natives);
                }
                natives = platformNatives;
            }
        }
    }

    if (natives == null) {
        if (synthesize) {
            String encoded = encodeDataFlavor(flav);
            natives = new LinkedHashSet<>(1);
            getFlavorToNative().put(flav, natives);
            natives.add(encoded);

            LinkedHashSet<DataFlavor> flavors = getNativeToFlavor().get(encoded);
            if (flavors == null) {
                flavors = new LinkedHashSet<>(1);
                getNativeToFlavor().put(encoded, flavors);
            }
            flavors.add(flav);

            nativesForFlavorCache.remove(flav);
            flavorsForNativeCache.remove(encoded);
        } else {
            natives = new LinkedHashSet<>(0);
        }
    }

    return new LinkedHashSet<>(natives);
}
 
Example 3
Source File: SystemFlavorMap.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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 LinkedHashSet<DataFlavor> nativeToFlavorLookup(String nat) {
    LinkedHashSet<DataFlavor> flavors = getNativeToFlavor().get(nat);


    if (nat != null && !disabledMappingGenerationKeys.contains(nat)) {
        DataTransferer transferer = DataTransferer.getInstance();
        if (transferer != null) {
            LinkedHashSet<DataFlavor> platformFlavors =
                transferer.getPlatformMappingsForNative(nat);
            if (!platformFlavors.isEmpty()) {
                if (flavors != null) {
                    // Prepending the platform-specific mappings ensures
                    // that the flavors added with
                    // addFlavorForUnencodedNative() are at the end of
                    // list.
                    platformFlavors.addAll(flavors);
                }
                flavors = platformFlavors;
            }
        }
    }

    if (flavors == null && isJavaMIMEType(nat)) {
        String decoded = decodeJavaMIMEType(nat);
        DataFlavor flavor = null;

        try {
            flavor = new DataFlavor(decoded);
        } catch (Exception e) {
            System.err.println("Exception \"" + e.getClass().getName() +
                               ": " + e.getMessage()  +
                               "\"while constructing DataFlavor for: " +
                               decoded);
        }

        if (flavor != null) {
            flavors = new LinkedHashSet<>(1);
            getNativeToFlavor().put(nat, flavors);
            flavors.add(flavor);
            flavorsForNativeCache.remove(nat);

            LinkedHashSet<String> natives = getFlavorToNative().get(flavor);
            if (natives == null) {
                natives = new LinkedHashSet<>(1);
                getFlavorToNative().put(flavor, natives);
            }
            natives.add(nat);
            nativesForFlavorCache.remove(flavor);
        }
    }

    return (flavors != null) ? flavors : new LinkedHashSet<>(0);
}
 
Example 4
Source File: SystemFlavorMap.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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 LinkedHashSet<String> flavorToNativeLookup(final DataFlavor flav,
                                                   final boolean synthesize) {

    LinkedHashSet<String> natives = getFlavorToNative().get(flav);

    if (flav != null && !disabledMappingGenerationKeys.contains(flav)) {
        DataTransferer transferer = DataTransferer.getInstance();
        if (transferer != null) {
            LinkedHashSet<String> platformNatives =
                transferer.getPlatformMappingsForFlavor(flav);
            if (!platformNatives.isEmpty()) {
                if (natives != null) {
                    // Prepend the platform-specific mappings to ensure
                    // that the natives added with
                    // addUnencodedNativeForFlavor() are at the end of
                    // list.
                    platformNatives.addAll(natives);
                }
                natives = platformNatives;
            }
        }
    }

    if (natives == null) {
        if (synthesize) {
            String encoded = encodeDataFlavor(flav);
            natives = new LinkedHashSet<>(1);
            getFlavorToNative().put(flav, natives);
            natives.add(encoded);

            LinkedHashSet<DataFlavor> flavors = getNativeToFlavor().get(encoded);
            if (flavors == null) {
                flavors = new LinkedHashSet<>(1);
                getNativeToFlavor().put(encoded, flavors);
            }
            flavors.add(flav);

            nativesForFlavorCache.remove(flav);
            flavorsForNativeCache.remove(encoded);
        } else {
            natives = new LinkedHashSet<>(0);
        }
    }

    return new LinkedHashSet<>(natives);
}
 
Example 5
Source File: SystemFlavorMap.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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 LinkedHashSet<DataFlavor> nativeToFlavorLookup(String nat) {
    LinkedHashSet<DataFlavor> flavors = getNativeToFlavor().get(nat);


    if (nat != null && !disabledMappingGenerationKeys.contains(nat)) {
        DataTransferer transferer = DataTransferer.getInstance();
        if (transferer != null) {
            LinkedHashSet<DataFlavor> platformFlavors =
                transferer.getPlatformMappingsForNative(nat);
            if (!platformFlavors.isEmpty()) {
                if (flavors != null) {
                    // Prepending the platform-specific mappings ensures
                    // that the flavors added with
                    // addFlavorForUnencodedNative() are at the end of
                    // list.
                    platformFlavors.addAll(flavors);
                }
                flavors = platformFlavors;
            }
        }
    }

    if (flavors == null && isJavaMIMEType(nat)) {
        String decoded = decodeJavaMIMEType(nat);
        DataFlavor flavor = null;

        try {
            flavor = new DataFlavor(decoded);
        } catch (Exception e) {
            System.err.println("Exception \"" + e.getClass().getName() +
                               ": " + e.getMessage()  +
                               "\"while constructing DataFlavor for: " +
                               decoded);
        }

        if (flavor != null) {
            flavors = new LinkedHashSet<>(1);
            getNativeToFlavor().put(nat, flavors);
            flavors.add(flavor);
            flavorsForNativeCache.remove(nat);

            LinkedHashSet<String> natives = getFlavorToNative().get(flavor);
            if (natives == null) {
                natives = new LinkedHashSet<>(1);
                getFlavorToNative().put(flavor, natives);
            }
            natives.add(nat);
            nativesForFlavorCache.remove(flavor);
        }
    }

    return (flavors != null) ? flavors : new LinkedHashSet<>(0);
}
 
Example 6
Source File: SystemFlavorMap.java    From JDKSourceCode1.8 with MIT License 4 votes vote down vote up
/**
 * 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 LinkedHashSet<String> flavorToNativeLookup(final DataFlavor flav,
                                                   final boolean synthesize) {

    LinkedHashSet<String> natives = getFlavorToNative().get(flav);

    if (flav != null && !disabledMappingGenerationKeys.contains(flav)) {
        DataTransferer transferer = DataTransferer.getInstance();
        if (transferer != null) {
            LinkedHashSet<String> platformNatives =
                transferer.getPlatformMappingsForFlavor(flav);
            if (!platformNatives.isEmpty()) {
                if (natives != null) {
                    // Prepend the platform-specific mappings to ensure
                    // that the natives added with
                    // addUnencodedNativeForFlavor() are at the end of
                    // list.
                    platformNatives.addAll(natives);
                }
                natives = platformNatives;
            }
        }
    }

    if (natives == null) {
        if (synthesize) {
            String encoded = encodeDataFlavor(flav);
            natives = new LinkedHashSet<>(1);
            getFlavorToNative().put(flav, natives);
            natives.add(encoded);

            LinkedHashSet<DataFlavor> flavors = getNativeToFlavor().get(encoded);
            if (flavors == null) {
                flavors = new LinkedHashSet<>(1);
                getNativeToFlavor().put(encoded, flavors);
            }
            flavors.add(flav);

            nativesForFlavorCache.remove(flav);
            flavorsForNativeCache.remove(encoded);
        } else {
            natives = new LinkedHashSet<>(0);
        }
    }

    return new LinkedHashSet<>(natives);
}
 
Example 7
Source File: SystemFlavorMap.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
/**
 * 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 LinkedHashSet<DataFlavor> nativeToFlavorLookup(String nat) {
    LinkedHashSet<DataFlavor> flavors = getNativeToFlavor().get(nat);


    if (nat != null && !disabledMappingGenerationKeys.contains(nat)) {
        DataTransferer transferer = DataTransferer.getInstance();
        if (transferer != null) {
            LinkedHashSet<DataFlavor> platformFlavors =
                transferer.getPlatformMappingsForNative(nat);
            if (!platformFlavors.isEmpty()) {
                if (flavors != null) {
                    // Prepending the platform-specific mappings ensures
                    // that the flavors added with
                    // addFlavorForUnencodedNative() are at the end of
                    // list.
                    platformFlavors.addAll(flavors);
                }
                flavors = platformFlavors;
            }
        }
    }

    if (flavors == null && isJavaMIMEType(nat)) {
        String decoded = decodeJavaMIMEType(nat);
        DataFlavor flavor = null;

        try {
            flavor = new DataFlavor(decoded);
        } catch (Exception e) {
            System.err.println("Exception \"" + e.getClass().getName() +
                               ": " + e.getMessage()  +
                               "\"while constructing DataFlavor for: " +
                               decoded);
        }

        if (flavor != null) {
            flavors = new LinkedHashSet<>(1);
            getNativeToFlavor().put(nat, flavors);
            flavors.add(flavor);
            flavorsForNativeCache.remove(nat);

            LinkedHashSet<String> natives = getFlavorToNative().get(flavor);
            if (natives == null) {
                natives = new LinkedHashSet<>(1);
                getFlavorToNative().put(flavor, natives);
            }
            natives.add(nat);
            nativesForFlavorCache.remove(flavor);
        }
    }

    return (flavors != null) ? flavors : new LinkedHashSet<>(0);
}
 
Example 8
Source File: SystemFlavorMap.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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);
                }
                flavors = platformFlavors;
            }
        }
    }

    if (flavors == null && isJavaMIMEType(nat)) {
        String decoded = decodeJavaMIMEType(nat);
        DataFlavor flavor = null;

        try {
            flavor = new DataFlavor(decoded);
        } catch (Exception e) {
            System.err.println("Exception \"" + e.getClass().getName() +
                               ": " + e.getMessage()  +
                               "\"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);
}
 
Example 9
Source File: SystemFlavorMap.java    From Java8CN with Apache License 2.0 4 votes vote down vote up
/**
 * 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 LinkedHashSet<String> flavorToNativeLookup(final DataFlavor flav,
                                                   final boolean synthesize) {

    LinkedHashSet<String> natives = getFlavorToNative().get(flav);

    if (flav != null && !disabledMappingGenerationKeys.contains(flav)) {
        DataTransferer transferer = DataTransferer.getInstance();
        if (transferer != null) {
            LinkedHashSet<String> platformNatives =
                transferer.getPlatformMappingsForFlavor(flav);
            if (!platformNatives.isEmpty()) {
                if (natives != null) {
                    // Prepend the platform-specific mappings to ensure
                    // that the natives added with
                    // addUnencodedNativeForFlavor() are at the end of
                    // list.
                    platformNatives.addAll(natives);
                }
                natives = platformNatives;
            }
        }
    }

    if (natives == null) {
        if (synthesize) {
            String encoded = encodeDataFlavor(flav);
            natives = new LinkedHashSet<>(1);
            getFlavorToNative().put(flav, natives);
            natives.add(encoded);

            LinkedHashSet<DataFlavor> flavors = getNativeToFlavor().get(encoded);
            if (flavors == null) {
                flavors = new LinkedHashSet<>(1);
                getNativeToFlavor().put(encoded, flavors);
            }
            flavors.add(flav);

            nativesForFlavorCache.remove(flav);
            flavorsForNativeCache.remove(encoded);
        } else {
            natives = new LinkedHashSet<>(0);
        }
    }

    return new LinkedHashSet<>(natives);
}
 
Example 10
Source File: SystemFlavorMap.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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 LinkedHashSet<String> flavorToNativeLookup(final DataFlavor flav,
                                                   final boolean synthesize) {

    LinkedHashSet<String> natives = getFlavorToNative().get(flav);

    if (flav != null && !disabledMappingGenerationKeys.contains(flav)) {
        DataTransferer transferer = DataTransferer.getInstance();
        if (transferer != null) {
            LinkedHashSet<String> platformNatives =
                transferer.getPlatformMappingsForFlavor(flav);
            if (!platformNatives.isEmpty()) {
                if (natives != null) {
                    // Prepend the platform-specific mappings to ensure
                    // that the natives added with
                    // addUnencodedNativeForFlavor() are at the end of
                    // list.
                    platformNatives.addAll(natives);
                }
                natives = platformNatives;
            }
        }
    }

    if (natives == null) {
        if (synthesize) {
            String encoded = encodeDataFlavor(flav);
            natives = new LinkedHashSet<>(1);
            getFlavorToNative().put(flav, natives);
            natives.add(encoded);

            LinkedHashSet<DataFlavor> flavors = getNativeToFlavor().get(encoded);
            if (flavors == null) {
                flavors = new LinkedHashSet<>(1);
                getNativeToFlavor().put(encoded, flavors);
            }
            flavors.add(flav);

            nativesForFlavorCache.remove(flav);
            flavorsForNativeCache.remove(encoded);
        } else {
            natives = new LinkedHashSet<>(0);
        }
    }

    return new LinkedHashSet<>(natives);
}
 
Example 11
Source File: SystemFlavorMap.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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 LinkedHashSet<DataFlavor> nativeToFlavorLookup(String nat) {
    LinkedHashSet<DataFlavor> flavors = getNativeToFlavor().get(nat);


    if (nat != null && !disabledMappingGenerationKeys.contains(nat)) {
        DataTransferer transferer = DataTransferer.getInstance();
        if (transferer != null) {
            LinkedHashSet<DataFlavor> platformFlavors =
                transferer.getPlatformMappingsForNative(nat);
            if (!platformFlavors.isEmpty()) {
                if (flavors != null) {
                    // Prepending the platform-specific mappings ensures
                    // that the flavors added with
                    // addFlavorForUnencodedNative() are at the end of
                    // list.
                    platformFlavors.addAll(flavors);
                }
                flavors = platformFlavors;
            }
        }
    }

    if (flavors == null && isJavaMIMEType(nat)) {
        String decoded = decodeJavaMIMEType(nat);
        DataFlavor flavor = null;

        try {
            flavor = new DataFlavor(decoded);
        } catch (Exception e) {
            System.err.println("Exception \"" + e.getClass().getName() +
                               ": " + e.getMessage()  +
                               "\"while constructing DataFlavor for: " +
                               decoded);
        }

        if (flavor != null) {
            flavors = new LinkedHashSet<>(1);
            getNativeToFlavor().put(nat, flavors);
            flavors.add(flavor);
            flavorsForNativeCache.remove(nat);

            LinkedHashSet<String> natives = getFlavorToNative().get(flavor);
            if (natives == null) {
                natives = new LinkedHashSet<>(1);
                getFlavorToNative().put(flavor, natives);
            }
            natives.add(nat);
            nativesForFlavorCache.remove(flavor);
        }
    }

    return (flavors != null) ? flavors : new LinkedHashSet<>(0);
}
 
Example 12
Source File: SystemFlavorMap.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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 LinkedHashSet<DataFlavor> nativeToFlavorLookup(String nat) {
    LinkedHashSet<DataFlavor> flavors = getNativeToFlavor().get(nat);


    if (nat != null && !disabledMappingGenerationKeys.contains(nat)) {
        DataTransferer transferer = DataTransferer.getInstance();
        if (transferer != null) {
            LinkedHashSet<DataFlavor> platformFlavors =
                transferer.getPlatformMappingsForNative(nat);
            if (!platformFlavors.isEmpty()) {
                if (flavors != null) {
                    // Prepending the platform-specific mappings ensures
                    // that the flavors added with
                    // addFlavorForUnencodedNative() are at the end of
                    // list.
                    platformFlavors.addAll(flavors);
                }
                flavors = platformFlavors;
            }
        }
    }

    if (flavors == null && isJavaMIMEType(nat)) {
        String decoded = decodeJavaMIMEType(nat);
        DataFlavor flavor = null;

        try {
            flavor = new DataFlavor(decoded);
        } catch (Exception e) {
            System.err.println("Exception \"" + e.getClass().getName() +
                               ": " + e.getMessage()  +
                               "\"while constructing DataFlavor for: " +
                               decoded);
        }

        if (flavor != null) {
            flavors = new LinkedHashSet<>(1);
            getNativeToFlavor().put(nat, flavors);
            flavors.add(flavor);
            flavorsForNativeCache.remove(nat);

            LinkedHashSet<String> natives = getFlavorToNative().get(flavor);
            if (natives == null) {
                natives = new LinkedHashSet<>(1);
                getFlavorToNative().put(flavor, natives);
            }
            natives.add(nat);
            nativesForFlavorCache.remove(flavor);
        }
    }

    return (flavors != null) ? flavors : new LinkedHashSet<>(0);
}
 
Example 13
Source File: SystemFlavorMap.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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 LinkedHashSet<DataFlavor> nativeToFlavorLookup(String nat) {
    LinkedHashSet<DataFlavor> flavors = getNativeToFlavor().get(nat);


    if (nat != null && !disabledMappingGenerationKeys.contains(nat)) {
        DataTransferer transferer = DataTransferer.getInstance();
        if (transferer != null) {
            LinkedHashSet<DataFlavor> platformFlavors =
                transferer.getPlatformMappingsForNative(nat);
            if (!platformFlavors.isEmpty()) {
                if (flavors != null) {
                    // Prepending the platform-specific mappings ensures
                    // that the flavors added with
                    // addFlavorForUnencodedNative() are at the end of
                    // list.
                    platformFlavors.addAll(flavors);
                }
                flavors = platformFlavors;
            }
        }
    }

    if (flavors == null && isJavaMIMEType(nat)) {
        String decoded = decodeJavaMIMEType(nat);
        DataFlavor flavor = null;

        try {
            flavor = new DataFlavor(decoded);
        } catch (Exception e) {
            System.err.println("Exception \"" + e.getClass().getName() +
                               ": " + e.getMessage()  +
                               "\"while constructing DataFlavor for: " +
                               decoded);
        }

        if (flavor != null) {
            flavors = new LinkedHashSet<>(1);
            getNativeToFlavor().put(nat, flavors);
            flavors.add(flavor);
            flavorsForNativeCache.remove(nat);

            LinkedHashSet<String> natives = getFlavorToNative().get(flavor);
            if (natives == null) {
                natives = new LinkedHashSet<>(1);
                getFlavorToNative().put(flavor, natives);
            }
            natives.add(nat);
            nativesForFlavorCache.remove(flavor);
        }
    }

    return (flavors != null) ? flavors : new LinkedHashSet<>(0);
}
 
Example 14
Source File: DataFlavor.java    From jdk-1.7-annotated with Apache License 2.0 3 votes vote down vote up
/**
 * Returns a <code>DataFlavor</code> representing plain text with Unicode
 * encoding, where:
 * <pre>
 *     representationClass = java.io.InputStream
 *     mimeType            = "text/plain;
 *                            charset=&lt;platform default Unicode encoding&gt;"
 * </pre>
 * Sun's implementation for Microsoft Windows uses the encoding <code>utf-16le</code>.
 * Sun's implementation for Solaris and Linux uses the encoding
 * <code>iso-10646-ucs-2</code>.
 *
 * @return a <code>DataFlavor</code> representing plain text
 *    with Unicode encoding
 * @since 1.3
 */
public static final DataFlavor getTextPlainUnicodeFlavor() {
    String encoding = null;
    DataTransferer transferer = DataTransferer.getInstance();
    if (transferer != null) {
        encoding = transferer.getDefaultUnicodeEncoding();
    }
    return new DataFlavor(
        "text/plain;charset="+encoding
        +";class=java.io.InputStream", "Plain Text");
}
 
Example 15
Source File: DataFlavor.java    From jdk8u-dev-jdk with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Returns a <code>DataFlavor</code> representing plain text with Unicode
 * encoding, where:
 * <pre>
 *     representationClass = java.io.InputStream
 *     mimeType            = "text/plain;
 *                            charset=&lt;platform default Unicode encoding&gt;"
 * </pre>
 * Sun's implementation for Microsoft Windows uses the encoding <code>utf-16le</code>.
 * Sun's implementation for Solaris and Linux uses the encoding
 * <code>iso-10646-ucs-2</code>.
 *
 * @return a <code>DataFlavor</code> representing plain text
 *    with Unicode encoding
 * @since 1.3
 */
public static final DataFlavor getTextPlainUnicodeFlavor() {
    String encoding = null;
    DataTransferer transferer = DataTransferer.getInstance();
    if (transferer != null) {
        encoding = transferer.getDefaultUnicodeEncoding();
    }
    return new DataFlavor(
        "text/plain;charset="+encoding
        +";class=java.io.InputStream", "Plain Text");
}
 
Example 16
Source File: DataFlavor.java    From jdk8u60 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Returns a <code>DataFlavor</code> representing plain text with Unicode
 * encoding, where:
 * <pre>
 *     representationClass = java.io.InputStream
 *     mimeType            = "text/plain;
 *                            charset=&lt;platform default Unicode encoding&gt;"
 * </pre>
 * Sun's implementation for Microsoft Windows uses the encoding <code>utf-16le</code>.
 * Sun's implementation for Solaris and Linux uses the encoding
 * <code>iso-10646-ucs-2</code>.
 *
 * @return a <code>DataFlavor</code> representing plain text
 *    with Unicode encoding
 * @since 1.3
 */
public static final DataFlavor getTextPlainUnicodeFlavor() {
    String encoding = null;
    DataTransferer transferer = DataTransferer.getInstance();
    if (transferer != null) {
        encoding = transferer.getDefaultUnicodeEncoding();
    }
    return new DataFlavor(
        "text/plain;charset="+encoding
        +";class=java.io.InputStream", "Plain Text");
}
 
Example 17
Source File: DataFlavor.java    From openjdk-8-source with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Returns a <code>DataFlavor</code> representing plain text with Unicode
 * encoding, where:
 * <pre>
 *     representationClass = java.io.InputStream
 *     mimeType            = "text/plain;
 *                            charset=&lt;platform default Unicode encoding&gt;"
 * </pre>
 * Sun's implementation for Microsoft Windows uses the encoding <code>utf-16le</code>.
 * Sun's implementation for Solaris and Linux uses the encoding
 * <code>iso-10646-ucs-2</code>.
 *
 * @return a <code>DataFlavor</code> representing plain text
 *    with Unicode encoding
 * @since 1.3
 */
public static final DataFlavor getTextPlainUnicodeFlavor() {
    String encoding = null;
    DataTransferer transferer = DataTransferer.getInstance();
    if (transferer != null) {
        encoding = transferer.getDefaultUnicodeEncoding();
    }
    return new DataFlavor(
        "text/plain;charset="+encoding
        +";class=java.io.InputStream", "Plain Text");
}
 
Example 18
Source File: DataFlavor.java    From JDKSourceCode1.8 with MIT License 3 votes vote down vote up
/**
 * Returns a <code>DataFlavor</code> representing plain text with Unicode
 * encoding, where:
 * <pre>
 *     representationClass = java.io.InputStream
 *     mimeType            = "text/plain;
 *                            charset=&lt;platform default Unicode encoding&gt;"
 * </pre>
 * Sun's implementation for Microsoft Windows uses the encoding <code>utf-16le</code>.
 * Sun's implementation for Solaris and Linux uses the encoding
 * <code>iso-10646-ucs-2</code>.
 *
 * @return a <code>DataFlavor</code> representing plain text
 *    with Unicode encoding
 * @since 1.3
 */
public static final DataFlavor getTextPlainUnicodeFlavor() {
    String encoding = null;
    DataTransferer transferer = DataTransferer.getInstance();
    if (transferer != null) {
        encoding = transferer.getDefaultUnicodeEncoding();
    }
    return new DataFlavor(
        "text/plain;charset="+encoding
        +";class=java.io.InputStream", "Plain Text");
}
 
Example 19
Source File: DataFlavor.java    From openjdk-8 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Returns a <code>DataFlavor</code> representing plain text with Unicode
 * encoding, where:
 * <pre>
 *     representationClass = java.io.InputStream
 *     mimeType            = "text/plain;
 *                            charset=&lt;platform default Unicode encoding&gt;"
 * </pre>
 * Sun's implementation for Microsoft Windows uses the encoding <code>utf-16le</code>.
 * Sun's implementation for Solaris and Linux uses the encoding
 * <code>iso-10646-ucs-2</code>.
 *
 * @return a <code>DataFlavor</code> representing plain text
 *    with Unicode encoding
 * @since 1.3
 */
public static final DataFlavor getTextPlainUnicodeFlavor() {
    String encoding = null;
    DataTransferer transferer = DataTransferer.getInstance();
    if (transferer != null) {
        encoding = transferer.getDefaultUnicodeEncoding();
    }
    return new DataFlavor(
        "text/plain;charset="+encoding
        +";class=java.io.InputStream", "Plain Text");
}
 
Example 20
Source File: DataFlavor.java    From openjdk-jdk8u with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Returns a <code>DataFlavor</code> representing plain text with Unicode
 * encoding, where:
 * <pre>
 *     representationClass = java.io.InputStream
 *     mimeType            = "text/plain;
 *                            charset=&lt;platform default Unicode encoding&gt;"
 * </pre>
 * Sun's implementation for Microsoft Windows uses the encoding <code>utf-16le</code>.
 * Sun's implementation for Solaris and Linux uses the encoding
 * <code>iso-10646-ucs-2</code>.
 *
 * @return a <code>DataFlavor</code> representing plain text
 *    with Unicode encoding
 * @since 1.3
 */
public static final DataFlavor getTextPlainUnicodeFlavor() {
    String encoding = null;
    DataTransferer transferer = DataTransferer.getInstance();
    if (transferer != null) {
        encoding = transferer.getDefaultUnicodeEncoding();
    }
    return new DataFlavor(
        "text/plain;charset="+encoding
        +";class=java.io.InputStream", "Plain Text");
}