src/share/classes/com/sun/imageio/plugins/gif/GIFImageReader.java

Print this page
rev 9230 : imported patch 8033716

@@ -70,11 +70,11 @@
     GIFImageMetadata imageMetadata = null;
 
     // A List of Longs indicating the stream positions of the
     // start of the metadata for each image.  Entries are added
     // as needed.
-    List imageStartPosition = new ArrayList();
+    List<Long> imageStartPosition = new ArrayList<>();
 
     // Length of metadata for image at 'currIndex', valid only if
     // imageMetadata != null.
     int imageMetadataLength;
 

@@ -225,20 +225,20 @@
                     1, 1, bits);
         }
         return new ImageTypeSpecifier(colorModel, sampleModel);
     }
 
-    public Iterator getImageTypes(int imageIndex) throws IIOException {
+    public Iterator<ImageTypeSpecifier> getImageTypes(int imageIndex) throws IIOException {
         checkIndex(imageIndex);
 
         int index = locateImage(imageIndex);
         if (index != imageIndex) {
             throw new IndexOutOfBoundsException();
         }
         readMetadata();
 
-        List l = new ArrayList(1);
+        List<ImageTypeSpecifier> l = new ArrayList<>(1);
 
         byte[] colorTable;
         if (imageMetadata.localColorTable != null) {
             colorTable = imageMetadata.localColorTable;
             fallbackColorTable = imageMetadata.localColorTable;

@@ -603,11 +603,11 @@
         try {
             // Find closest known index
             int index = Math.min(imageIndex, imageStartPosition.size() - 1);
 
             // Seek to that position
-            Long l = (Long)imageStartPosition.get(index);
+            Long l = imageStartPosition.get(index);
             stream.seek(l.longValue());
 
             // Skip images until at desired index or last image found
             while (index < imageIndex) {
                 if (!skipImage()) {

@@ -729,11 +729,11 @@
                             stream.readUnsignedByte();
                         imageMetadata.text = concatenateBlocks();
                     } else if (label == 0xfe) { // Comment extension
                         byte[] comment = concatenateBlocks();
                         if (imageMetadata.comments == null) {
-                            imageMetadata.comments = new ArrayList();
+                            imageMetadata.comments = new ArrayList<>();
                         }
                         imageMetadata.comments.add(comment);
                     } else if (label == 0xff) { // Application extension
                         int blockSize = stream.readUnsignedByte();
                         byte[] applicationID = new byte[8];

@@ -760,14 +760,14 @@
                             applicationData = data;
                         }
 
                         // Init lists if necessary
                         if (imageMetadata.applicationIDs == null) {
-                            imageMetadata.applicationIDs = new ArrayList();
+                            imageMetadata.applicationIDs = new ArrayList<>();
                             imageMetadata.authenticationCodes =
-                                new ArrayList();
-                            imageMetadata.applicationData = new ArrayList();
+                                new ArrayList<>();
+                            imageMetadata.applicationData = new ArrayList<>();
                         }
                         imageMetadata.applicationIDs.add(applicationID);
                         imageMetadata.authenticationCodes.add(authCode);
                         imageMetadata.applicationData.add(applicationData);
                     } else {

@@ -866,11 +866,11 @@
         if (param == null) {
             param = getDefaultReadParam();
         }
 
         // Initialize the destination image
-        Iterator imageTypes = getImageTypes(imageIndex);
+        Iterator<ImageTypeSpecifier> imageTypes = getImageTypes(imageIndex);
         this.theImage = getDestination(param,
                                        imageTypes,
                                        imageMetadata.imageWidth,
                                        imageMetadata.imageHeight);
         this.theTile = theImage.getWritableTile(0, 0);

@@ -1029,11 +1029,11 @@
     private void resetStreamSettings() {
         gotHeader = false;
         streamMetadata = null;
         currIndex = -1;
         imageMetadata = null;
-        imageStartPosition = new ArrayList();
+        imageStartPosition = new ArrayList<>();
         numImages = -1;
 
         // No need to reinitialize 'block'
         blockLength = 0;
         bitPos = 0;