src/share/classes/javax/imageio/ImageIO.java

Print this page
rev 9344 : 8034998: Fix raw and unchecked lint warnings in javax.imageio
Reviewed-by: darcy, prr

*** 337,347 **** throws IOException { if (input == null) { throw new IllegalArgumentException("input == null!"); } ! Iterator iter; // Ensure category is present try { iter = theRegistry.getServiceProviders(ImageInputStreamSpi.class, true); } catch (IllegalArgumentException e) { --- 337,347 ---- throws IOException { if (input == null) { throw new IllegalArgumentException("input == null!"); } ! Iterator<ImageInputStreamSpi> iter; // Ensure category is present try { iter = theRegistry.getServiceProviders(ImageInputStreamSpi.class, true); } catch (IllegalArgumentException e) {
*** 349,359 **** } boolean usecache = getUseCache() && hasCachePermission(); while (iter.hasNext()) { ! ImageInputStreamSpi spi = (ImageInputStreamSpi)iter.next(); if (spi.getInputClass().isInstance(input)) { try { return spi.createInputStreamInstance(input, usecache, getCacheDirectory()); --- 349,359 ---- } boolean usecache = getUseCache() && hasCachePermission(); while (iter.hasNext()) { ! ImageInputStreamSpi spi = iter.next(); if (spi.getInputClass().isInstance(input)) { try { return spi.createInputStreamInstance(input, usecache, getCacheDirectory());
*** 399,409 **** throws IOException { if (output == null) { throw new IllegalArgumentException("output == null!"); } ! Iterator iter; // Ensure category is present try { iter = theRegistry.getServiceProviders(ImageOutputStreamSpi.class, true); } catch (IllegalArgumentException e) { --- 399,409 ---- throws IOException { if (output == null) { throw new IllegalArgumentException("output == null!"); } ! Iterator<ImageOutputStreamSpi> iter; // Ensure category is present try { iter = theRegistry.getServiceProviders(ImageOutputStreamSpi.class, true); } catch (IllegalArgumentException e) {
*** 411,421 **** } boolean usecache = getUseCache() && hasCachePermission(); while (iter.hasNext()) { ! ImageOutputStreamSpi spi = (ImageOutputStreamSpi)iter.next(); if (spi.getOutputClass().isInstance(output)) { try { return spi.createOutputStreamInstance(output, usecache, getCacheDirectory()); --- 411,421 ---- } boolean usecache = getUseCache() && hasCachePermission(); while (iter.hasNext()) { ! ImageOutputStreamSpi spi = iter.next(); if (spi.getOutputClass().isInstance(output)) { try { return spi.createOutputStreamInstance(output, usecache, getCacheDirectory());
*** 510,533 **** SpiInfo.FILE_SUFFIXES); } static class ImageReaderIterator implements Iterator<ImageReader> { // Contains ImageReaderSpis ! public Iterator iter; ! public ImageReaderIterator(Iterator iter) { this.iter = iter; } public boolean hasNext() { return iter.hasNext(); } public ImageReader next() { ImageReaderSpi spi = null; try { ! spi = (ImageReaderSpi)iter.next(); return spi.createReaderInstance(); } catch (IOException e) { // Deregister the spi in this case, but only as // an ImageReaderSpi theRegistry.deregisterServiceProvider(spi, ImageReaderSpi.class); --- 510,533 ---- SpiInfo.FILE_SUFFIXES); } static class ImageReaderIterator implements Iterator<ImageReader> { // Contains ImageReaderSpis ! private Iterator<ImageReaderSpi> iter; ! public ImageReaderIterator(Iterator<ImageReaderSpi> iter) { this.iter = iter; } public boolean hasNext() { return iter.hasNext(); } public ImageReader next() { ImageReaderSpi spi = null; try { ! spi = iter.next(); return spi.createReaderInstance(); } catch (IOException e) { // Deregister the spi in this case, but only as // an ImageReaderSpi theRegistry.deregisterServiceProvider(spi, ImageReaderSpi.class);
*** 638,648 **** */ public static Iterator<ImageReader> getImageReaders(Object input) { if (input == null) { throw new IllegalArgumentException("input == null!"); } ! Iterator iter; // Ensure category is present try { iter = theRegistry.getServiceProviders(ImageReaderSpi.class, new CanDecodeInputFilter(input), true); --- 638,648 ---- */ public static Iterator<ImageReader> getImageReaders(Object input) { if (input == null) { throw new IllegalArgumentException("input == null!"); } ! Iterator<ImageReaderSpi> iter; // Ensure category is present try { iter = theRegistry.getServiceProviders(ImageReaderSpi.class, new CanDecodeInputFilter(input), true);
*** 700,710 **** getImageReadersByFormatName(String formatName) { if (formatName == null) { throw new IllegalArgumentException("formatName == null!"); } ! Iterator iter; // Ensure category is present try { iter = theRegistry.getServiceProviders(ImageReaderSpi.class, new ContainsFilter(readerFormatNamesMethod, formatName), --- 700,710 ---- getImageReadersByFormatName(String formatName) { if (formatName == null) { throw new IllegalArgumentException("formatName == null!"); } ! Iterator<ImageReaderSpi> iter; // Ensure category is present try { iter = theRegistry.getServiceProviders(ImageReaderSpi.class, new ContainsFilter(readerFormatNamesMethod, formatName),
*** 736,746 **** { if (fileSuffix == null) { throw new IllegalArgumentException("fileSuffix == null!"); } // Ensure category is present ! Iterator iter; try { iter = theRegistry.getServiceProviders(ImageReaderSpi.class, new ContainsFilter(readerFileSuffixesMethod, fileSuffix), true); --- 736,746 ---- { if (fileSuffix == null) { throw new IllegalArgumentException("fileSuffix == null!"); } // Ensure category is present ! Iterator<ImageReaderSpi> iter; try { iter = theRegistry.getServiceProviders(ImageReaderSpi.class, new ContainsFilter(readerFileSuffixesMethod, fileSuffix), true);
*** 771,781 **** { if (MIMEType == null) { throw new IllegalArgumentException("MIMEType == null!"); } // Ensure category is present ! Iterator iter; try { iter = theRegistry.getServiceProviders(ImageReaderSpi.class, new ContainsFilter(readerMIMETypesMethod, MIMEType), true); --- 771,781 ---- { if (MIMEType == null) { throw new IllegalArgumentException("MIMEType == null!"); } // Ensure category is present ! Iterator<ImageReaderSpi> iter; try { iter = theRegistry.getServiceProviders(ImageReaderSpi.class, new ContainsFilter(readerMIMETypesMethod, MIMEType), true);
*** 824,847 **** SpiInfo.FILE_SUFFIXES); } static class ImageWriterIterator implements Iterator<ImageWriter> { // Contains ImageWriterSpis ! public Iterator iter; ! public ImageWriterIterator(Iterator iter) { this.iter = iter; } public boolean hasNext() { return iter.hasNext(); } public ImageWriter next() { ImageWriterSpi spi = null; try { ! spi = (ImageWriterSpi)iter.next(); return spi.createWriterInstance(); } catch (IOException e) { // Deregister the spi in this case, but only as a writerSpi theRegistry.deregisterServiceProvider(spi, ImageWriterSpi.class); } --- 824,847 ---- SpiInfo.FILE_SUFFIXES); } static class ImageWriterIterator implements Iterator<ImageWriter> { // Contains ImageWriterSpis ! private Iterator<ImageWriterSpi> iter; ! public ImageWriterIterator(Iterator<ImageWriterSpi> iter) { this.iter = iter; } public boolean hasNext() { return iter.hasNext(); } public ImageWriter next() { ImageWriterSpi spi = null; try { ! spi = iter.next(); return spi.createWriterInstance(); } catch (IOException e) { // Deregister the spi in this case, but only as a writerSpi theRegistry.deregisterServiceProvider(spi, ImageWriterSpi.class); }
*** 883,893 **** getImageWritersByFormatName(String formatName) { if (formatName == null) { throw new IllegalArgumentException("formatName == null!"); } ! Iterator iter; // Ensure category is present try { iter = theRegistry.getServiceProviders(ImageWriterSpi.class, new ContainsFilter(writerFormatNamesMethod, formatName), --- 883,893 ---- getImageWritersByFormatName(String formatName) { if (formatName == null) { throw new IllegalArgumentException("formatName == null!"); } ! Iterator<ImageWriterSpi> iter; // Ensure category is present try { iter = theRegistry.getServiceProviders(ImageWriterSpi.class, new ContainsFilter(writerFormatNamesMethod, formatName),
*** 917,927 **** getImageWritersBySuffix(String fileSuffix) { if (fileSuffix == null) { throw new IllegalArgumentException("fileSuffix == null!"); } ! Iterator iter; // Ensure category is present try { iter = theRegistry.getServiceProviders(ImageWriterSpi.class, new ContainsFilter(writerFileSuffixesMethod, fileSuffix), --- 917,927 ---- getImageWritersBySuffix(String fileSuffix) { if (fileSuffix == null) { throw new IllegalArgumentException("fileSuffix == null!"); } ! Iterator<ImageWriterSpi> iter; // Ensure category is present try { iter = theRegistry.getServiceProviders(ImageWriterSpi.class, new ContainsFilter(writerFileSuffixesMethod, fileSuffix),
*** 951,961 **** getImageWritersByMIMEType(String MIMEType) { if (MIMEType == null) { throw new IllegalArgumentException("MIMEType == null!"); } ! Iterator iter; // Ensure category is present try { iter = theRegistry.getServiceProviders(ImageWriterSpi.class, new ContainsFilter(writerMIMETypesMethod, MIMEType), --- 951,961 ---- getImageWritersByMIMEType(String MIMEType) { if (MIMEType == null) { throw new IllegalArgumentException("MIMEType == null!"); } ! Iterator<ImageWriterSpi> iter; // Ensure category is present try { iter = theRegistry.getServiceProviders(ImageWriterSpi.class, new ContainsFilter(writerMIMETypesMethod, MIMEType),
*** 1000,1021 **** throw new IllegalArgumentException("reader == null!"); } ImageReaderSpi readerSpi = reader.getOriginatingProvider(); if (readerSpi == null) { ! Iterator readerSpiIter; // Ensure category is present try { readerSpiIter = theRegistry.getServiceProviders(ImageReaderSpi.class, false); } catch (IllegalArgumentException e) { return null; } while (readerSpiIter.hasNext()) { ! ImageReaderSpi temp = (ImageReaderSpi) readerSpiIter.next(); if (temp.isOwnReader(reader)) { readerSpi = temp; break; } } --- 1000,1021 ---- throw new IllegalArgumentException("reader == null!"); } ImageReaderSpi readerSpi = reader.getOriginatingProvider(); if (readerSpi == null) { ! Iterator<ImageReaderSpi> readerSpiIter; // Ensure category is present try { readerSpiIter = theRegistry.getServiceProviders(ImageReaderSpi.class, false); } catch (IllegalArgumentException e) { return null; } while (readerSpiIter.hasNext()) { ! ImageReaderSpi temp = readerSpiIter.next(); if (temp.isOwnReader(reader)) { readerSpi = temp; break; } }
*** 1027,1037 **** String[] writerNames = readerSpi.getImageWriterSpiNames(); if (writerNames == null) { return null; } ! Class writerSpiClass = null; try { writerSpiClass = Class.forName(writerNames[0], true, ClassLoader.getSystemClassLoader()); } catch (ClassNotFoundException e) { return null; --- 1027,1037 ---- String[] writerNames = readerSpi.getImageWriterSpiNames(); if (writerNames == null) { return null; } ! Class<?> writerSpiClass = null; try { writerSpiClass = Class.forName(writerNames[0], true, ClassLoader.getSystemClassLoader()); } catch (ClassNotFoundException e) { return null;
*** 1080,1101 **** throw new IllegalArgumentException("writer == null!"); } ImageWriterSpi writerSpi = writer.getOriginatingProvider(); if (writerSpi == null) { ! Iterator writerSpiIter; // Ensure category is present try { writerSpiIter = theRegistry.getServiceProviders(ImageWriterSpi.class, false); } catch (IllegalArgumentException e) { return null; } while (writerSpiIter.hasNext()) { ! ImageWriterSpi temp = (ImageWriterSpi) writerSpiIter.next(); if (temp.isOwnWriter(writer)) { writerSpi = temp; break; } } --- 1080,1101 ---- throw new IllegalArgumentException("writer == null!"); } ImageWriterSpi writerSpi = writer.getOriginatingProvider(); if (writerSpi == null) { ! Iterator<ImageWriterSpi> writerSpiIter; // Ensure category is present try { writerSpiIter = theRegistry.getServiceProviders(ImageWriterSpi.class, false); } catch (IllegalArgumentException e) { return null; } while (writerSpiIter.hasNext()) { ! ImageWriterSpi temp = writerSpiIter.next(); if (temp.isOwnWriter(writer)) { writerSpi = temp; break; } }
*** 1107,1117 **** String[] readerNames = writerSpi.getImageReaderSpiNames(); if (readerNames == null) { return null; } ! Class readerSpiClass = null; try { readerSpiClass = Class.forName(readerNames[0], true, ClassLoader.getSystemClassLoader()); } catch (ClassNotFoundException e) { return null; --- 1107,1117 ---- String[] readerNames = writerSpi.getImageReaderSpiNames(); if (readerNames == null) { return null; } ! Class<?> readerSpiClass = null; try { readerSpiClass = Class.forName(readerNames[0], true, ClassLoader.getSystemClassLoader()); } catch (ClassNotFoundException e) { return null;
*** 1158,1168 **** } if (formatName == null) { throw new IllegalArgumentException("formatName == null!"); } ! Iterator iter; // Ensure category is present try { iter = theRegistry.getServiceProviders(ImageWriterSpi.class, new CanEncodeImageAndFormatFilter(type, formatName), --- 1158,1168 ---- } if (formatName == null) { throw new IllegalArgumentException("formatName == null!"); } ! Iterator<ImageWriterSpi> iter; // Ensure category is present try { iter = theRegistry.getServiceProviders(ImageWriterSpi.class, new CanEncodeImageAndFormatFilter(type, formatName),
*** 1176,1198 **** static class ImageTranscoderIterator implements Iterator<ImageTranscoder> { // Contains ImageTranscoderSpis ! public Iterator iter; ! public ImageTranscoderIterator(Iterator iter) { this.iter = iter; } public boolean hasNext() { return iter.hasNext(); } public ImageTranscoder next() { ImageTranscoderSpi spi = null; ! spi = (ImageTranscoderSpi)iter.next(); return spi.createTranscoderInstance(); } public void remove() { throw new UnsupportedOperationException(); --- 1176,1198 ---- static class ImageTranscoderIterator implements Iterator<ImageTranscoder> { // Contains ImageTranscoderSpis ! public Iterator<ImageTranscoderSpi> iter; ! public ImageTranscoderIterator(Iterator<ImageTranscoderSpi> iter) { this.iter = iter; } public boolean hasNext() { return iter.hasNext(); } public ImageTranscoder next() { ImageTranscoderSpi spi = null; ! spi = iter.next(); return spi.createTranscoderInstance(); } public void remove() { throw new UnsupportedOperationException();
*** 1247,1257 **** ImageReaderSpi readerSpi = reader.getOriginatingProvider(); ImageWriterSpi writerSpi = writer.getOriginatingProvider(); ServiceRegistry.Filter filter = new TranscoderFilter(readerSpi, writerSpi); ! Iterator iter; // Ensure category is present try { iter = theRegistry.getServiceProviders(ImageTranscoderSpi.class, filter, true); } catch (IllegalArgumentException e) { --- 1247,1257 ---- ImageReaderSpi readerSpi = reader.getOriginatingProvider(); ImageWriterSpi writerSpi = writer.getOriginatingProvider(); ServiceRegistry.Filter filter = new TranscoderFilter(readerSpi, writerSpi); ! Iterator<ImageTranscoderSpi> iter; // Ensure category is present try { iter = theRegistry.getServiceProviders(ImageTranscoderSpi.class, filter, true); } catch (IllegalArgumentException e) {
*** 1433,1448 **** throws IOException { if (stream == null) { throw new IllegalArgumentException("stream == null!"); } ! Iterator iter = getImageReaders(stream); if (!iter.hasNext()) { return null; } ! ImageReader reader = (ImageReader)iter.next(); ImageReadParam param = reader.getDefaultReadParam(); reader.setInput(stream, true, true); BufferedImage bi; try { bi = reader.read(0, param); --- 1433,1448 ---- throws IOException { if (stream == null) { throw new IllegalArgumentException("stream == null!"); } ! Iterator<ImageReader> iter = getImageReaders(stream); if (!iter.hasNext()) { return null; } ! ImageReader reader = iter.next(); ImageReadParam param = reader.getDefaultReadParam(); reader.setInput(stream, true, true); BufferedImage bi; try { bi = reader.read(0, param);