Java Code Examples for javax.imageio.spi.ImageReaderSpi#getImageWriterSpiNames()

The following examples show how to use javax.imageio.spi.ImageReaderSpi#getImageWriterSpiNames() . 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: SpiTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public void testSpi(ImageReaderSpi spi) {
    testSpi((ImageReaderWriterSpi)spi);
    Class[] inputTypes = spi.getInputTypes();
    if (inputTypes == null) {
        error("inputTypes == null!");
    }
    if (inputTypes.length == 0) {
        error("inputTypes.length == 0!");
    }
    String[] writerSpiNames = spi.getImageWriterSpiNames();
    if (writerSpiNames != null && writerSpiNames.length == 0) {
        error("writerSpiNames.length == 0!");
    }
}
 
Example 2
Source File: SpiTest.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
public void testSpi(ImageReaderSpi spi) {
    testSpi((ImageReaderWriterSpi)spi);
    Class[] inputTypes = spi.getInputTypes();
    if (inputTypes == null) {
        error("inputTypes == null!");
    }
    if (inputTypes.length == 0) {
        error("inputTypes.length == 0!");
    }
    String[] writerSpiNames = spi.getImageWriterSpiNames();
    if (writerSpiNames != null && writerSpiNames.length == 0) {
        error("writerSpiNames.length == 0!");
    }
}
 
Example 3
Source File: SpiTest.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public void testImageReaderSpiConstructor() {
    resetConstructorArguments();

    checkImageReaderSpiConstructor(true);
    vendorName = "My Vendor";
    checkImageReaderSpiConstructor(true);
    version = "My Version";
    checkImageReaderSpiConstructor(true);
    names = new String[0];
    checkImageReaderSpiConstructor(true);
    names = new String[1];
    names[0] = "My Format Name";
    checkImageReaderSpiConstructor(true);
    readerClassName = "com.mycompany.Reader";
    checkImageReaderSpiConstructor(true);
    inputTypes = new Class[0];
    checkImageReaderSpiConstructor(true);
    inputTypes = new Class[1];
    inputTypes[0] = Object.class;
    // Now it should work
    checkImageReaderSpiConstructor(false);

    // Test normalization of zero-length arrays
    suffixes = new String[0];
    MIMETypes = new String[0];
    writerSpiNames = new String[0];
    extraStreamMetadataFormatNames = new String[0];
    extraImageMetadataFormatNames = new String[0];

    ImageReaderSpi spi = constructImageReaderSpi();
    if (spi.getFileSuffixes() != null) {
        error("Failed to normalize suffixes!");
    }
    if (spi.getMIMETypes() != null) {
        error("Failed to normalize MIMETypes!");
    }
    if (spi.getImageWriterSpiNames() != null) {
        error("Failed to normalize writerSpiNames!");
    }
    if (spi.getExtraStreamMetadataFormatNames() != null) {
        error("Failed to normalize extraStreamMetadataFormatNames!");
    }
    if (spi.getExtraImageMetadataFormatNames() != null) {
        error("Failed to normalize extraImageMetadataFormatNames!");
    }
}
 
Example 4
Source File: PluginSpiTest.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public static void testFormat(String format) {
    ImageReader reader =
        ImageIO.getImageReadersByFormatName(format).next();
    if (reader == null) {
        throw new RuntimeException("Failed to get reader for " + format);
    }

    ImageReaderSpi readerSpi = reader.getOriginatingProvider();
    System.out.println(format + " Reader SPI: " + readerSpi);

    String writerSpiNames[] = readerSpi.getImageWriterSpiNames();
    if (writerSpiNames == null || writerSpiNames.length == 0) {
        throw new RuntimeException("Failed to get writer spi names for " +
                                   format);
    }

    System.out.println("Available writer spi names:");
    for (int i = 0; i < writerSpiNames.length; i++) {
        System.out.println(writerSpiNames[i]);
        try {
            Class spiClass = Class.forName(writerSpiNames[i]);
            if (spiClass == null) {
                throw new RuntimeException("Failed to get spi class " +
                                           writerSpiNames[i]);
            }
            System.out.println("Got class " + spiClass.getName());

            Object spiObject = spiClass.newInstance();
            if (spiObject == null) {
                throw new RuntimeException("Failed to instantiate spi " +
                                           writerSpiNames[i]);
            }
            System.out.println("Got instance " + spiObject);
        } catch (Throwable e) {
            throw new RuntimeException("Failed to test spi " +
                                       writerSpiNames[i]);
        }
    }

    ImageWriter writer = ImageIO.getImageWriter(reader);
    if (writer == null) {
        throw new RuntimeException("Failed to get writer for " + format);
    }
}
 
