8034998: Fix raw and unchecked lint warnings in javax.imageio

Reviewed-by: prr, darcy
This commit is contained in:
Henry Jen 2014-02-20 16:23:45 -08:00
parent c29425c5be
commit 083589648a
9 changed files with 116 additions and 116 deletions

View File

@ -339,7 +339,7 @@ public final class ImageIO {
throw new IllegalArgumentException("input == null!"); throw new IllegalArgumentException("input == null!");
} }
Iterator iter; Iterator<ImageInputStreamSpi> iter;
// Ensure category is present // Ensure category is present
try { try {
iter = theRegistry.getServiceProviders(ImageInputStreamSpi.class, iter = theRegistry.getServiceProviders(ImageInputStreamSpi.class,
@ -351,7 +351,7 @@ public final class ImageIO {
boolean usecache = getUseCache() && hasCachePermission(); boolean usecache = getUseCache() && hasCachePermission();
while (iter.hasNext()) { while (iter.hasNext()) {
ImageInputStreamSpi spi = (ImageInputStreamSpi)iter.next(); ImageInputStreamSpi spi = iter.next();
if (spi.getInputClass().isInstance(input)) { if (spi.getInputClass().isInstance(input)) {
try { try {
return spi.createInputStreamInstance(input, return spi.createInputStreamInstance(input,
@ -401,7 +401,7 @@ public final class ImageIO {
throw new IllegalArgumentException("output == null!"); throw new IllegalArgumentException("output == null!");
} }
Iterator iter; Iterator<ImageOutputStreamSpi> iter;
// Ensure category is present // Ensure category is present
try { try {
iter = theRegistry.getServiceProviders(ImageOutputStreamSpi.class, iter = theRegistry.getServiceProviders(ImageOutputStreamSpi.class,
@ -413,7 +413,7 @@ public final class ImageIO {
boolean usecache = getUseCache() && hasCachePermission(); boolean usecache = getUseCache() && hasCachePermission();
while (iter.hasNext()) { while (iter.hasNext()) {
ImageOutputStreamSpi spi = (ImageOutputStreamSpi)iter.next(); ImageOutputStreamSpi spi = iter.next();
if (spi.getOutputClass().isInstance(output)) { if (spi.getOutputClass().isInstance(output)) {
try { try {
return spi.createOutputStreamInstance(output, return spi.createOutputStreamInstance(output,
@ -512,9 +512,9 @@ public final class ImageIO {
static class ImageReaderIterator implements Iterator<ImageReader> { static class ImageReaderIterator implements Iterator<ImageReader> {
// Contains ImageReaderSpis // Contains ImageReaderSpis
public Iterator iter; private Iterator<ImageReaderSpi> iter;
public ImageReaderIterator(Iterator iter) { public ImageReaderIterator(Iterator<ImageReaderSpi> iter) {
this.iter = iter; this.iter = iter;
} }
@ -525,7 +525,7 @@ public final class ImageIO {
public ImageReader next() { public ImageReader next() {
ImageReaderSpi spi = null; ImageReaderSpi spi = null;
try { try {
spi = (ImageReaderSpi)iter.next(); spi = iter.next();
return spi.createReaderInstance(); return spi.createReaderInstance();
} catch (IOException e) { } catch (IOException e) {
// Deregister the spi in this case, but only as // Deregister the spi in this case, but only as
@ -640,7 +640,7 @@ public final class ImageIO {
if (input == null) { if (input == null) {
throw new IllegalArgumentException("input == null!"); throw new IllegalArgumentException("input == null!");
} }
Iterator iter; Iterator<ImageReaderSpi> iter;
// Ensure category is present // Ensure category is present
try { try {
iter = theRegistry.getServiceProviders(ImageReaderSpi.class, iter = theRegistry.getServiceProviders(ImageReaderSpi.class,
@ -702,7 +702,7 @@ public final class ImageIO {
if (formatName == null) { if (formatName == null) {
throw new IllegalArgumentException("formatName == null!"); throw new IllegalArgumentException("formatName == null!");
} }
Iterator iter; Iterator<ImageReaderSpi> iter;
// Ensure category is present // Ensure category is present
try { try {
iter = theRegistry.getServiceProviders(ImageReaderSpi.class, iter = theRegistry.getServiceProviders(ImageReaderSpi.class,
@ -738,7 +738,7 @@ public final class ImageIO {
throw new IllegalArgumentException("fileSuffix == null!"); throw new IllegalArgumentException("fileSuffix == null!");
} }
// Ensure category is present // Ensure category is present
Iterator iter; Iterator<ImageReaderSpi> iter;
try { try {
iter = theRegistry.getServiceProviders(ImageReaderSpi.class, iter = theRegistry.getServiceProviders(ImageReaderSpi.class,
new ContainsFilter(readerFileSuffixesMethod, new ContainsFilter(readerFileSuffixesMethod,
@ -773,7 +773,7 @@ public final class ImageIO {
throw new IllegalArgumentException("MIMEType == null!"); throw new IllegalArgumentException("MIMEType == null!");
} }
// Ensure category is present // Ensure category is present
Iterator iter; Iterator<ImageReaderSpi> iter;
try { try {
iter = theRegistry.getServiceProviders(ImageReaderSpi.class, iter = theRegistry.getServiceProviders(ImageReaderSpi.class,
new ContainsFilter(readerMIMETypesMethod, new ContainsFilter(readerMIMETypesMethod,
@ -826,9 +826,9 @@ public final class ImageIO {
static class ImageWriterIterator implements Iterator<ImageWriter> { static class ImageWriterIterator implements Iterator<ImageWriter> {
// Contains ImageWriterSpis // Contains ImageWriterSpis
public Iterator iter; private Iterator<ImageWriterSpi> iter;
public ImageWriterIterator(Iterator iter) { public ImageWriterIterator(Iterator<ImageWriterSpi> iter) {
this.iter = iter; this.iter = iter;
} }
@ -839,7 +839,7 @@ public final class ImageIO {
public ImageWriter next() { public ImageWriter next() {
ImageWriterSpi spi = null; ImageWriterSpi spi = null;
try { try {
spi = (ImageWriterSpi)iter.next(); spi = iter.next();
return spi.createWriterInstance(); return spi.createWriterInstance();
} catch (IOException e) { } catch (IOException e) {
// Deregister the spi in this case, but only as a writerSpi // Deregister the spi in this case, but only as a writerSpi
@ -885,7 +885,7 @@ public final class ImageIO {
if (formatName == null) { if (formatName == null) {
throw new IllegalArgumentException("formatName == null!"); throw new IllegalArgumentException("formatName == null!");
} }
Iterator iter; Iterator<ImageWriterSpi> iter;
// Ensure category is present // Ensure category is present
try { try {
iter = theRegistry.getServiceProviders(ImageWriterSpi.class, iter = theRegistry.getServiceProviders(ImageWriterSpi.class,
@ -919,7 +919,7 @@ public final class ImageIO {
if (fileSuffix == null) { if (fileSuffix == null) {
throw new IllegalArgumentException("fileSuffix == null!"); throw new IllegalArgumentException("fileSuffix == null!");
} }
Iterator iter; Iterator<ImageWriterSpi> iter;
// Ensure category is present // Ensure category is present
try { try {
iter = theRegistry.getServiceProviders(ImageWriterSpi.class, iter = theRegistry.getServiceProviders(ImageWriterSpi.class,
@ -953,7 +953,7 @@ public final class ImageIO {
if (MIMEType == null) { if (MIMEType == null) {
throw new IllegalArgumentException("MIMEType == null!"); throw new IllegalArgumentException("MIMEType == null!");
} }
Iterator iter; Iterator<ImageWriterSpi> iter;
// Ensure category is present // Ensure category is present
try { try {
iter = theRegistry.getServiceProviders(ImageWriterSpi.class, iter = theRegistry.getServiceProviders(ImageWriterSpi.class,
@ -1002,7 +1002,7 @@ public final class ImageIO {
ImageReaderSpi readerSpi = reader.getOriginatingProvider(); ImageReaderSpi readerSpi = reader.getOriginatingProvider();
if (readerSpi == null) { if (readerSpi == null) {
Iterator readerSpiIter; Iterator<ImageReaderSpi> readerSpiIter;
// Ensure category is present // Ensure category is present
try { try {
readerSpiIter = readerSpiIter =
@ -1013,7 +1013,7 @@ public final class ImageIO {
} }
while (readerSpiIter.hasNext()) { while (readerSpiIter.hasNext()) {
ImageReaderSpi temp = (ImageReaderSpi) readerSpiIter.next(); ImageReaderSpi temp = readerSpiIter.next();
if (temp.isOwnReader(reader)) { if (temp.isOwnReader(reader)) {
readerSpi = temp; readerSpi = temp;
break; break;
@ -1029,7 +1029,7 @@ public final class ImageIO {
return null; return null;
} }
Class writerSpiClass = null; Class<?> writerSpiClass = null;
try { try {
writerSpiClass = Class.forName(writerNames[0], true, writerSpiClass = Class.forName(writerNames[0], true,
ClassLoader.getSystemClassLoader()); ClassLoader.getSystemClassLoader());
@ -1082,7 +1082,7 @@ public final class ImageIO {
ImageWriterSpi writerSpi = writer.getOriginatingProvider(); ImageWriterSpi writerSpi = writer.getOriginatingProvider();
if (writerSpi == null) { if (writerSpi == null) {
Iterator writerSpiIter; Iterator<ImageWriterSpi> writerSpiIter;
// Ensure category is present // Ensure category is present
try { try {
writerSpiIter = writerSpiIter =
@ -1093,7 +1093,7 @@ public final class ImageIO {
} }
while (writerSpiIter.hasNext()) { while (writerSpiIter.hasNext()) {
ImageWriterSpi temp = (ImageWriterSpi) writerSpiIter.next(); ImageWriterSpi temp = writerSpiIter.next();
if (temp.isOwnWriter(writer)) { if (temp.isOwnWriter(writer)) {
writerSpi = temp; writerSpi = temp;
break; break;
@ -1109,7 +1109,7 @@ public final class ImageIO {
return null; return null;
} }
Class readerSpiClass = null; Class<?> readerSpiClass = null;
try { try {
readerSpiClass = Class.forName(readerNames[0], true, readerSpiClass = Class.forName(readerNames[0], true,
ClassLoader.getSystemClassLoader()); ClassLoader.getSystemClassLoader());
@ -1160,7 +1160,7 @@ public final class ImageIO {
throw new IllegalArgumentException("formatName == null!"); throw new IllegalArgumentException("formatName == null!");
} }
Iterator iter; Iterator<ImageWriterSpi> iter;
// Ensure category is present // Ensure category is present
try { try {
iter = theRegistry.getServiceProviders(ImageWriterSpi.class, iter = theRegistry.getServiceProviders(ImageWriterSpi.class,
@ -1178,9 +1178,9 @@ public final class ImageIO {
implements Iterator<ImageTranscoder> implements Iterator<ImageTranscoder>
{ {
// Contains ImageTranscoderSpis // Contains ImageTranscoderSpis
public Iterator iter; public Iterator<ImageTranscoderSpi> iter;
public ImageTranscoderIterator(Iterator iter) { public ImageTranscoderIterator(Iterator<ImageTranscoderSpi> iter) {
this.iter = iter; this.iter = iter;
} }
@ -1190,7 +1190,7 @@ public final class ImageIO {
public ImageTranscoder next() { public ImageTranscoder next() {
ImageTranscoderSpi spi = null; ImageTranscoderSpi spi = null;
spi = (ImageTranscoderSpi)iter.next(); spi = iter.next();
return spi.createTranscoderInstance(); return spi.createTranscoderInstance();
} }
@ -1249,7 +1249,7 @@ public final class ImageIO {
ServiceRegistry.Filter filter = ServiceRegistry.Filter filter =
new TranscoderFilter(readerSpi, writerSpi); new TranscoderFilter(readerSpi, writerSpi);
Iterator iter; Iterator<ImageTranscoderSpi> iter;
// Ensure category is present // Ensure category is present
try { try {
iter = theRegistry.getServiceProviders(ImageTranscoderSpi.class, iter = theRegistry.getServiceProviders(ImageTranscoderSpi.class,
@ -1435,12 +1435,12 @@ public final class ImageIO {
throw new IllegalArgumentException("stream == null!"); throw new IllegalArgumentException("stream == null!");
} }
Iterator iter = getImageReaders(stream); Iterator<ImageReader> iter = getImageReaders(stream);
if (!iter.hasNext()) { if (!iter.hasNext()) {
return null; return null;
} }
ImageReader reader = (ImageReader)iter.next(); ImageReader reader = iter.next();
ImageReadParam param = reader.getDefaultReadParam(); ImageReadParam param = reader.getDefaultReadParam();
reader.setInput(stream, true, true); reader.setInput(stream, true, true);
BufferedImage bi; BufferedImage bi;

View File

@ -793,7 +793,7 @@ public abstract class ImageReader {
} }
private IIOMetadata getMetadata(String formatName, private IIOMetadata getMetadata(String formatName,
Set nodeNames, Set<String> nodeNames,
boolean wantStream, boolean wantStream,
int imageIndex) throws IOException { int imageIndex) throws IOException {
if (formatName == null) { if (formatName == null) {
@ -1065,10 +1065,10 @@ public abstract class ImageReader {
BufferedImage im = read(imageIndex, param); BufferedImage im = read(imageIndex, param);
ArrayList thumbnails = null; ArrayList<BufferedImage> thumbnails = null;
int numThumbnails = getNumThumbnails(imageIndex); int numThumbnails = getNumThumbnails(imageIndex);
if (numThumbnails > 0) { if (numThumbnails > 0) {
thumbnails = new ArrayList(); thumbnails = new ArrayList<>();
for (int j = 0; j < numThumbnails; j++) { for (int j = 0; j < numThumbnails; j++) {
thumbnails.add(readThumbnail(imageIndex, j)); thumbnails.add(readThumbnail(imageIndex, j));
} }
@ -1156,7 +1156,7 @@ public abstract class ImageReader {
readAll(Iterator<? extends ImageReadParam> params) readAll(Iterator<? extends ImageReadParam> params)
throws IOException throws IOException
{ {
List output = new ArrayList(); List<IIOImage> output = new ArrayList<>();
int imageIndex = getMinIndex(); int imageIndex = getMinIndex();
@ -1187,10 +1187,10 @@ public abstract class ImageReader {
break; break;
} }
ArrayList thumbnails = null; ArrayList<BufferedImage> thumbnails = null;
int numThumbnails = getNumThumbnails(imageIndex); int numThumbnails = getNumThumbnails(imageIndex);
if (numThumbnails > 0) { if (numThumbnails > 0) {
thumbnails = new ArrayList(); thumbnails = new ArrayList<>();
for (int j = 0; j < numThumbnails; j++) { for (int j = 0; j < numThumbnails; j++) {
thumbnails.add(readThumbnail(imageIndex, j)); thumbnails.add(readThumbnail(imageIndex, j));
} }
@ -1797,9 +1797,9 @@ public abstract class ImageReader {
// Add an element to a list, creating a new list if the // Add an element to a list, creating a new list if the
// existing list is null, and return the list. // existing list is null, and return the list.
static List addToList(List l, Object elt) { static <T> List<T> addToList(List<T> l, T elt) {
if (l == null) { if (l == null) {
l = new ArrayList(); l = new ArrayList<>();
} }
l.add(elt); l.add(elt);
return l; return l;
@ -1808,7 +1808,7 @@ public abstract class ImageReader {
// Remove an element from a list, discarding the list if the // Remove an element from a list, discarding the list if the
// resulting list is empty, and return the list or null. // resulting list is empty, and return the list or null.
static List removeFromList(List l, Object elt) { static <T> List<T> removeFromList(List<T> l, T elt) {
if (l == null) { if (l == null) {
return l; return l;
} }
@ -2461,10 +2461,10 @@ public abstract class ImageReader {
* If that throws MissingResourceException, then try the * If that throws MissingResourceException, then try the
* system class loader. * system class loader.
*/ */
ClassLoader loader = (ClassLoader) ClassLoader loader =
java.security.AccessController.doPrivileged( java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction() { new java.security.PrivilegedAction<ClassLoader>() {
public Object run() { public ClassLoader run() {
return Thread.currentThread().getContextClassLoader(); return Thread.currentThread().getContextClassLoader();
} }
}); });

View File

@ -1075,7 +1075,7 @@ public class ImageTypeSpecifier {
new Point(0, 0)); new Point(0, 0));
return new BufferedImage(colorModel, raster, return new BufferedImage(colorModel, raster,
colorModel.isAlphaPremultiplied(), colorModel.isAlphaPremultiplied(),
new Hashtable()); new Hashtable<>());
} catch (NegativeArraySizeException e) { } catch (NegativeArraySizeException e) {
// Exception most likely thrown from a DataBuffer constructor // Exception most likely thrown from a DataBuffer constructor
throw new IllegalArgumentException throw new IllegalArgumentException

View File

@ -1964,10 +1964,10 @@ public abstract class ImageWriter implements ImageTranscoder {
* If that throws MissingResourceException, then try the * If that throws MissingResourceException, then try the
* system class loader. * system class loader.
*/ */
ClassLoader loader = (ClassLoader) ClassLoader loader =
java.security.AccessController.doPrivileged( java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction() { new java.security.PrivilegedAction<ClassLoader>() {
public Object run() { public ClassLoader run() {
return Thread.currentThread().getContextClassLoader(); return Thread.currentThread().getContextClassLoader();
} }
}); });

View File

@ -395,15 +395,15 @@ public abstract class IIOMetadata {
throw new IllegalArgumentException("Unsupported format name"); throw new IllegalArgumentException("Unsupported format name");
} }
try { try {
Class cls = null; Class<?> cls = null;
final Object o = this; final Object o = this;
// firstly we try to use classloader used for loading // firstly we try to use classloader used for loading
// the IIOMetadata implemantation for this plugin. // the IIOMetadata implemantation for this plugin.
ClassLoader loader = (ClassLoader) ClassLoader loader =
java.security.AccessController.doPrivileged( java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction() { new java.security.PrivilegedAction<ClassLoader>() {
public Object run() { public ClassLoader run() {
return o.getClass().getClassLoader(); return o.getClass().getClassLoader();
} }
}); });
@ -415,10 +415,10 @@ public abstract class IIOMetadata {
// we failed to load IIOMetadataFormat class by // we failed to load IIOMetadataFormat class by
// using IIOMetadata classloader.Next try is to // using IIOMetadata classloader.Next try is to
// use thread context classloader. // use thread context classloader.
loader = (ClassLoader) loader =
java.security.AccessController.doPrivileged( java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction() { new java.security.PrivilegedAction<ClassLoader>() {
public Object run() { public ClassLoader run() {
return Thread.currentThread().getContextClassLoader(); return Thread.currentThread().getContextClassLoader();
} }
}); });

View File

@ -90,7 +90,7 @@ public abstract class IIOMetadataFormatImpl implements IIOMetadataFormat {
private String rootName; private String rootName;
// Element name (String) -> Element // Element name (String) -> Element
private HashMap elementMap = new HashMap(); private HashMap<String, Element> elementMap = new HashMap<>();
class Element { class Element {
String elementName; String elementName;
@ -100,17 +100,17 @@ public abstract class IIOMetadataFormatImpl implements IIOMetadataFormat {
int maxChildren = 0; int maxChildren = 0;
// Child names (Strings) // Child names (Strings)
List childList = new ArrayList(); List<String> childList = new ArrayList<>();
// Parent names (Strings) // Parent names (Strings)
List parentList = new ArrayList(); List<String> parentList = new ArrayList<>();
// List of attribute names in the order they were added // List of attribute names in the order they were added
List attrList = new ArrayList(); List<String> attrList = new ArrayList<>();
// Attr name (String) -> Attribute // Attr name (String) -> Attribute
Map attrMap = new HashMap(); Map<String, Attribute> attrMap = new HashMap<>();
ObjectValue objectValue; ObjectValue<?> objectValue;
} }
class Attribute { class Attribute {
@ -122,7 +122,7 @@ public abstract class IIOMetadataFormatImpl implements IIOMetadataFormat {
String defaultValue = null; String defaultValue = null;
// enumeration // enumeration
List enumeratedValues; List<String> enumeratedValues;
// range // range
String minValue; String minValue;
@ -133,17 +133,18 @@ public abstract class IIOMetadataFormatImpl implements IIOMetadataFormat {
int listMaxLength; int listMaxLength;
} }
class ObjectValue { class ObjectValue<T> {
int valueType = VALUE_NONE; int valueType = VALUE_NONE;
Class classType = null; // ? extends T So that ObjectValue<Object> can take Class<?>
Object defaultValue = null; Class<? extends T> classType = null;
T defaultValue = null;
// Meaningful only if valueType == VALUE_ENUMERATION // Meaningful only if valueType == VALUE_ENUMERATION
List enumeratedValues = null; List<? extends T> enumeratedValues = null;
// Meaningful only if valueType == VALUE_RANGE // Meaningful only if valueType == VALUE_RANGE
Comparable minValue = null; Comparable<? super T> minValue = null;
Comparable maxValue = null; Comparable<? super T> maxValue = null;
// Meaningful only if valueType == VALUE_LIST // Meaningful only if valueType == VALUE_LIST
int arrayMinLength = 0; int arrayMinLength = 0;
@ -272,7 +273,7 @@ public abstract class IIOMetadataFormatImpl implements IIOMetadataFormat {
if (mustAppear && (elementName == null)) { if (mustAppear && (elementName == null)) {
throw new IllegalArgumentException("element name is null!"); throw new IllegalArgumentException("element name is null!");
} }
Element element = (Element)elementMap.get(elementName); Element element = elementMap.get(elementName);
if (mustAppear && (element == null)) { if (mustAppear && (element == null)) {
throw new IllegalArgumentException("No such element: " + throw new IllegalArgumentException("No such element: " +
elementName); elementName);
@ -287,7 +288,7 @@ public abstract class IIOMetadataFormatImpl implements IIOMetadataFormat {
// Utility method for locating an attribute // Utility method for locating an attribute
private Attribute getAttribute(String elementName, String attrName) { private Attribute getAttribute(String elementName, String attrName) {
Element element = getElement(elementName); Element element = getElement(elementName);
Attribute attr = (Attribute)element.attrMap.get(attrName); Attribute attr = element.attrMap.get(attrName);
if (attr == null) { if (attr == null) {
throw new IllegalArgumentException("No such attribute \"" + throw new IllegalArgumentException("No such attribute \"" +
attrName + "\"!"); attrName + "\"!");
@ -408,9 +409,9 @@ public abstract class IIOMetadataFormatImpl implements IIOMetadataFormat {
protected void removeElement(String elementName) { protected void removeElement(String elementName) {
Element element = getElement(elementName, false); Element element = getElement(elementName, false);
if (element != null) { if (element != null) {
Iterator iter = element.parentList.iterator(); Iterator<String> iter = element.parentList.iterator();
while (iter.hasNext()) { while (iter.hasNext()) {
String parentName = (String)iter.next(); String parentName = iter.next();
Element parent = getElement(parentName, false); Element parent = getElement(parentName, false);
if (parent != null) { if (parent != null) {
parent.childList.remove(elementName); parent.childList.remove(elementName);
@ -514,7 +515,7 @@ public abstract class IIOMetadataFormatImpl implements IIOMetadataFormat {
if (enumeratedValues.size() == 0) { if (enumeratedValues.size() == 0) {
throw new IllegalArgumentException("enumeratedValues is empty!"); throw new IllegalArgumentException("enumeratedValues is empty!");
} }
Iterator iter = enumeratedValues.iterator(); Iterator<String> iter = enumeratedValues.iterator();
while (iter.hasNext()) { while (iter.hasNext()) {
Object o = iter.next(); Object o = iter.next();
if (o == null) { if (o == null) {
@ -681,7 +682,7 @@ public abstract class IIOMetadataFormatImpl implements IIOMetadataFormat {
String attrName, String attrName,
boolean hasDefaultValue, boolean hasDefaultValue,
boolean defaultValue) { boolean defaultValue) {
List values = new ArrayList(); List<String> values = new ArrayList<>();
values.add("TRUE"); values.add("TRUE");
values.add("FALSE"); values.add("FALSE");
@ -740,7 +741,7 @@ public abstract class IIOMetadataFormatImpl implements IIOMetadataFormat {
T defaultValue) T defaultValue)
{ {
Element element = getElement(elementName); Element element = getElement(elementName);
ObjectValue obj = new ObjectValue(); ObjectValue<T> obj = new ObjectValue<>();
obj.valueType = VALUE_ARBITRARY; obj.valueType = VALUE_ARBITRARY;
obj.classType = classType; obj.classType = classType;
obj.defaultValue = defaultValue; obj.defaultValue = defaultValue;
@ -793,7 +794,7 @@ public abstract class IIOMetadataFormatImpl implements IIOMetadataFormat {
if (enumeratedValues.size() == 0) { if (enumeratedValues.size() == 0) {
throw new IllegalArgumentException("enumeratedValues is empty!"); throw new IllegalArgumentException("enumeratedValues is empty!");
} }
Iterator iter = enumeratedValues.iterator(); Iterator<? extends T> iter = enumeratedValues.iterator();
while (iter.hasNext()) { while (iter.hasNext()) {
Object o = iter.next(); Object o = iter.next();
if (o == null) { if (o == null) {
@ -804,7 +805,7 @@ public abstract class IIOMetadataFormatImpl implements IIOMetadataFormat {
} }
} }
ObjectValue obj = new ObjectValue(); ObjectValue<T> obj = new ObjectValue<>();
obj.valueType = VALUE_ENUMERATION; obj.valueType = VALUE_ENUMERATION;
obj.classType = classType; obj.classType = classType;
obj.defaultValue = defaultValue; obj.defaultValue = defaultValue;
@ -854,7 +855,7 @@ public abstract class IIOMetadataFormatImpl implements IIOMetadataFormat {
boolean maxInclusive) boolean maxInclusive)
{ {
Element element = getElement(elementName); Element element = getElement(elementName);
ObjectValue obj = new ObjectValue(); ObjectValue<T> obj = new ObjectValue<>();
obj.valueType = VALUE_RANGE; obj.valueType = VALUE_RANGE;
if (minInclusive) { if (minInclusive) {
obj.valueType |= VALUE_RANGE_MIN_INCLUSIVE_MASK; obj.valueType |= VALUE_RANGE_MIN_INCLUSIVE_MASK;
@ -895,7 +896,7 @@ public abstract class IIOMetadataFormatImpl implements IIOMetadataFormat {
int arrayMinLength, int arrayMinLength,
int arrayMaxLength) { int arrayMaxLength) {
Element element = getElement(elementName); Element element = getElement(elementName);
ObjectValue obj = new ObjectValue(); ObjectValue<Object> obj = new ObjectValue<>();
obj.valueType = VALUE_LIST; obj.valueType = VALUE_LIST;
obj.classType = classType; obj.classType = classType;
obj.arrayMinLength = arrayMinLength; obj.arrayMinLength = arrayMinLength;
@ -962,10 +963,10 @@ public abstract class IIOMetadataFormatImpl implements IIOMetadataFormat {
* If that throws MissingResourceException, then try the * If that throws MissingResourceException, then try the
* system class loader. * system class loader.
*/ */
ClassLoader loader = (ClassLoader) ClassLoader loader =
java.security.AccessController.doPrivileged( java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction() { new java.security.PrivilegedAction<ClassLoader>() {
public Object run() { public ClassLoader run() {
return Thread.currentThread().getContextClassLoader(); return Thread.currentThread().getContextClassLoader();
} }
}); });
@ -1037,17 +1038,17 @@ public abstract class IIOMetadataFormatImpl implements IIOMetadataFormat {
if (element.childPolicy == CHILD_POLICY_EMPTY) { if (element.childPolicy == CHILD_POLICY_EMPTY) {
return null; return null;
} }
return (String[])element.childList.toArray(new String[0]); return element.childList.toArray(new String[0]);
} }
// Attributes // Attributes
public String[] getAttributeNames(String elementName) { public String[] getAttributeNames(String elementName) {
Element element = getElement(elementName); Element element = getElement(elementName);
List names = element.attrList; List<String> names = element.attrList;
String[] result = new String[names.size()]; String[] result = new String[names.size()];
return (String[])names.toArray(result); return names.toArray(result);
} }
public int getAttributeValueType(String elementName, String attrName) { public int getAttributeValueType(String elementName, String attrName) {
@ -1079,10 +1080,9 @@ public abstract class IIOMetadataFormatImpl implements IIOMetadataFormat {
("Attribute not an enumeration!"); ("Attribute not an enumeration!");
} }
List values = attr.enumeratedValues; List<String> values = attr.enumeratedValues;
Iterator iter = values.iterator();
String[] result = new String[values.size()]; String[] result = new String[values.size()];
return (String[])values.toArray(result); return values.toArray(result);
} }
public String getAttributeMinValue(String elementName, String attrName) { public String getAttributeMinValue(String elementName, String attrName) {
@ -1170,7 +1170,7 @@ public abstract class IIOMetadataFormatImpl implements IIOMetadataFormat {
if (attrName == null) { if (attrName == null) {
throw new IllegalArgumentException("attrName == null!"); throw new IllegalArgumentException("attrName == null!");
} }
Attribute attr = (Attribute)element.attrMap.get(attrName); Attribute attr = element.attrMap.get(attrName);
if (attr == null) { if (attr == null) {
throw new IllegalArgumentException("No such attribute!"); throw new IllegalArgumentException("No such attribute!");
} }
@ -1179,9 +1179,9 @@ public abstract class IIOMetadataFormatImpl implements IIOMetadataFormat {
return getResource(key, locale); return getResource(key, locale);
} }
private ObjectValue getObjectValue(String elementName) { private ObjectValue<?> getObjectValue(String elementName) {
Element element = getElement(elementName); Element element = getElement(elementName);
ObjectValue objv = element.objectValue; ObjectValue<?> objv = element.objectValue;
if (objv == null) { if (objv == null) {
throw new IllegalArgumentException("No object within element " + throw new IllegalArgumentException("No object within element " +
elementName + "!"); elementName + "!");
@ -1191,7 +1191,7 @@ public abstract class IIOMetadataFormatImpl implements IIOMetadataFormat {
public int getObjectValueType(String elementName) { public int getObjectValueType(String elementName) {
Element element = getElement(elementName); Element element = getElement(elementName);
ObjectValue objv = element.objectValue; ObjectValue<?> objv = element.objectValue;
if (objv == null) { if (objv == null) {
return VALUE_NONE; return VALUE_NONE;
} }
@ -1199,27 +1199,27 @@ public abstract class IIOMetadataFormatImpl implements IIOMetadataFormat {
} }
public Class<?> getObjectClass(String elementName) { public Class<?> getObjectClass(String elementName) {
ObjectValue objv = getObjectValue(elementName); ObjectValue<?> objv = getObjectValue(elementName);
return objv.classType; return objv.classType;
} }
public Object getObjectDefaultValue(String elementName) { public Object getObjectDefaultValue(String elementName) {
ObjectValue objv = getObjectValue(elementName); ObjectValue<?> objv = getObjectValue(elementName);
return objv.defaultValue; return objv.defaultValue;
} }
public Object[] getObjectEnumerations(String elementName) { public Object[] getObjectEnumerations(String elementName) {
ObjectValue objv = getObjectValue(elementName); ObjectValue<?> objv = getObjectValue(elementName);
if (objv.valueType != VALUE_ENUMERATION) { if (objv.valueType != VALUE_ENUMERATION) {
throw new IllegalArgumentException("Not an enumeration!"); throw new IllegalArgumentException("Not an enumeration!");
} }
List vlist = objv.enumeratedValues; List<?> vlist = objv.enumeratedValues;
Object[] values = new Object[vlist.size()]; Object[] values = new Object[vlist.size()];
return vlist.toArray(values); return vlist.toArray(values);
} }
public Comparable<?> getObjectMinValue(String elementName) { public Comparable<?> getObjectMinValue(String elementName) {
ObjectValue objv = getObjectValue(elementName); ObjectValue<?> objv = getObjectValue(elementName);
if ((objv.valueType & VALUE_RANGE) != VALUE_RANGE) { if ((objv.valueType & VALUE_RANGE) != VALUE_RANGE) {
throw new IllegalArgumentException("Not a range!"); throw new IllegalArgumentException("Not a range!");
} }
@ -1227,7 +1227,7 @@ public abstract class IIOMetadataFormatImpl implements IIOMetadataFormat {
} }
public Comparable<?> getObjectMaxValue(String elementName) { public Comparable<?> getObjectMaxValue(String elementName) {
ObjectValue objv = getObjectValue(elementName); ObjectValue<?> objv = getObjectValue(elementName);
if ((objv.valueType & VALUE_RANGE) != VALUE_RANGE) { if ((objv.valueType & VALUE_RANGE) != VALUE_RANGE) {
throw new IllegalArgumentException("Not a range!"); throw new IllegalArgumentException("Not a range!");
} }
@ -1235,7 +1235,7 @@ public abstract class IIOMetadataFormatImpl implements IIOMetadataFormat {
} }
public int getObjectArrayMinLength(String elementName) { public int getObjectArrayMinLength(String elementName) {
ObjectValue objv = getObjectValue(elementName); ObjectValue<?> objv = getObjectValue(elementName);
if (objv.valueType != VALUE_LIST) { if (objv.valueType != VALUE_LIST) {
throw new IllegalArgumentException("Not a list!"); throw new IllegalArgumentException("Not a list!");
} }
@ -1243,7 +1243,7 @@ public abstract class IIOMetadataFormatImpl implements IIOMetadataFormat {
} }
public int getObjectArrayMaxLength(String elementName) { public int getObjectArrayMaxLength(String elementName) {
ObjectValue objv = getObjectValue(elementName); ObjectValue<?> objv = getObjectValue(elementName);
if (objv.valueType != VALUE_LIST) { if (objv.valueType != VALUE_LIST) {
throw new IllegalArgumentException("Not a list!"); throw new IllegalArgumentException("Not a list!");
} }

View File

@ -50,9 +50,9 @@ class IIODOMException extends DOMException {
class IIONamedNodeMap implements NamedNodeMap { class IIONamedNodeMap implements NamedNodeMap {
List nodes; List<? extends Node> nodes;
public IIONamedNodeMap(List nodes) { public IIONamedNodeMap(List<? extends Node> nodes) {
this.nodes = nodes; this.nodes = nodes;
} }
@ -61,9 +61,9 @@ class IIONamedNodeMap implements NamedNodeMap {
} }
public Node getNamedItem(String name) { public Node getNamedItem(String name) {
Iterator iter = nodes.iterator(); Iterator<? extends Node> iter = nodes.iterator();
while (iter.hasNext()) { while (iter.hasNext()) {
Node node = (Node)iter.next(); Node node = iter.next();
if (name.equals(node.getNodeName())) { if (name.equals(node.getNodeName())) {
return node; return node;
} }
@ -73,7 +73,7 @@ class IIONamedNodeMap implements NamedNodeMap {
} }
public Node item(int index) { public Node item(int index) {
Node node = (Node)nodes.get(index); Node node = nodes.get(index);
return node; return node;
} }
@ -111,9 +111,9 @@ class IIONamedNodeMap implements NamedNodeMap {
class IIONodeList implements NodeList { class IIONodeList implements NodeList {
List nodes; List<? extends Node> nodes;
public IIONodeList(List nodes) { public IIONodeList(List<? extends Node> nodes) {
this.nodes = nodes; this.nodes = nodes;
} }
@ -125,7 +125,7 @@ class IIONodeList implements NodeList {
if (index < 0 || index > nodes.size()) { if (index < 0 || index > nodes.size()) {
return null; return null;
} }
return (Node)nodes.get(index); return nodes.get(index);
} }
} }
@ -285,7 +285,7 @@ public class IIOMetadataNode implements Element, NodeList {
* A <code>List</code> of <code>IIOAttr</code> nodes representing * A <code>List</code> of <code>IIOAttr</code> nodes representing
* attributes. * attributes.
*/ */
private List attributes = new ArrayList(); private List<IIOAttr> attributes = new ArrayList<>();
/** /**
* Constructs an empty <code>IIOMetadataNode</code>. * Constructs an empty <code>IIOMetadataNode</code>.
@ -789,7 +789,7 @@ public class IIOMetadataNode implements Element, NodeList {
private void removeAttribute(String name, boolean checkPresent) { private void removeAttribute(String name, boolean checkPresent) {
int numAttributes = attributes.size(); int numAttributes = attributes.size();
for (int i = 0; i < numAttributes; i++) { for (int i = 0; i < numAttributes; i++) {
IIOAttr attr = (IIOAttr)attributes.get(i); IIOAttr attr = attributes.get(i);
if (name.equals(attr.getName())) { if (name.equals(attr.getName())) {
attr.setOwnerElement(null); attr.setOwnerElement(null);
attributes.remove(i); attributes.remove(i);
@ -873,12 +873,12 @@ public class IIOMetadataNode implements Element, NodeList {
} }
public NodeList getElementsByTagName(String name) { public NodeList getElementsByTagName(String name) {
List l = new ArrayList(); List<Node> l = new ArrayList<>();
getElementsByTagName(name, l); getElementsByTagName(name, l);
return new IIONodeList(l); return new IIONodeList(l);
} }
private void getElementsByTagName(String name, List l) { private void getElementsByTagName(String name, List<Node> l) {
if (nodeName.equals(name)) { if (nodeName.equals(name)) {
l.add(this); l.add(this);
} }

View File

@ -43,9 +43,9 @@ import javax.imageio.IIOException;
*/ */
public abstract class ImageInputStreamImpl implements ImageInputStream { public abstract class ImageInputStreamImpl implements ImageInputStream {
private Stack markByteStack = new Stack(); private Stack<Long> markByteStack = new Stack<>();
private Stack markBitStack = new Stack(); private Stack<Integer> markBitStack = new Stack<>();
private boolean isClosed = false; private boolean isClosed = false;
@ -798,14 +798,14 @@ public abstract class ImageInputStreamImpl implements ImageInputStream {
return; return;
} }
long pos = ((Long)markByteStack.pop()).longValue(); long pos = markByteStack.pop().longValue();
if (pos < flushedPos) { if (pos < flushedPos) {
throw new IIOException throw new IIOException
("Previous marked position has been discarded!"); ("Previous marked position has been discarded!");
} }
seek(pos); seek(pos);
int offset = ((Integer)markBitStack.pop()).intValue(); int offset = markBitStack.pop().intValue();
setBitOffset(offset); setBitOffset(offset);
} }

View File

@ -58,7 +58,7 @@ class MemoryCache {
private static final int BUFFER_LENGTH = 8192; private static final int BUFFER_LENGTH = 8192;
private ArrayList cache = new ArrayList(); private ArrayList<byte[]> cache = new ArrayList<>();
private long cacheStart = 0L; private long cacheStart = 0L;
@ -74,7 +74,7 @@ class MemoryCache {
// contiguous data... // contiguous data...
throw new IOException("Cache addressing limit exceeded!"); throw new IOException("Cache addressing limit exceeded!");
} }
return (byte[])cache.get((int)blockOffset); return cache.get((int)blockOffset);
} }
/** /**