8034998: Fix raw and unchecked lint warnings in javax.imageio
Reviewed-by: prr, darcy
This commit is contained in:
parent
c29425c5be
commit
083589648a
@ -339,7 +339,7 @@ public final class ImageIO {
|
||||
throw new IllegalArgumentException("input == null!");
|
||||
}
|
||||
|
||||
Iterator iter;
|
||||
Iterator<ImageInputStreamSpi> iter;
|
||||
// Ensure category is present
|
||||
try {
|
||||
iter = theRegistry.getServiceProviders(ImageInputStreamSpi.class,
|
||||
@ -351,7 +351,7 @@ public final class ImageIO {
|
||||
boolean usecache = getUseCache() && hasCachePermission();
|
||||
|
||||
while (iter.hasNext()) {
|
||||
ImageInputStreamSpi spi = (ImageInputStreamSpi)iter.next();
|
||||
ImageInputStreamSpi spi = iter.next();
|
||||
if (spi.getInputClass().isInstance(input)) {
|
||||
try {
|
||||
return spi.createInputStreamInstance(input,
|
||||
@ -401,7 +401,7 @@ public final class ImageIO {
|
||||
throw new IllegalArgumentException("output == null!");
|
||||
}
|
||||
|
||||
Iterator iter;
|
||||
Iterator<ImageOutputStreamSpi> iter;
|
||||
// Ensure category is present
|
||||
try {
|
||||
iter = theRegistry.getServiceProviders(ImageOutputStreamSpi.class,
|
||||
@ -413,7 +413,7 @@ public final class ImageIO {
|
||||
boolean usecache = getUseCache() && hasCachePermission();
|
||||
|
||||
while (iter.hasNext()) {
|
||||
ImageOutputStreamSpi spi = (ImageOutputStreamSpi)iter.next();
|
||||
ImageOutputStreamSpi spi = iter.next();
|
||||
if (spi.getOutputClass().isInstance(output)) {
|
||||
try {
|
||||
return spi.createOutputStreamInstance(output,
|
||||
@ -512,9 +512,9 @@ public final class ImageIO {
|
||||
|
||||
static class ImageReaderIterator implements Iterator<ImageReader> {
|
||||
// Contains ImageReaderSpis
|
||||
public Iterator iter;
|
||||
private Iterator<ImageReaderSpi> iter;
|
||||
|
||||
public ImageReaderIterator(Iterator iter) {
|
||||
public ImageReaderIterator(Iterator<ImageReaderSpi> iter) {
|
||||
this.iter = iter;
|
||||
}
|
||||
|
||||
@ -525,7 +525,7 @@ public final class ImageIO {
|
||||
public ImageReader next() {
|
||||
ImageReaderSpi spi = null;
|
||||
try {
|
||||
spi = (ImageReaderSpi)iter.next();
|
||||
spi = iter.next();
|
||||
return spi.createReaderInstance();
|
||||
} catch (IOException e) {
|
||||
// Deregister the spi in this case, but only as
|
||||
@ -640,7 +640,7 @@ public final class ImageIO {
|
||||
if (input == null) {
|
||||
throw new IllegalArgumentException("input == null!");
|
||||
}
|
||||
Iterator iter;
|
||||
Iterator<ImageReaderSpi> iter;
|
||||
// Ensure category is present
|
||||
try {
|
||||
iter = theRegistry.getServiceProviders(ImageReaderSpi.class,
|
||||
@ -702,7 +702,7 @@ public final class ImageIO {
|
||||
if (formatName == null) {
|
||||
throw new IllegalArgumentException("formatName == null!");
|
||||
}
|
||||
Iterator iter;
|
||||
Iterator<ImageReaderSpi> iter;
|
||||
// Ensure category is present
|
||||
try {
|
||||
iter = theRegistry.getServiceProviders(ImageReaderSpi.class,
|
||||
@ -738,7 +738,7 @@ public final class ImageIO {
|
||||
throw new IllegalArgumentException("fileSuffix == null!");
|
||||
}
|
||||
// Ensure category is present
|
||||
Iterator iter;
|
||||
Iterator<ImageReaderSpi> iter;
|
||||
try {
|
||||
iter = theRegistry.getServiceProviders(ImageReaderSpi.class,
|
||||
new ContainsFilter(readerFileSuffixesMethod,
|
||||
@ -773,7 +773,7 @@ public final class ImageIO {
|
||||
throw new IllegalArgumentException("MIMEType == null!");
|
||||
}
|
||||
// Ensure category is present
|
||||
Iterator iter;
|
||||
Iterator<ImageReaderSpi> iter;
|
||||
try {
|
||||
iter = theRegistry.getServiceProviders(ImageReaderSpi.class,
|
||||
new ContainsFilter(readerMIMETypesMethod,
|
||||
@ -826,9 +826,9 @@ public final class ImageIO {
|
||||
|
||||
static class ImageWriterIterator implements Iterator<ImageWriter> {
|
||||
// Contains ImageWriterSpis
|
||||
public Iterator iter;
|
||||
private Iterator<ImageWriterSpi> iter;
|
||||
|
||||
public ImageWriterIterator(Iterator iter) {
|
||||
public ImageWriterIterator(Iterator<ImageWriterSpi> iter) {
|
||||
this.iter = iter;
|
||||
}
|
||||
|
||||
@ -839,7 +839,7 @@ public final class ImageIO {
|
||||
public ImageWriter next() {
|
||||
ImageWriterSpi spi = null;
|
||||
try {
|
||||
spi = (ImageWriterSpi)iter.next();
|
||||
spi = iter.next();
|
||||
return spi.createWriterInstance();
|
||||
} catch (IOException e) {
|
||||
// Deregister the spi in this case, but only as a writerSpi
|
||||
@ -885,7 +885,7 @@ public final class ImageIO {
|
||||
if (formatName == null) {
|
||||
throw new IllegalArgumentException("formatName == null!");
|
||||
}
|
||||
Iterator iter;
|
||||
Iterator<ImageWriterSpi> iter;
|
||||
// Ensure category is present
|
||||
try {
|
||||
iter = theRegistry.getServiceProviders(ImageWriterSpi.class,
|
||||
@ -919,7 +919,7 @@ public final class ImageIO {
|
||||
if (fileSuffix == null) {
|
||||
throw new IllegalArgumentException("fileSuffix == null!");
|
||||
}
|
||||
Iterator iter;
|
||||
Iterator<ImageWriterSpi> iter;
|
||||
// Ensure category is present
|
||||
try {
|
||||
iter = theRegistry.getServiceProviders(ImageWriterSpi.class,
|
||||
@ -953,7 +953,7 @@ public final class ImageIO {
|
||||
if (MIMEType == null) {
|
||||
throw new IllegalArgumentException("MIMEType == null!");
|
||||
}
|
||||
Iterator iter;
|
||||
Iterator<ImageWriterSpi> iter;
|
||||
// Ensure category is present
|
||||
try {
|
||||
iter = theRegistry.getServiceProviders(ImageWriterSpi.class,
|
||||
@ -1002,7 +1002,7 @@ public final class ImageIO {
|
||||
|
||||
ImageReaderSpi readerSpi = reader.getOriginatingProvider();
|
||||
if (readerSpi == null) {
|
||||
Iterator readerSpiIter;
|
||||
Iterator<ImageReaderSpi> readerSpiIter;
|
||||
// Ensure category is present
|
||||
try {
|
||||
readerSpiIter =
|
||||
@ -1013,7 +1013,7 @@ public final class ImageIO {
|
||||
}
|
||||
|
||||
while (readerSpiIter.hasNext()) {
|
||||
ImageReaderSpi temp = (ImageReaderSpi) readerSpiIter.next();
|
||||
ImageReaderSpi temp = readerSpiIter.next();
|
||||
if (temp.isOwnReader(reader)) {
|
||||
readerSpi = temp;
|
||||
break;
|
||||
@ -1029,7 +1029,7 @@ public final class ImageIO {
|
||||
return null;
|
||||
}
|
||||
|
||||
Class writerSpiClass = null;
|
||||
Class<?> writerSpiClass = null;
|
||||
try {
|
||||
writerSpiClass = Class.forName(writerNames[0], true,
|
||||
ClassLoader.getSystemClassLoader());
|
||||
@ -1082,7 +1082,7 @@ public final class ImageIO {
|
||||
|
||||
ImageWriterSpi writerSpi = writer.getOriginatingProvider();
|
||||
if (writerSpi == null) {
|
||||
Iterator writerSpiIter;
|
||||
Iterator<ImageWriterSpi> writerSpiIter;
|
||||
// Ensure category is present
|
||||
try {
|
||||
writerSpiIter =
|
||||
@ -1093,7 +1093,7 @@ public final class ImageIO {
|
||||
}
|
||||
|
||||
while (writerSpiIter.hasNext()) {
|
||||
ImageWriterSpi temp = (ImageWriterSpi) writerSpiIter.next();
|
||||
ImageWriterSpi temp = writerSpiIter.next();
|
||||
if (temp.isOwnWriter(writer)) {
|
||||
writerSpi = temp;
|
||||
break;
|
||||
@ -1109,7 +1109,7 @@ public final class ImageIO {
|
||||
return null;
|
||||
}
|
||||
|
||||
Class readerSpiClass = null;
|
||||
Class<?> readerSpiClass = null;
|
||||
try {
|
||||
readerSpiClass = Class.forName(readerNames[0], true,
|
||||
ClassLoader.getSystemClassLoader());
|
||||
@ -1160,7 +1160,7 @@ public final class ImageIO {
|
||||
throw new IllegalArgumentException("formatName == null!");
|
||||
}
|
||||
|
||||
Iterator iter;
|
||||
Iterator<ImageWriterSpi> iter;
|
||||
// Ensure category is present
|
||||
try {
|
||||
iter = theRegistry.getServiceProviders(ImageWriterSpi.class,
|
||||
@ -1178,9 +1178,9 @@ public final class ImageIO {
|
||||
implements Iterator<ImageTranscoder>
|
||||
{
|
||||
// Contains ImageTranscoderSpis
|
||||
public Iterator iter;
|
||||
public Iterator<ImageTranscoderSpi> iter;
|
||||
|
||||
public ImageTranscoderIterator(Iterator iter) {
|
||||
public ImageTranscoderIterator(Iterator<ImageTranscoderSpi> iter) {
|
||||
this.iter = iter;
|
||||
}
|
||||
|
||||
@ -1190,7 +1190,7 @@ public final class ImageIO {
|
||||
|
||||
public ImageTranscoder next() {
|
||||
ImageTranscoderSpi spi = null;
|
||||
spi = (ImageTranscoderSpi)iter.next();
|
||||
spi = iter.next();
|
||||
return spi.createTranscoderInstance();
|
||||
}
|
||||
|
||||
@ -1249,7 +1249,7 @@ public final class ImageIO {
|
||||
ServiceRegistry.Filter filter =
|
||||
new TranscoderFilter(readerSpi, writerSpi);
|
||||
|
||||
Iterator iter;
|
||||
Iterator<ImageTranscoderSpi> iter;
|
||||
// Ensure category is present
|
||||
try {
|
||||
iter = theRegistry.getServiceProviders(ImageTranscoderSpi.class,
|
||||
@ -1435,12 +1435,12 @@ public final class ImageIO {
|
||||
throw new IllegalArgumentException("stream == null!");
|
||||
}
|
||||
|
||||
Iterator iter = getImageReaders(stream);
|
||||
Iterator<ImageReader> iter = getImageReaders(stream);
|
||||
if (!iter.hasNext()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
ImageReader reader = (ImageReader)iter.next();
|
||||
ImageReader reader = iter.next();
|
||||
ImageReadParam param = reader.getDefaultReadParam();
|
||||
reader.setInput(stream, true, true);
|
||||
BufferedImage bi;
|
||||
|
@ -793,7 +793,7 @@ public abstract class ImageReader {
|
||||
}
|
||||
|
||||
private IIOMetadata getMetadata(String formatName,
|
||||
Set nodeNames,
|
||||
Set<String> nodeNames,
|
||||
boolean wantStream,
|
||||
int imageIndex) throws IOException {
|
||||
if (formatName == null) {
|
||||
@ -1065,10 +1065,10 @@ public abstract class ImageReader {
|
||||
|
||||
BufferedImage im = read(imageIndex, param);
|
||||
|
||||
ArrayList thumbnails = null;
|
||||
ArrayList<BufferedImage> thumbnails = null;
|
||||
int numThumbnails = getNumThumbnails(imageIndex);
|
||||
if (numThumbnails > 0) {
|
||||
thumbnails = new ArrayList();
|
||||
thumbnails = new ArrayList<>();
|
||||
for (int j = 0; j < numThumbnails; j++) {
|
||||
thumbnails.add(readThumbnail(imageIndex, j));
|
||||
}
|
||||
@ -1156,7 +1156,7 @@ public abstract class ImageReader {
|
||||
readAll(Iterator<? extends ImageReadParam> params)
|
||||
throws IOException
|
||||
{
|
||||
List output = new ArrayList();
|
||||
List<IIOImage> output = new ArrayList<>();
|
||||
|
||||
int imageIndex = getMinIndex();
|
||||
|
||||
@ -1187,10 +1187,10 @@ public abstract class ImageReader {
|
||||
break;
|
||||
}
|
||||
|
||||
ArrayList thumbnails = null;
|
||||
ArrayList<BufferedImage> thumbnails = null;
|
||||
int numThumbnails = getNumThumbnails(imageIndex);
|
||||
if (numThumbnails > 0) {
|
||||
thumbnails = new ArrayList();
|
||||
thumbnails = new ArrayList<>();
|
||||
for (int j = 0; j < numThumbnails; 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
|
||||
// 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) {
|
||||
l = new ArrayList();
|
||||
l = new ArrayList<>();
|
||||
}
|
||||
l.add(elt);
|
||||
return l;
|
||||
@ -1808,7 +1808,7 @@ public abstract class ImageReader {
|
||||
|
||||
// Remove an element from a list, discarding the list if the
|
||||
// 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) {
|
||||
return l;
|
||||
}
|
||||
@ -2461,10 +2461,10 @@ public abstract class ImageReader {
|
||||
* If that throws MissingResourceException, then try the
|
||||
* system class loader.
|
||||
*/
|
||||
ClassLoader loader = (ClassLoader)
|
||||
ClassLoader loader =
|
||||
java.security.AccessController.doPrivileged(
|
||||
new java.security.PrivilegedAction() {
|
||||
public Object run() {
|
||||
new java.security.PrivilegedAction<ClassLoader>() {
|
||||
public ClassLoader run() {
|
||||
return Thread.currentThread().getContextClassLoader();
|
||||
}
|
||||
});
|
||||
|
@ -1075,7 +1075,7 @@ public class ImageTypeSpecifier {
|
||||
new Point(0, 0));
|
||||
return new BufferedImage(colorModel, raster,
|
||||
colorModel.isAlphaPremultiplied(),
|
||||
new Hashtable());
|
||||
new Hashtable<>());
|
||||
} catch (NegativeArraySizeException e) {
|
||||
// Exception most likely thrown from a DataBuffer constructor
|
||||
throw new IllegalArgumentException
|
||||
|
@ -1964,10 +1964,10 @@ public abstract class ImageWriter implements ImageTranscoder {
|
||||
* If that throws MissingResourceException, then try the
|
||||
* system class loader.
|
||||
*/
|
||||
ClassLoader loader = (ClassLoader)
|
||||
ClassLoader loader =
|
||||
java.security.AccessController.doPrivileged(
|
||||
new java.security.PrivilegedAction() {
|
||||
public Object run() {
|
||||
new java.security.PrivilegedAction<ClassLoader>() {
|
||||
public ClassLoader run() {
|
||||
return Thread.currentThread().getContextClassLoader();
|
||||
}
|
||||
});
|
||||
|
@ -395,15 +395,15 @@ public abstract class IIOMetadata {
|
||||
throw new IllegalArgumentException("Unsupported format name");
|
||||
}
|
||||
try {
|
||||
Class cls = null;
|
||||
Class<?> cls = null;
|
||||
final Object o = this;
|
||||
|
||||
// firstly we try to use classloader used for loading
|
||||
// the IIOMetadata implemantation for this plugin.
|
||||
ClassLoader loader = (ClassLoader)
|
||||
ClassLoader loader =
|
||||
java.security.AccessController.doPrivileged(
|
||||
new java.security.PrivilegedAction() {
|
||||
public Object run() {
|
||||
new java.security.PrivilegedAction<ClassLoader>() {
|
||||
public ClassLoader run() {
|
||||
return o.getClass().getClassLoader();
|
||||
}
|
||||
});
|
||||
@ -415,10 +415,10 @@ public abstract class IIOMetadata {
|
||||
// we failed to load IIOMetadataFormat class by
|
||||
// using IIOMetadata classloader.Next try is to
|
||||
// use thread context classloader.
|
||||
loader = (ClassLoader)
|
||||
loader =
|
||||
java.security.AccessController.doPrivileged(
|
||||
new java.security.PrivilegedAction() {
|
||||
public Object run() {
|
||||
new java.security.PrivilegedAction<ClassLoader>() {
|
||||
public ClassLoader run() {
|
||||
return Thread.currentThread().getContextClassLoader();
|
||||
}
|
||||
});
|
||||
|
@ -90,7 +90,7 @@ public abstract class IIOMetadataFormatImpl implements IIOMetadataFormat {
|
||||
private String rootName;
|
||||
|
||||
// Element name (String) -> Element
|
||||
private HashMap elementMap = new HashMap();
|
||||
private HashMap<String, Element> elementMap = new HashMap<>();
|
||||
|
||||
class Element {
|
||||
String elementName;
|
||||
@ -100,17 +100,17 @@ public abstract class IIOMetadataFormatImpl implements IIOMetadataFormat {
|
||||
int maxChildren = 0;
|
||||
|
||||
// Child names (Strings)
|
||||
List childList = new ArrayList();
|
||||
List<String> childList = new ArrayList<>();
|
||||
|
||||
// Parent names (Strings)
|
||||
List parentList = new ArrayList();
|
||||
List<String> parentList = new ArrayList<>();
|
||||
|
||||
// List of attribute names in the order they were added
|
||||
List attrList = new ArrayList();
|
||||
List<String> attrList = new ArrayList<>();
|
||||
// Attr name (String) -> Attribute
|
||||
Map attrMap = new HashMap();
|
||||
Map<String, Attribute> attrMap = new HashMap<>();
|
||||
|
||||
ObjectValue objectValue;
|
||||
ObjectValue<?> objectValue;
|
||||
}
|
||||
|
||||
class Attribute {
|
||||
@ -122,7 +122,7 @@ public abstract class IIOMetadataFormatImpl implements IIOMetadataFormat {
|
||||
String defaultValue = null;
|
||||
|
||||
// enumeration
|
||||
List enumeratedValues;
|
||||
List<String> enumeratedValues;
|
||||
|
||||
// range
|
||||
String minValue;
|
||||
@ -133,17 +133,18 @@ public abstract class IIOMetadataFormatImpl implements IIOMetadataFormat {
|
||||
int listMaxLength;
|
||||
}
|
||||
|
||||
class ObjectValue {
|
||||
class ObjectValue<T> {
|
||||
int valueType = VALUE_NONE;
|
||||
Class classType = null;
|
||||
Object defaultValue = null;
|
||||
// ? extends T So that ObjectValue<Object> can take Class<?>
|
||||
Class<? extends T> classType = null;
|
||||
T defaultValue = null;
|
||||
|
||||
// Meaningful only if valueType == VALUE_ENUMERATION
|
||||
List enumeratedValues = null;
|
||||
List<? extends T> enumeratedValues = null;
|
||||
|
||||
// Meaningful only if valueType == VALUE_RANGE
|
||||
Comparable minValue = null;
|
||||
Comparable maxValue = null;
|
||||
Comparable<? super T> minValue = null;
|
||||
Comparable<? super T> maxValue = null;
|
||||
|
||||
// Meaningful only if valueType == VALUE_LIST
|
||||
int arrayMinLength = 0;
|
||||
@ -272,7 +273,7 @@ public abstract class IIOMetadataFormatImpl implements IIOMetadataFormat {
|
||||
if (mustAppear && (elementName == null)) {
|
||||
throw new IllegalArgumentException("element name is null!");
|
||||
}
|
||||
Element element = (Element)elementMap.get(elementName);
|
||||
Element element = elementMap.get(elementName);
|
||||
if (mustAppear && (element == null)) {
|
||||
throw new IllegalArgumentException("No such element: " +
|
||||
elementName);
|
||||
@ -287,7 +288,7 @@ public abstract class IIOMetadataFormatImpl implements IIOMetadataFormat {
|
||||
// Utility method for locating an attribute
|
||||
private Attribute getAttribute(String elementName, String attrName) {
|
||||
Element element = getElement(elementName);
|
||||
Attribute attr = (Attribute)element.attrMap.get(attrName);
|
||||
Attribute attr = element.attrMap.get(attrName);
|
||||
if (attr == null) {
|
||||
throw new IllegalArgumentException("No such attribute \"" +
|
||||
attrName + "\"!");
|
||||
@ -408,9 +409,9 @@ public abstract class IIOMetadataFormatImpl implements IIOMetadataFormat {
|
||||
protected void removeElement(String elementName) {
|
||||
Element element = getElement(elementName, false);
|
||||
if (element != null) {
|
||||
Iterator iter = element.parentList.iterator();
|
||||
Iterator<String> iter = element.parentList.iterator();
|
||||
while (iter.hasNext()) {
|
||||
String parentName = (String)iter.next();
|
||||
String parentName = iter.next();
|
||||
Element parent = getElement(parentName, false);
|
||||
if (parent != null) {
|
||||
parent.childList.remove(elementName);
|
||||
@ -514,7 +515,7 @@ public abstract class IIOMetadataFormatImpl implements IIOMetadataFormat {
|
||||
if (enumeratedValues.size() == 0) {
|
||||
throw new IllegalArgumentException("enumeratedValues is empty!");
|
||||
}
|
||||
Iterator iter = enumeratedValues.iterator();
|
||||
Iterator<String> iter = enumeratedValues.iterator();
|
||||
while (iter.hasNext()) {
|
||||
Object o = iter.next();
|
||||
if (o == null) {
|
||||
@ -681,7 +682,7 @@ public abstract class IIOMetadataFormatImpl implements IIOMetadataFormat {
|
||||
String attrName,
|
||||
boolean hasDefaultValue,
|
||||
boolean defaultValue) {
|
||||
List values = new ArrayList();
|
||||
List<String> values = new ArrayList<>();
|
||||
values.add("TRUE");
|
||||
values.add("FALSE");
|
||||
|
||||
@ -740,7 +741,7 @@ public abstract class IIOMetadataFormatImpl implements IIOMetadataFormat {
|
||||
T defaultValue)
|
||||
{
|
||||
Element element = getElement(elementName);
|
||||
ObjectValue obj = new ObjectValue();
|
||||
ObjectValue<T> obj = new ObjectValue<>();
|
||||
obj.valueType = VALUE_ARBITRARY;
|
||||
obj.classType = classType;
|
||||
obj.defaultValue = defaultValue;
|
||||
@ -793,7 +794,7 @@ public abstract class IIOMetadataFormatImpl implements IIOMetadataFormat {
|
||||
if (enumeratedValues.size() == 0) {
|
||||
throw new IllegalArgumentException("enumeratedValues is empty!");
|
||||
}
|
||||
Iterator iter = enumeratedValues.iterator();
|
||||
Iterator<? extends T> iter = enumeratedValues.iterator();
|
||||
while (iter.hasNext()) {
|
||||
Object o = iter.next();
|
||||
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.classType = classType;
|
||||
obj.defaultValue = defaultValue;
|
||||
@ -854,7 +855,7 @@ public abstract class IIOMetadataFormatImpl implements IIOMetadataFormat {
|
||||
boolean maxInclusive)
|
||||
{
|
||||
Element element = getElement(elementName);
|
||||
ObjectValue obj = new ObjectValue();
|
||||
ObjectValue<T> obj = new ObjectValue<>();
|
||||
obj.valueType = VALUE_RANGE;
|
||||
if (minInclusive) {
|
||||
obj.valueType |= VALUE_RANGE_MIN_INCLUSIVE_MASK;
|
||||
@ -895,7 +896,7 @@ public abstract class IIOMetadataFormatImpl implements IIOMetadataFormat {
|
||||
int arrayMinLength,
|
||||
int arrayMaxLength) {
|
||||
Element element = getElement(elementName);
|
||||
ObjectValue obj = new ObjectValue();
|
||||
ObjectValue<Object> obj = new ObjectValue<>();
|
||||
obj.valueType = VALUE_LIST;
|
||||
obj.classType = classType;
|
||||
obj.arrayMinLength = arrayMinLength;
|
||||
@ -962,10 +963,10 @@ public abstract class IIOMetadataFormatImpl implements IIOMetadataFormat {
|
||||
* If that throws MissingResourceException, then try the
|
||||
* system class loader.
|
||||
*/
|
||||
ClassLoader loader = (ClassLoader)
|
||||
ClassLoader loader =
|
||||
java.security.AccessController.doPrivileged(
|
||||
new java.security.PrivilegedAction() {
|
||||
public Object run() {
|
||||
new java.security.PrivilegedAction<ClassLoader>() {
|
||||
public ClassLoader run() {
|
||||
return Thread.currentThread().getContextClassLoader();
|
||||
}
|
||||
});
|
||||
@ -1037,17 +1038,17 @@ public abstract class IIOMetadataFormatImpl implements IIOMetadataFormat {
|
||||
if (element.childPolicy == CHILD_POLICY_EMPTY) {
|
||||
return null;
|
||||
}
|
||||
return (String[])element.childList.toArray(new String[0]);
|
||||
return element.childList.toArray(new String[0]);
|
||||
}
|
||||
|
||||
// Attributes
|
||||
|
||||
public String[] getAttributeNames(String elementName) {
|
||||
Element element = getElement(elementName);
|
||||
List names = element.attrList;
|
||||
List<String> names = element.attrList;
|
||||
|
||||
String[] result = new String[names.size()];
|
||||
return (String[])names.toArray(result);
|
||||
return names.toArray(result);
|
||||
}
|
||||
|
||||
public int getAttributeValueType(String elementName, String attrName) {
|
||||
@ -1079,10 +1080,9 @@ public abstract class IIOMetadataFormatImpl implements IIOMetadataFormat {
|
||||
("Attribute not an enumeration!");
|
||||
}
|
||||
|
||||
List values = attr.enumeratedValues;
|
||||
Iterator iter = values.iterator();
|
||||
List<String> values = attr.enumeratedValues;
|
||||
String[] result = new String[values.size()];
|
||||
return (String[])values.toArray(result);
|
||||
return values.toArray(result);
|
||||
}
|
||||
|
||||
public String getAttributeMinValue(String elementName, String attrName) {
|
||||
@ -1170,7 +1170,7 @@ public abstract class IIOMetadataFormatImpl implements IIOMetadataFormat {
|
||||
if (attrName == null) {
|
||||
throw new IllegalArgumentException("attrName == null!");
|
||||
}
|
||||
Attribute attr = (Attribute)element.attrMap.get(attrName);
|
||||
Attribute attr = element.attrMap.get(attrName);
|
||||
if (attr == null) {
|
||||
throw new IllegalArgumentException("No such attribute!");
|
||||
}
|
||||
@ -1179,9 +1179,9 @@ public abstract class IIOMetadataFormatImpl implements IIOMetadataFormat {
|
||||
return getResource(key, locale);
|
||||
}
|
||||
|
||||
private ObjectValue getObjectValue(String elementName) {
|
||||
private ObjectValue<?> getObjectValue(String elementName) {
|
||||
Element element = getElement(elementName);
|
||||
ObjectValue objv = element.objectValue;
|
||||
ObjectValue<?> objv = element.objectValue;
|
||||
if (objv == null) {
|
||||
throw new IllegalArgumentException("No object within element " +
|
||||
elementName + "!");
|
||||
@ -1191,7 +1191,7 @@ public abstract class IIOMetadataFormatImpl implements IIOMetadataFormat {
|
||||
|
||||
public int getObjectValueType(String elementName) {
|
||||
Element element = getElement(elementName);
|
||||
ObjectValue objv = element.objectValue;
|
||||
ObjectValue<?> objv = element.objectValue;
|
||||
if (objv == null) {
|
||||
return VALUE_NONE;
|
||||
}
|
||||
@ -1199,27 +1199,27 @@ public abstract class IIOMetadataFormatImpl implements IIOMetadataFormat {
|
||||
}
|
||||
|
||||
public Class<?> getObjectClass(String elementName) {
|
||||
ObjectValue objv = getObjectValue(elementName);
|
||||
ObjectValue<?> objv = getObjectValue(elementName);
|
||||
return objv.classType;
|
||||
}
|
||||
|
||||
public Object getObjectDefaultValue(String elementName) {
|
||||
ObjectValue objv = getObjectValue(elementName);
|
||||
ObjectValue<?> objv = getObjectValue(elementName);
|
||||
return objv.defaultValue;
|
||||
}
|
||||
|
||||
public Object[] getObjectEnumerations(String elementName) {
|
||||
ObjectValue objv = getObjectValue(elementName);
|
||||
ObjectValue<?> objv = getObjectValue(elementName);
|
||||
if (objv.valueType != VALUE_ENUMERATION) {
|
||||
throw new IllegalArgumentException("Not an enumeration!");
|
||||
}
|
||||
List vlist = objv.enumeratedValues;
|
||||
List<?> vlist = objv.enumeratedValues;
|
||||
Object[] values = new Object[vlist.size()];
|
||||
return vlist.toArray(values);
|
||||
}
|
||||
|
||||
public Comparable<?> getObjectMinValue(String elementName) {
|
||||
ObjectValue objv = getObjectValue(elementName);
|
||||
ObjectValue<?> objv = getObjectValue(elementName);
|
||||
if ((objv.valueType & VALUE_RANGE) != VALUE_RANGE) {
|
||||
throw new IllegalArgumentException("Not a range!");
|
||||
}
|
||||
@ -1227,7 +1227,7 @@ public abstract class IIOMetadataFormatImpl implements IIOMetadataFormat {
|
||||
}
|
||||
|
||||
public Comparable<?> getObjectMaxValue(String elementName) {
|
||||
ObjectValue objv = getObjectValue(elementName);
|
||||
ObjectValue<?> objv = getObjectValue(elementName);
|
||||
if ((objv.valueType & VALUE_RANGE) != VALUE_RANGE) {
|
||||
throw new IllegalArgumentException("Not a range!");
|
||||
}
|
||||
@ -1235,7 +1235,7 @@ public abstract class IIOMetadataFormatImpl implements IIOMetadataFormat {
|
||||
}
|
||||
|
||||
public int getObjectArrayMinLength(String elementName) {
|
||||
ObjectValue objv = getObjectValue(elementName);
|
||||
ObjectValue<?> objv = getObjectValue(elementName);
|
||||
if (objv.valueType != VALUE_LIST) {
|
||||
throw new IllegalArgumentException("Not a list!");
|
||||
}
|
||||
@ -1243,7 +1243,7 @@ public abstract class IIOMetadataFormatImpl implements IIOMetadataFormat {
|
||||
}
|
||||
|
||||
public int getObjectArrayMaxLength(String elementName) {
|
||||
ObjectValue objv = getObjectValue(elementName);
|
||||
ObjectValue<?> objv = getObjectValue(elementName);
|
||||
if (objv.valueType != VALUE_LIST) {
|
||||
throw new IllegalArgumentException("Not a list!");
|
||||
}
|
||||
|
@ -50,9 +50,9 @@ class IIODOMException extends DOMException {
|
||||
|
||||
class IIONamedNodeMap implements NamedNodeMap {
|
||||
|
||||
List nodes;
|
||||
List<? extends Node> nodes;
|
||||
|
||||
public IIONamedNodeMap(List nodes) {
|
||||
public IIONamedNodeMap(List<? extends Node> nodes) {
|
||||
this.nodes = nodes;
|
||||
}
|
||||
|
||||
@ -61,9 +61,9 @@ class IIONamedNodeMap implements NamedNodeMap {
|
||||
}
|
||||
|
||||
public Node getNamedItem(String name) {
|
||||
Iterator iter = nodes.iterator();
|
||||
Iterator<? extends Node> iter = nodes.iterator();
|
||||
while (iter.hasNext()) {
|
||||
Node node = (Node)iter.next();
|
||||
Node node = iter.next();
|
||||
if (name.equals(node.getNodeName())) {
|
||||
return node;
|
||||
}
|
||||
@ -73,7 +73,7 @@ class IIONamedNodeMap implements NamedNodeMap {
|
||||
}
|
||||
|
||||
public Node item(int index) {
|
||||
Node node = (Node)nodes.get(index);
|
||||
Node node = nodes.get(index);
|
||||
return node;
|
||||
}
|
||||
|
||||
@ -111,9 +111,9 @@ class IIONamedNodeMap implements NamedNodeMap {
|
||||
|
||||
class IIONodeList implements NodeList {
|
||||
|
||||
List nodes;
|
||||
List<? extends Node> nodes;
|
||||
|
||||
public IIONodeList(List nodes) {
|
||||
public IIONodeList(List<? extends Node> nodes) {
|
||||
this.nodes = nodes;
|
||||
}
|
||||
|
||||
@ -125,7 +125,7 @@ class IIONodeList implements NodeList {
|
||||
if (index < 0 || index > nodes.size()) {
|
||||
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
|
||||
* attributes.
|
||||
*/
|
||||
private List attributes = new ArrayList();
|
||||
private List<IIOAttr> attributes = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Constructs an empty <code>IIOMetadataNode</code>.
|
||||
@ -789,7 +789,7 @@ public class IIOMetadataNode implements Element, NodeList {
|
||||
private void removeAttribute(String name, boolean checkPresent) {
|
||||
int numAttributes = attributes.size();
|
||||
for (int i = 0; i < numAttributes; i++) {
|
||||
IIOAttr attr = (IIOAttr)attributes.get(i);
|
||||
IIOAttr attr = attributes.get(i);
|
||||
if (name.equals(attr.getName())) {
|
||||
attr.setOwnerElement(null);
|
||||
attributes.remove(i);
|
||||
@ -873,12 +873,12 @@ public class IIOMetadataNode implements Element, NodeList {
|
||||
}
|
||||
|
||||
public NodeList getElementsByTagName(String name) {
|
||||
List l = new ArrayList();
|
||||
List<Node> l = new ArrayList<>();
|
||||
getElementsByTagName(name, l);
|
||||
return new IIONodeList(l);
|
||||
}
|
||||
|
||||
private void getElementsByTagName(String name, List l) {
|
||||
private void getElementsByTagName(String name, List<Node> l) {
|
||||
if (nodeName.equals(name)) {
|
||||
l.add(this);
|
||||
}
|
||||
|
@ -43,9 +43,9 @@ import javax.imageio.IIOException;
|
||||
*/
|
||||
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;
|
||||
|
||||
@ -798,14 +798,14 @@ public abstract class ImageInputStreamImpl implements ImageInputStream {
|
||||
return;
|
||||
}
|
||||
|
||||
long pos = ((Long)markByteStack.pop()).longValue();
|
||||
long pos = markByteStack.pop().longValue();
|
||||
if (pos < flushedPos) {
|
||||
throw new IIOException
|
||||
("Previous marked position has been discarded!");
|
||||
}
|
||||
seek(pos);
|
||||
|
||||
int offset = ((Integer)markBitStack.pop()).intValue();
|
||||
int offset = markBitStack.pop().intValue();
|
||||
setBitOffset(offset);
|
||||
}
|
||||
|
||||
|
@ -58,7 +58,7 @@ class MemoryCache {
|
||||
|
||||
private static final int BUFFER_LENGTH = 8192;
|
||||
|
||||
private ArrayList cache = new ArrayList();
|
||||
private ArrayList<byte[]> cache = new ArrayList<>();
|
||||
|
||||
private long cacheStart = 0L;
|
||||
|
||||
@ -74,7 +74,7 @@ class MemoryCache {
|
||||
// contiguous data...
|
||||
throw new IOException("Cache addressing limit exceeded!");
|
||||
}
|
||||
return (byte[])cache.get((int)blockOffset);
|
||||
return cache.get((int)blockOffset);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user