javax.imageio.spi.IIORegistry#getDefaultInstance ( )源码实例Demo

下面列出了javax.imageio.spi.IIORegistry#getDefaultInstance ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: openjdk-jdk9   文件: OrderingTest.java
public OrderingTest() {

         ServiceRegistry reg = IIORegistry.getDefaultInstance();
         ImageReaderSpi gifSpi = (ImageReaderSpi) reg.getServiceProviderByClass(com.sun.imageio.plugins.gif.GIFImageReaderSpi.class);
         ImageReaderSpi pngSpi = (ImageReaderSpi) reg.getServiceProviderByClass(com.sun.imageio.plugins.png.PNGImageReaderSpi.class);

         boolean ordered = reg.setOrdering(ImageReaderSpi.class, gifSpi, pngSpi);

         ordered = reg.setOrdering(ImageReaderSpi.class, pngSpi, gifSpi);

         boolean unordered = reg.unsetOrdering(ImageReaderSpi.class, gifSpi,
                                               pngSpi);
         boolean unordered1 = reg.unsetOrdering(ImageReaderSpi.class, gifSpi,
                                                pngSpi);

         if (unordered1) {
             throw new RuntimeException("FAIL: Ordering 2 spi objects in the  "
                                        + "reverse direction does not remove the previous ordering "
                                        + "set between the spi objects and hence unsetOrdering() "
                                        + "returns true for the same spi objects when called consecutively");
         } else {
             System.out.println("PASS");
         }

     }
 
源代码2 项目: MyBox   文件: ImageValue.java
public static void registrySupportedImageFormats() {
        IIORegistry registry = IIORegistry.getDefaultInstance();
//        registry.registerServiceProvider(new TIFFImageWriterSpi());
//        registry.registerServiceProvider(new TIFFImageReaderSpi());
//        registry.registerServiceProvider(new BMPImageWriterSpi());
//        registry.registerServiceProvider(new BMPImageReaderSpi());
//        registry.registerServiceProvider(new GIFImageWriterSpi());
//        registry.registerServiceProvider(new WBMPImageWriterSpi());
//        registry.registerServiceProvider(new WBMPImageReaderSpi());

        registry.registerServiceProvider(new RawImageWriterSpi());
        registry.registerServiceProvider(new RawImageReaderSpi());
        registry.registerServiceProvider(new PCXImageWriterSpi());
        registry.registerServiceProvider(new PCXImageReaderSpi());
        registry.registerServiceProvider(new PNMImageWriterSpi());
        registry.registerServiceProvider(new PNMImageReaderSpi());
//        registry.registerServiceProvider(new J2KImageWriterSpi());
//        registry.registerServiceProvider(new J2KImageReaderSpi());

//        String readFormats[] = ImageIO.getReaderFormatNames();
//        String writeFormats[] = ImageIO.getWriterFormatNames();
//        logger.info("Readers:" + Arrays.asList(readFormats));
//        logger.info("Writers:" + Arrays.asList(writeFormats));
//Readers:[JPG, JPEG 2000, tiff, bmp, PCX, gif, WBMP, PNG, RAW, JPEG, PNM, tif, TIFF, wbmp, jpeg, jpg, JPEG2000, BMP, pcx, GIF, png, raw, pnm, TIF, jpeg2000, jpeg 2000]
//Writers:[JPEG 2000, JPG, tiff, bmp, PCX, gif, WBMP, PNG, RAW, JPEG, PNM, tif, TIFF, wbmp, jpeg, jpg, JPEG2000, BMP, pcx, GIF, png, raw, pnm, TIF, jpeg2000, jpeg 2000]
    }
 