Example 5
Source File: SpiTest.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
public void testImageReaderSpiConstructor() {
    resetConstructorArguments();

    checkImageReaderSpiConstructor(true);
    vendorName = "My Vendor";
    checkImageReaderSpiConstructor(true);
    version = "My Version";
    checkImageReaderSpiConstructor(true);
    names = new String[0];
    checkImageReaderSpiConstructor(true);
    names = new String[1];
    names[0] = "My Format Name";
    checkImageReaderSpiConstructor(true);
    readerClassName = "com.mycompany.Reader";
    checkImageReaderSpiConstructor(true);
    inputTypes = new Class[0];
    checkImageReaderSpiConstructor(true);
    inputTypes = new Class[1];
    inputTypes[0] = Object.class;
    // Now it should work
    checkImageReaderSpiConstructor(false);

    // Test normalization of zero-length arrays
    suffixes = new String[0];
    MIMETypes = new String[0];
    writerSpiNames = new String[0];
    extraStreamMetadataFormatNames = new String[0];
    extraImageMetadataFormatNames = new String[0];

    ImageReaderSpi spi = constructImageReaderSpi();
    if (spi.getFileSuffixes() != null) {
        error("Failed to normalize suffixes!");
    }
    if (spi.getMIMETypes() != null) {
        error("Failed to normalize MIMETypes!");
    }
    if (spi.getImageWriterSpiNames() != null) {
        error("Failed to normalize writerSpiNames!");
    }
    if (spi.getExtraStreamMetadataFormatNames() != null) {
        error("Failed to normalize extraStreamMetadataFormatNames!");
    }
    if (spi.getExtraImageMetadataFormatNames() != null) {
        error("Failed to normalize extraImageMetadataFormatNames!");
    }
}
 
Example 6
Source File: PluginSpiTest.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
public static void testFormat(String format) {
    ImageReader reader =
        ImageIO.getImageReadersByFormatName(format).next();
    if (reader == null) {
        throw new RuntimeException("Failed to get reader for " + format);
    }

    ImageReaderSpi readerSpi = reader.getOriginatingProvider();
    System.out.println(format + " Reader SPI: " + readerSpi);

    String writerSpiNames[] = readerSpi.getImageWriterSpiNames();
    if (writerSpiNames == null || writerSpiNames.length == 0) {
        throw new RuntimeException("Failed to get writer spi names for " +
                                   format);
    }

    System.out.println("Available writer spi names:");
    for (int i = 0; i < writerSpiNames.length; i++) {
        System.out.println(writerSpiNames[i]);
        try {
            Class spiClass = Class.forName(writerSpiNames[i]);
            if (spiClass == null) {
                throw new RuntimeException("Failed to get spi class " +
                                           writerSpiNames[i]);
            }
            System.out.println("Got class " + spiClass.getName());

            Object spiObject = spiClass.newInstance();
            if (spiObject == null) {
                throw new RuntimeException("Failed to instantiate spi " +
                                           writerSpiNames[i]);
            }
            System.out.println("Got instance " + spiObject);
        } catch (Throwable e) {
            throw new RuntimeException("Failed to test spi " +
                                       writerSpiNames[i]);
        }
    }

    ImageWriter writer = ImageIO.getImageWriter(reader);
    if (writer == null) {
        throw new RuntimeException("Failed to get writer for " + format);
    }
}