java.awt.datatransfer.SystemFlavorMap#getNativesForFlavor ( )源码实例Demo

下面列出了java.awt.datatransfer.SystemFlavorMap#getNativesForFlavor ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: dragonwell8_jdk   文件: ImageTransferTest.java
static String[] retrieveFormatsToTest() {
    SystemFlavorMap sfm = (SystemFlavorMap) SystemFlavorMap.getDefaultFlavorMap();
    java.util.List<String> ln = sfm.getNativesForFlavor(DataFlavor.imageFlavor);
    if (OSInfo.OSType.WINDOWS.equals(OSInfo.getOSType()) && !ln.contains("METAFILEPICT")) {
        // for test failing on JDK without this fix
        ln.add("METAFILEPICT");
    }
    return ln.toArray(new String[ln.size()]);
}
 
源代码2 项目: TencentKona-8   文件: ImageTransferTest.java
static String[] retrieveFormatsToTest() {
    SystemFlavorMap sfm = (SystemFlavorMap) SystemFlavorMap.getDefaultFlavorMap();
    java.util.List<String> ln = sfm.getNativesForFlavor(DataFlavor.imageFlavor);
    if (OSInfo.OSType.WINDOWS.equals(OSInfo.getOSType()) && !ln.contains("METAFILEPICT")) {
        // for test failing on JDK without this fix
        ln.add("METAFILEPICT");
    }
    return ln.toArray(new String[ln.size()]);
}
 
源代码3 项目: openjdk-jdk8u   文件: ImageTransferTest.java
static String[] retrieveFormatsToTest() {
    SystemFlavorMap sfm = (SystemFlavorMap) SystemFlavorMap.getDefaultFlavorMap();
    java.util.List<String> ln = sfm.getNativesForFlavor(DataFlavor.imageFlavor);
    if (OSInfo.OSType.WINDOWS.equals(OSInfo.getOSType()) && !ln.contains("METAFILEPICT")) {
        // for test failing on JDK without this fix
        ln.add("METAFILEPICT");
    }
    return ln.toArray(new String[ln.size()]);
}
 
源代码4 项目: openjdk-jdk8u-backup   文件: ImageTransferTest.java
static String[] retrieveFormatsToTest() {
    SystemFlavorMap sfm = (SystemFlavorMap) SystemFlavorMap.getDefaultFlavorMap();
    java.util.List<String> ln = sfm.getNativesForFlavor(DataFlavor.imageFlavor);
    if (OSInfo.OSType.WINDOWS.equals(OSInfo.getOSType()) && !ln.contains("METAFILEPICT")) {
        // for test failing on JDK without this fix
        ln.add("METAFILEPICT");
    }
    return ln.toArray(new String[ln.size()]);
}
 
源代码5 项目: openjdk-jdk9   文件: GetNativesForNewFlavorTest.java
public void doTest() throws Exception {
    // Initialize DataFlavors and arrays used for test data
    initMappings();

    boolean passed = true;
    flavorMap = (SystemFlavorMap)SystemFlavorMap.getDefaultFlavorMap();

    // Get all the native strings and preferred DataFlavor mappings
    hash = new Hashtable(flavorMap.getFlavorsForNatives(null));
    hashSize = hash.size();

    // GetNativesForFlavor using unknown DataFlavor (verify 2-way mapping)
    //
    // If a new DataFlavor is specified, the method should establish a mapping
    // in both directions between specified DataFlavor and an encoded
    // version of its MIME type as its native.
    System.out.println("GetNativesForFlavor using new DataFlavor");

    comp1 = new Vector(Arrays.asList(test_natives_set));
    comp2 = new Vector(flavorMap.getNativesForFlavor(test_flavor1));

    comp3 = new Vector(Arrays.asList(test_flavors_set));
    comp4 = new Vector(flavorMap.getFlavorsForNative(test_encoded));

    if ( !comp1.equals(comp2) || !comp3.equals(comp4) ) {
        throw new RuntimeException("\n*** After passing a new DataFlavor" +
            "\nwith getNativesForFlavor(DataFlavor flav)" +
            "\nthe mapping in both directions was not established.");
    }
    else
       System.out.println("GetNativesForFlavor using new DataFlavor: Test Passes");
}
 
源代码6 项目: openjdk-jdk9   文件: SetNativesForFlavorTest.java
public static void main(String[] args) throws Exception {
        final String nativeString = "NATIVE";

        final SystemFlavorMap fm =
            (SystemFlavorMap)SystemFlavorMap.getDefaultFlavorMap();

        fm.setNativesForFlavor(DataFlavor.plainTextFlavor,
                               new String[] { nativeString });

        final java.util.List natives =
            fm.getNativesForFlavor(DataFlavor.plainTextFlavor);

        if (natives.size() != 1 || !natives.contains(nativeString)) {
            throw new RuntimeException("getNativesForFlavor() returns:" +
                                       natives);
        }

        final DataFlavor dataFlavor =
            new DataFlavor("text/unknown; class=java.lang.String");

        fm.setFlavorsForNative(nativeString, new DataFlavor[] { dataFlavor });

        final java.util.List flavors = fm.getFlavorsForNative(nativeString);

        if (flavors.size() != 1 || !flavors.contains(dataFlavor)) {
            throw new RuntimeException("getFlavorsForNative() returns:" +
                                       flavors);
        }
}
 