源代码3 项目: snap-desktop   文件: SnapApp.java
private static void initImageIO() {
    // todo - actually this should be done in the activator of ceres-jai which does not exist yet
    Lookup.Result<ModuleInfo> moduleInfos = Lookup.getDefault().lookupResult(ModuleInfo.class);
    String ceresJaiCodeName = "org.esa.snap.ceres.jai";
    Optional<? extends ModuleInfo> info = moduleInfos.allInstances().stream().filter(
            moduleInfo -> ceresJaiCodeName.equals(moduleInfo.getCodeName())).findFirst();

    if (info.isPresent()) {
        ClassLoader classLoader = info.get().getClassLoader();
        IIORegistry iioRegistry = IIORegistry.getDefaultInstance();
        iioRegistry.registerServiceProviders(IIORegistry.lookupProviders(ImageReaderSpi.class, classLoader));
        iioRegistry.registerServiceProviders(IIORegistry.lookupProviders(ImageWriterSpi.class, classLoader));
    } else {
        LOG.warning(String.format("Module '%s' not found. Not able to load image-IO services.", ceresJaiCodeName));
    }
}
 
源代码4 项目: jdk8u_jdk   文件: OutputImageTests.java
private static void initIIOWriteFormats() {
    List spis = new ArrayList();
    List shortNames = new ArrayList();

    ImageIO.scanForPlugins();
    IIORegistry registry = IIORegistry.getDefaultInstance();
    java.util.Iterator writerspis =
        registry.getServiceProviders(ImageWriterSpi.class, false);
    while (writerspis.hasNext()) {
        // REMIND: there could be more than one non-core plugin for
        // a particular format, as is the case for JPEG2000 in the JAI
        // IIO Tools package, so we should support that somehow
        ImageWriterSpi spi = (ImageWriterSpi)writerspis.next();
        String klass = spi.getClass().getName();
        String format = spi.getFormatNames()[0].toLowerCase();
        String suffix = spi.getFileSuffixes()[0].toLowerCase();
        if (suffix == null || suffix.equals("")) {
            suffix = format;
        }
        String shortName;
        if (klass.startsWith("com.sun.imageio.plugins")) {
            shortName = "core-" + suffix;
        } else {
            shortName = "ext-" + suffix;
        }
        spis.add(spi);
        shortNames.add(shortName);
    }

    imageioWriterSpis = new ImageWriterSpi[spis.size()];
    imageioWriterSpis = (ImageWriterSpi[])spis.toArray(imageioWriterSpis);
    imageioWriteFormatShortNames = new String[shortNames.size()];
    imageioWriteFormatShortNames =
        (String[])shortNames.toArray(imageioWriteFormatShortNames);
}
 
源代码5 项目: openjdk-8-source   文件: OutputImageTests.java
private static void initIIOWriteFormats() {
    List spis = new ArrayList();
    List shortNames = new ArrayList();

    ImageIO.scanForPlugins();
    IIORegistry registry = IIORegistry.getDefaultInstance();
    java.util.Iterator writerspis =
        registry.getServiceProviders(ImageWriterSpi.class, false);
    while (writerspis.hasNext()) {
        // REMIND: there could be more than one non-core plugin for
        // a particular format, as is the case for JPEG2000 in the JAI
        // IIO Tools package, so we should support that somehow
        ImageWriterSpi spi = (ImageWriterSpi)writerspis.next();
        String klass = spi.getClass().getName();
        String format = spi.getFormatNames()[0].toLowerCase();
        String suffix = spi.getFileSuffixes()[0].toLowerCase();
        if (suffix == null || suffix.equals("")) {
            suffix = format;
        }
        String shortName;
        if (klass.startsWith("com.sun.imageio.plugins")) {
            shortName = "core-" + suffix;
        } else {
            shortName = "ext-" + suffix;
        }
        spis.add(spi);
        shortNames.add(shortName);
    }

    imageioWriterSpis = new ImageWriterSpi[spis.size()];
    imageioWriterSpis = (ImageWriterSpi[])spis.toArray(imageioWriterSpis);
    imageioWriteFormatShortNames = new String[shortNames.size()];
    imageioWriteFormatShortNames =
        (String[])shortNames.toArray(imageioWriteFormatShortNames);
}
 
源代码6 项目: hottub   文件: CanWriteSequence.java
public static void main(final String[] args) throws Exception {
    final IIORegistry registry = IIORegistry.getDefaultInstance();
    final Iterator<ImageWriterSpi> iter =
            registry.getServiceProviders(ImageWriterSpi.class,
                    provider -> true, true);
    // Validates all supported ImageWriters
    while (iter.hasNext()) {
        final ImageWriter writer = iter.next().createWriterInstance();
        System.out.println("ImageWriter = " + writer);
        test(writer);
    }
    System.out.println("Test passed");
}
 
源代码7 项目: dragonwell8_jdk   文件: WriteAfterAbort.java
public static void main(final String[] args) throws IOException {
    final IIORegistry registry = IIORegistry.getDefaultInstance();
    final Iterator<ImageWriterSpi> iter = registry.getServiceProviders(
            ImageWriterSpi.class, provider -> true, true);

    // Validates all supported ImageWriters
    while (iter.hasNext()) {
        final WriteAfterAbort writeAfterAbort = new WriteAfterAbort();
        final ImageWriter writer = iter.next().createWriterInstance();
        System.out.println("ImageWriter = " + writer);
        writeAfterAbort.test(writer);
    }
    System.out.println("Test passed");
}
 
源代码8 项目: openjdk-jdk9   文件: OutputImageTests.java
private static void initIIOWriteFormats() {
    List spis = new ArrayList();
    List shortNames = new ArrayList();

    ImageIO.scanForPlugins();
    IIORegistry registry = IIORegistry.getDefaultInstance();
    java.util.Iterator writerspis =
        registry.getServiceProviders(ImageWriterSpi.class, false);
    while (writerspis.hasNext()) {
        // REMIND: there could be more than one non-core plugin for
        // a particular format, as is the case for JPEG2000 in the JAI
        // IIO Tools package, so we should support that somehow
        ImageWriterSpi spi = (ImageWriterSpi)writerspis.next();
        String klass = spi.getClass().getName();
        String format = spi.getFormatNames()[0].toLowerCase();
        String suffix = spi.getFileSuffixes()[0].toLowerCase();
        if (suffix == null || suffix.equals("")) {
            suffix = format;
        }
        String shortName;
        if (klass.startsWith("com.sun.imageio.plugins")) {
            shortName = "core-" + suffix;
        } else {
            shortName = "ext-" + suffix;
        }
        spis.add(spi);
        shortNames.add(shortName);
    }

    imageioWriterSpis = new ImageWriterSpi[spis.size()];
    imageioWriterSpis = (ImageWriterSpi[])spis.toArray(imageioWriterSpis);
    imageioWriteFormatShortNames = new String[shortNames.size()];
    imageioWriteFormatShortNames =
        (String[])shortNames.toArray(imageioWriteFormatShortNames);
}
 
源代码9 项目: jdk8u-jdk   文件: InputImageTests.java
private static void initIIOReadFormats() {
    List spis = new ArrayList();
    List shortNames = new ArrayList();

    ImageIO.scanForPlugins();
    IIORegistry registry = IIORegistry.getDefaultInstance();
    java.util.Iterator readerspis =
        registry.getServiceProviders(ImageReaderSpi.class, false);
    while (readerspis.hasNext()) {
        // REMIND: there could be more than one non-core plugin for
        // a particular format, as is the case for JPEG2000 in the JAI
        // IIO Tools package, so we should support that somehow
        ImageReaderSpi spi = (ImageReaderSpi)readerspis.next();
        String klass = spi.getClass().getName();
        String format = spi.getFormatNames()[0].toLowerCase();
        String suffix = spi.getFileSuffixes()[0].toLowerCase();
        if (suffix == null || suffix.equals("")) {
            suffix = format;
        }
        String shortName;
        if (klass.startsWith("com.sun.imageio.plugins")) {
            shortName = "core-" + suffix;
        } else {
            shortName = "ext-" + suffix;
        }
        spis.add(spi);
        shortNames.add(shortName);
    }

    imageioReaderSpis = new ImageReaderSpi[spis.size()];
    imageioReaderSpis = (ImageReaderSpi[])spis.toArray(imageioReaderSpis);
    imageioReadFormatShortNames = new String[shortNames.size()];
    imageioReadFormatShortNames =
        (String[])shortNames.toArray(imageioReadFormatShortNames);
}
 