源代码7 项目: openjdk-jdk9   文件: ManyFlavorMapTest.java
public void doTest() {
    flavorMap = (SystemFlavorMap)SystemFlavorMap.getDefaultFlavorMap();

    // Get SystemFlavorMap Maps of String Natives and DataFlavors
    mapFlavors = flavorMap.getNativesForFlavors(null);
    mapNatives = flavorMap.getFlavorsForNatives(null);

    hashFlavors = new Hashtable(mapFlavors);
    hashNatives = new Hashtable(mapNatives);

    // Assertion: Verify getNativesForFlavors(null) is returning the full list
    //            of String Native entries
    List listNatives = flavorMap.getNativesForFlavor(null);
    verifyListAllNativeEntries(listNatives);

    // Assertion: Verify getFlavorsForNatives(null) is returning the full list
    //            of DataFlavor entries
    List listFlavors = flavorMap.getFlavorsForNative(null);
    verifyListAllDataFlavorEntries(listFlavors);

    // Assertion: Verify getNativesForFlavor(DataFlavor flav) is returning the list
    //            of Native Strings (for all supported DataFlavors)
    //
    //            Verify that the first list item is the most preferred Native
    verifyListNativeEntries();

    // Assertion: Verify getFlavorsForNative(String nat) is returning the list
    //            of DataFlavors(for all supported natives)
    //
    //            Verify that the first list item is the most preferred DataFlavor
    verifyListDataFlavorEntries();
}
 
源代码8 项目: openjdk-jdk9   文件: ImageTransferTest.java
static String[] retrieveFormatsToTest() {
    SystemFlavorMap sfm = (SystemFlavorMap) SystemFlavorMap.getDefaultFlavorMap();
    java.util.List<String> ln = sfm.getNativesForFlavor(DataFlavor.imageFlavor);
    if (OSInfo.OSType.WINDOWS.equals(OSInfo.getOSType()) && !ln.contains("METAFILEPICT")) {
        // for test failing on JDK without this fix
        ln.add("METAFILEPICT");
    }
    return ln.toArray(new String[ln.size()]);
}
 
源代码9 项目: jdk8u-jdk   文件: ImageTransferTest.java
static String[] retrieveFormatsToTest() {
    SystemFlavorMap sfm = (SystemFlavorMap) SystemFlavorMap.getDefaultFlavorMap();
    java.util.List<String> ln = sfm.getNativesForFlavor(DataFlavor.imageFlavor);
    if (OSInfo.OSType.WINDOWS.equals(OSInfo.getOSType()) && !ln.contains("METAFILEPICT")) {
        // for test failing on JDK without this fix
        ln.add("METAFILEPICT");
    }
    return ln.toArray(new String[ln.size()]);
}
 
源代码10 项目: hottub   文件: ImageTransferTest.java
static String[] retrieveFormatsToTest() {
    SystemFlavorMap sfm = (SystemFlavorMap) SystemFlavorMap.getDefaultFlavorMap();
    java.util.List<String> ln = sfm.getNativesForFlavor(DataFlavor.imageFlavor);
    if (OSInfo.OSType.WINDOWS.equals(OSInfo.getOSType()) && !ln.contains("METAFILEPICT")) {
        // for test failing on JDK without this fix
        ln.add("METAFILEPICT");
    }
    return ln.toArray(new String[ln.size()]);
}
 
源代码11 项目: jdk8u_jdk   文件: ImageTransferTest.java
static String[] retrieveFormatsToTest() {
    SystemFlavorMap sfm = (SystemFlavorMap) SystemFlavorMap.getDefaultFlavorMap();
    java.util.List<String> ln = sfm.getNativesForFlavor(DataFlavor.imageFlavor);
    if (OSInfo.OSType.WINDOWS.equals(OSInfo.getOSType()) && !ln.contains("METAFILEPICT")) {
        // for test failing on JDK without this fix
        ln.add("METAFILEPICT");
    }
    return ln.toArray(new String[ln.size()]);
}
 
源代码12 项目: openjdk-jdk9   文件: DuplicateMappingTest.java
public static void main(String[] args) throws Exception {

        final String nativeString = "NATIVE";
        final DataFlavor dataFlavor = new DataFlavor();

        final SystemFlavorMap fm =
                (SystemFlavorMap) SystemFlavorMap.getDefaultFlavorMap();

        fm.addUnencodedNativeForFlavor(dataFlavor, nativeString);
        fm.addUnencodedNativeForFlavor(dataFlavor, nativeString);

        final java.util.List natives =
                fm.getNativesForFlavor(dataFlavor);
        boolean found = false;

        for (final Iterator i = natives.iterator(); i.hasNext(); ) {
            if (nativeString.equals(i.next())) {
                if (found) {
                    throw new RuntimeException("getNativesForFlavor() returns:" +
                            natives);
                } else {
                    found = true;
                }
            }
        }

        if (!found) {
            throw new RuntimeException("getNativesForFlavor() returns:" +
                    natives);
        }

        fm.addFlavorForUnencodedNative(nativeString, dataFlavor);
        fm.addFlavorForUnencodedNative(nativeString, dataFlavor);

        final java.util.List flavors =
                fm.getFlavorsForNative(nativeString);
        found = false;

        for (final Iterator i = flavors.iterator(); i.hasNext(); ) {
            if (dataFlavor.equals(i.next())) {
                if (found) {
                    throw new RuntimeException("getFlavorsForNative() returns:" +
                            flavors);
                } else {
                    found = true;
                }
            }
        }

        if (!found) {
            throw new RuntimeException("getFlavorsForNative() returns:" +
                    natives);
        }
    }