源代码10 项目: jdk8u_jdk   文件: InputImageTests.java
private static void initIIOReadFormats() {
    List spis = new ArrayList();
    List shortNames = new ArrayList();

    ImageIO.scanForPlugins();
    IIORegistry registry = IIORegistry.getDefaultInstance();
    java.util.Iterator readerspis =
        registry.getServiceProviders(ImageReaderSpi.class, false);
    while (readerspis.hasNext()) {
        // REMIND: there could be more than one non-core plugin for
        // a particular format, as is the case for JPEG2000 in the JAI
        // IIO Tools package, so we should support that somehow
        ImageReaderSpi spi = (ImageReaderSpi)readerspis.next();
        String klass = spi.getClass().getName();
        String format = spi.getFormatNames()[0].toLowerCase();
        String suffix = spi.getFileSuffixes()[0].toLowerCase();
        if (suffix == null || suffix.equals("")) {
            suffix = format;
        }
        String shortName;
        if (klass.startsWith("com.sun.imageio.plugins")) {
            shortName = "core-" + suffix;
        } else {
            shortName = "ext-" + suffix;
        }
        spis.add(spi);
        shortNames.add(shortName);
    }

    imageioReaderSpis = new ImageReaderSpi[spis.size()];
    imageioReaderSpis = (ImageReaderSpi[])spis.toArray(imageioReaderSpis);
    imageioReadFormatShortNames = new String[shortNames.size()];
    imageioReadFormatShortNames =
        (String[])shortNames.toArray(imageioReadFormatShortNames);
}
 
源代码11 项目: openjdk-jdk8u   文件: CanWriteSequence.java
public static void main(final String[] args) throws Exception {
    final IIORegistry registry = IIORegistry.getDefaultInstance();
    final Iterator<ImageWriterSpi> iter =
            registry.getServiceProviders(ImageWriterSpi.class,
                    provider -> true, true);
    // Validates all supported ImageWriters
    while (iter.hasNext()) {
        final ImageWriter writer = iter.next().createWriterInstance();
        System.out.println("ImageWriter = " + writer);
        test(writer);
    }
    System.out.println("Test passed");
}
 
源代码12 项目: openjdk-jdk8u-backup   文件: OutputImageTests.java
private static void initIIOWriteFormats() {
    List spis = new ArrayList();
    List shortNames = new ArrayList();

    ImageIO.scanForPlugins();
    IIORegistry registry = IIORegistry.getDefaultInstance();
    java.util.Iterator writerspis =
        registry.getServiceProviders(ImageWriterSpi.class, false);
    while (writerspis.hasNext()) {
        // REMIND: there could be more than one non-core plugin for
        // a particular format, as is the case for JPEG2000 in the JAI
        // IIO Tools package, so we should support that somehow
        ImageWriterSpi spi = (ImageWriterSpi)writerspis.next();
        String klass = spi.getClass().getName();
        String format = spi.getFormatNames()[0].toLowerCase();
        String suffix = spi.getFileSuffixes()[0].toLowerCase();
        if (suffix == null || suffix.equals("")) {
            suffix = format;
        }
        String shortName;
        if (klass.startsWith("com.sun.imageio.plugins")) {
            shortName = "core-" + suffix;
        } else {
            shortName = "ext-" + suffix;
        }
        spis.add(spi);
        shortNames.add(shortName);
    }

    imageioWriterSpis = new ImageWriterSpi[spis.size()];
    imageioWriterSpis = (ImageWriterSpi[])spis.toArray(imageioWriterSpis);
    imageioWriteFormatShortNames = new String[shortNames.size()];
    imageioWriteFormatShortNames =
        (String[])shortNames.toArray(imageioWriteFormatShortNames);
}
 
源代码13 项目: jdk8u60   文件: InputImageTests.java
private static void initIIOReadFormats() {
    List spis = new ArrayList();
    List shortNames = new ArrayList();

    ImageIO.scanForPlugins();
    IIORegistry registry = IIORegistry.getDefaultInstance();
    java.util.Iterator readerspis =
        registry.getServiceProviders(ImageReaderSpi.class, false);
    while (readerspis.hasNext()) {
        // REMIND: there could be more than one non-core plugin for
        // a particular format, as is the case for JPEG2000 in the JAI
        // IIO Tools package, so we should support that somehow
        ImageReaderSpi spi = (ImageReaderSpi)readerspis.next();
        String klass = spi.getClass().getName();
        String format = spi.getFormatNames()[0].toLowerCase();
        String suffix = spi.getFileSuffixes()[0].toLowerCase();
        if (suffix == null || suffix.equals("")) {
            suffix = format;
        }
        String shortName;
        if (klass.startsWith("com.sun.imageio.plugins")) {
            shortName = "core-" + suffix;
        } else {
            shortName = "ext-" + suffix;
        }
        spis.add(spi);
        shortNames.add(shortName);
    }

    imageioReaderSpis = new ImageReaderSpi[spis.size()];
    imageioReaderSpis = (ImageReaderSpi[])spis.toArray(imageioReaderSpis);
    imageioReadFormatShortNames = new String[shortNames.size()];
    imageioReadFormatShortNames =
        (String[])shortNames.toArray(imageioReadFormatShortNames);
}
 
源代码14 项目: jdk8u60   文件: OutputImageTests.java
private static void initIIOWriteFormats() {
    List spis = new ArrayList();
    List shortNames = new ArrayList();

    ImageIO.scanForPlugins();
    IIORegistry registry = IIORegistry.getDefaultInstance();
    java.util.Iterator writerspis =
        registry.getServiceProviders(ImageWriterSpi.class, false);
    while (writerspis.hasNext()) {
        // REMIND: there could be more than one non-core plugin for
        // a particular format, as is the case for JPEG2000 in the JAI
        // IIO Tools package, so we should support that somehow
        ImageWriterSpi spi = (ImageWriterSpi)writerspis.next();
        String klass = spi.getClass().getName();
        String format = spi.getFormatNames()[0].toLowerCase();
        String suffix = spi.getFileSuffixes()[0].toLowerCase();
        if (suffix == null || suffix.equals("")) {
            suffix = format;
        }
        String shortName;
        if (klass.startsWith("com.sun.imageio.plugins")) {
            shortName = "core-" + suffix;
        } else {
            shortName = "ext-" + suffix;
        }
        spis.add(spi);
        shortNames.add(shortName);
    }

    imageioWriterSpis = new ImageWriterSpi[spis.size()];
    imageioWriterSpis = (ImageWriterSpi[])spis.toArray(imageioWriterSpis);
    imageioWriteFormatShortNames = new String[shortNames.size()];
    imageioWriteFormatShortNames =
        (String[])shortNames.toArray(imageioWriteFormatShortNames);
}
 
源代码15 项目: jdk8u-jdk   文件: InputImageTests.java
private static void initIIOReadFormats() {
    List spis = new ArrayList();
    List shortNames = new ArrayList();

    ImageIO.scanForPlugins();
    IIORegistry registry = IIORegistry.getDefaultInstance();
    java.util.Iterator readerspis =
        registry.getServiceProviders(ImageReaderSpi.class, false);
    while (readerspis.hasNext()) {
        // REMIND: there could be more than one non-core plugin for
        // a particular format, as is the case for JPEG2000 in the JAI
        // IIO Tools package, so we should support that somehow
        ImageReaderSpi spi = (ImageReaderSpi)readerspis.next();
        String klass = spi.getClass().getName();
        String format = spi.getFormatNames()[0].toLowerCase();
        String suffix = spi.getFileSuffixes()[0].toLowerCase();
        if (suffix == null || suffix.equals("")) {
            suffix = format;
        }
        String shortName;
        if (klass.startsWith("com.sun.imageio.plugins")) {
            shortName = "core-" + suffix;
        } else {
            shortName = "ext-" + suffix;
        }
        spis.add(spi);
        shortNames.add(shortName);
    }

    imageioReaderSpis = new ImageReaderSpi[spis.size()];
    imageioReaderSpis = (ImageReaderSpi[])spis.toArray(imageioReaderSpis);
    imageioReadFormatShortNames = new String[shortNames.size()];
    imageioReadFormatShortNames =
        (String[])shortNames.toArray(imageioReadFormatShortNames);
}
 
源代码16 项目: jdk8u60   文件: WriteAfterAbort.java
public static void main(final String[] args) throws IOException {
    final IIORegistry registry = IIORegistry.getDefaultInstance();
    final Iterator<ImageWriterSpi> iter = registry.getServiceProviders(
            ImageWriterSpi.class, provider -> true, true);

    // Validates all supported ImageWriters
    while (iter.hasNext()) {
        final WriteAfterAbort writeAfterAbort = new WriteAfterAbort();
        final ImageWriter writer = iter.next().createWriterInstance();
        System.out.println("ImageWriter = " + writer);
        writeAfterAbort.test(writer);
    }
    System.out.println("Test passed");
}
 
源代码17 项目: openjdk-8   文件: InputImageTests.java
private static void initIIOReadFormats() {
    List spis = new ArrayList();
    List shortNames = new ArrayList();

    ImageIO.scanForPlugins();
    IIORegistry registry = IIORegistry.getDefaultInstance();
    java.util.Iterator readerspis =
        registry.getServiceProviders(ImageReaderSpi.class, false);
    while (readerspis.hasNext()) {
        // REMIND: there could be more than one non-core plugin for
        // a particular format, as is the case for JPEG2000 in the JAI
        // IIO Tools package, so we should support that somehow
        ImageReaderSpi spi = (ImageReaderSpi)readerspis.next();
        String klass = spi.getClass().getName();
        String format = spi.getFormatNames()[0].toLowerCase();
        String suffix = spi.getFileSuffixes()[0].toLowerCase();
        if (suffix == null || suffix.equals("")) {
            suffix = format;
        }
        String shortName;
        if (klass.startsWith("com.sun.imageio.plugins")) {
            shortName = "core-" + suffix;
        } else {
            shortName = "ext-" + suffix;
        }
        spis.add(spi);
        shortNames.add(shortName);
    }

    imageioReaderSpis = new ImageReaderSpi[spis.size()];
    imageioReaderSpis = (ImageReaderSpi[])spis.toArray(imageioReaderSpis);
    imageioReadFormatShortNames = new String[shortNames.size()];
    imageioReadFormatShortNames =
        (String[])shortNames.toArray(imageioReadFormatShortNames);
}
 
源代码18 项目: TencentKona-8   文件: RegisteredFormatsTest.java
public static void main(String[] args) {
    fmts = new Hashtable();

    fmts.put("javax_imageio_jpeg_stream_1.0", Boolean.FALSE);
    fmts.put("javax_imageio_jpeg_image_1.0",  Boolean.FALSE);
    fmts.put("javax_imageio_png_1.0",         Boolean.FALSE);
    fmts.put("javax_imageio_bmp_1.0",         Boolean.FALSE);
    fmts.put("javax_imageio_wbmp_1.0",        Boolean.FALSE);
    fmts.put("javax_imageio_gif_stream_1.0",  Boolean.FALSE);
    fmts.put("javax_imageio_gif_image_1.0",   Boolean.FALSE);

    IIORegistry registry = IIORegistry.getDefaultInstance();
    Iterator iter = registry.getServiceProviders(ImageReaderSpi.class,
                                                 false);
    while(iter.hasNext()) {
        ImageReaderSpi spi = (ImageReaderSpi)iter.next();
        String fmt_name;
        fmt_name = spi.getNativeStreamMetadataFormatName();
        testStreamMetadataFormat(spi, fmt_name);

        fmt_name = spi.getNativeImageMetadataFormatName();
        testImageMetadataFormat(spi, fmt_name);

        String[] fmt_names;
        fmt_names = spi.getExtraStreamMetadataFormatNames();
        for (int i=0; fmt_names != null && i < fmt_names.length; i++) {
            testStreamMetadataFormat(spi, fmt_names[i]);
        }

        fmt_names = spi.getExtraImageMetadataFormatNames();
        for (int i=0; fmt_names != null && i < fmt_names.length; i++) {
            testImageMetadataFormat(spi, fmt_names[i]);
        }
    }
    Enumeration keys = fmts.keys();
    while (keys.hasMoreElements()) {
        String key = (String)keys.nextElement();
        boolean val = ((Boolean)fmts.get(key)).booleanValue();
        if (!val) {
            throw new RuntimeException("Test failed: format " +
                                       key + "is not registered.");
        }
    }
}
 
源代码19 项目: jdk8u_jdk   文件: RegisteredFormatsTest.java
public static void main(String[] args) {
    fmts = new Hashtable();

    fmts.put("javax_imageio_jpeg_stream_1.0", Boolean.FALSE);
    fmts.put("javax_imageio_jpeg_image_1.0",  Boolean.FALSE);
    fmts.put("javax_imageio_png_1.0",         Boolean.FALSE);
    fmts.put("javax_imageio_bmp_1.0",         Boolean.FALSE);
    fmts.put("javax_imageio_wbmp_1.0",        Boolean.FALSE);
    fmts.put("javax_imageio_gif_stream_1.0",  Boolean.FALSE);
    fmts.put("javax_imageio_gif_image_1.0",   Boolean.FALSE);

    IIORegistry registry = IIORegistry.getDefaultInstance();
    Iterator iter = registry.getServiceProviders(ImageReaderSpi.class,
                                                 false);
    while(iter.hasNext()) {
        ImageReaderSpi spi = (ImageReaderSpi)iter.next();
        String fmt_name;
        fmt_name = spi.getNativeStreamMetadataFormatName();
        testStreamMetadataFormat(spi, fmt_name);

        fmt_name = spi.getNativeImageMetadataFormatName();
        testImageMetadataFormat(spi, fmt_name);

        String[] fmt_names;
        fmt_names = spi.getExtraStreamMetadataFormatNames();
        for (int i=0; fmt_names != null && i < fmt_names.length; i++) {
            testStreamMetadataFormat(spi, fmt_names[i]);
        }

        fmt_names = spi.getExtraImageMetadataFormatNames();
        for (int i=0; fmt_names != null && i < fmt_names.length; i++) {
            testImageMetadataFormat(spi, fmt_names[i]);
        }
    }
    Enumeration keys = fmts.keys();
    while (keys.hasMoreElements()) {
        String key = (String)keys.nextElement();
        boolean val = ((Boolean)fmts.get(key)).booleanValue();
        if (!val) {
            throw new RuntimeException("Test failed: format " +
                                       key + "is not registered.");
        }
    }
}
 
源代码20 项目: jdk8u-jdk   文件: RegisteredFormatsTest.java
public static void main(String[] args) {
    fmts = new Hashtable();

    fmts.put("javax_imageio_jpeg_stream_1.0", Boolean.FALSE);
    fmts.put("javax_imageio_jpeg_image_1.0",  Boolean.FALSE);
    fmts.put("javax_imageio_png_1.0",         Boolean.FALSE);
    fmts.put("javax_imageio_bmp_1.0",         Boolean.FALSE);
    fmts.put("javax_imageio_wbmp_1.0",        Boolean.FALSE);
    fmts.put("javax_imageio_gif_stream_1.0",  Boolean.FALSE);
    fmts.put("javax_imageio_gif_image_1.0",   Boolean.FALSE);

    IIORegistry registry = IIORegistry.getDefaultInstance();
    Iterator iter = registry.getServiceProviders(ImageReaderSpi.class,
                                                 false);
    while(iter.hasNext()) {
        ImageReaderSpi spi = (ImageReaderSpi)iter.next();
        String fmt_name;
        fmt_name = spi.getNativeStreamMetadataFormatName();
        testStreamMetadataFormat(spi, fmt_name);

        fmt_name = spi.getNativeImageMetadataFormatName();
        testImageMetadataFormat(spi, fmt_name);

        String[] fmt_names;
        fmt_names = spi.getExtraStreamMetadataFormatNames();
        for (int i=0; fmt_names != null && i < fmt_names.length; i++) {
            testStreamMetadataFormat(spi, fmt_names[i]);
        }

        fmt_names = spi.getExtraImageMetadataFormatNames();
        for (int i=0; fmt_names != null && i < fmt_names.length; i++) {
            testImageMetadataFormat(spi, fmt_names[i]);
        }
    }
    Enumeration keys = fmts.keys();
    while (keys.hasMoreElements()) {
        String key = (String)keys.nextElement();
        boolean val = ((Boolean)fmts.get(key)).booleanValue();
        if (!val) {
            throw new RuntimeException("Test failed: format " +
                                       key + "is not registered.");
        }
    }
}