commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ebo...@apache.org
Subject svn commit: r1221504 [1/2] - in /commons/proper/sanselan/trunk: ./ src/main/java/org/apache/commons/sanselan/ src/main/java/org/apache/commons/sanselan/common/ src/main/java/org/apache/commons/sanselan/common/itu_t4/ src/main/java/org/apache/commons/sa...
Date Tue, 20 Dec 2011 22:09:50 GMT
Author: ebourg
Date: Tue Dec 20 22:09:48 2011
New Revision: 1221504

URL: http://svn.apache.org/viewvc?rev=1221504&view=rev
Log:
First stab at generifying the API

Modified:
    commons/proper/sanselan/trunk/pom.xml
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/FormatCompliance.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/ImageInfo.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/ImageParser.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/Sanselan.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/common/BasicCParser.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/common/IImageMetadata.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/common/ImageMetadata.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/common/itu_t4/HuffmanTree.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/common/mylzw/MyLzwCompressor.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/bmp/BmpImageParser.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/dcx/DcxImageParser.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/gif/GenericGifBlock.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/gif/GifImageParser.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/gif/ImageContents.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/icns/IcnsDecoder.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/icns/IcnsImageParser.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/ico/IcoImageParser.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/JpegImageMetadata.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/decoder/JpegDecoder.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/iptc/IptcTypeLookup.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/segments/DhtSegment.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/segments/DqtSegment.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/xmp/JpegRewriter.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/pcx/PcxImageParser.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/png/PngImageInfo.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/png/PngImageParser.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/pnm/PnmImageParser.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/psd/PsdImageParser.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/TiffContents.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/TiffDirectory.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/TiffField.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/TiffImageMetadata.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/TiffImageParser.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/TiffReader.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/write/TiffImageWriterBase.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/write/TiffImageWriterLossless.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/write/TiffOutputDirectory.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/write/TiffOutputSet.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/write/TiffOutputSummary.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/wbmp/WbmpImageParser.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/xbm/XbmImageParser.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/xpm/XpmImageParser.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/palette/MedianCutQuantizer.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/palette/PaletteFactory.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/palette/QuantizedPalette.java

Modified: commons/proper/sanselan/trunk/pom.xml
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/pom.xml?rev=1221504&r1=1221503&r2=1221504&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/pom.xml (original)
+++ commons/proper/sanselan/trunk/pom.xml Tue Dec 20 22:09:48 2011
@@ -61,8 +61,8 @@
   </prerequisites>
 
   <properties>
-    <maven.compile.source>1.4</maven.compile.source>
-    <maven.compile.target>1.4</maven.compile.target>
+    <maven.compile.source>1.5</maven.compile.source>
+    <maven.compile.target>1.5</maven.compile.target>
     <commons.componentid>sanselan</commons.componentid>
     <commons.release.version>0.98</commons.release.version>
     <commons.jira.id>SANSELAN</commons.jira.id>

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/FormatCompliance.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/FormatCompliance.java?rev=1221504&r1=1221503&r2=1221504&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/FormatCompliance.java (original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/FormatCompliance.java Tue Dec 20 22:09:48 2011
@@ -26,7 +26,7 @@ public class FormatCompliance
 {
     private final boolean failOnError;
     private final String description;
-    private final List comments = new ArrayList();
+    private final List<String> comments = new ArrayList<String>();
 
     public FormatCompliance(String description)
     {

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/ImageInfo.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/ImageInfo.java?rev=1221504&r1=1221503&r2=1221504&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/ImageInfo.java (original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/ImageInfo.java Tue Dec 20 22:09:48 2011
@@ -30,7 +30,7 @@ public class ImageInfo
     private final String formatDetails; // ie version
 
     private final int bitsPerPixel;
-    private final List comments;
+    private final List<String> comments;
 
     private final ImageFormat format;
     private final String formatName;
@@ -72,7 +72,7 @@ public class ImageInfo
     private final String compressionAlgorithm;
 
     public ImageInfo(String formatDetails, int bitsPerPixel,
-            List comments, ImageFormat format, String formatName,
+            List<String> comments, ImageFormat format, String formatName,
             int height, String mimeType, int numberOfImages,
             int physicalHeightDpi, float physicalHeightInch,
             int physicalWidthDpi, float physicalWidthInch, int width,
@@ -116,9 +116,9 @@ public class ImageInfo
      * Returns a list of comments from the image file. <p/> This is mostly
      * obsolete.
      */
-    public List getComments()
+    public List<String> getComments()
     {
-        return new ArrayList(comments);
+        return new ArrayList<String>(comments);
     }
 
     /**
@@ -317,7 +317,7 @@ public class ImageInfo
         pw.println("Comments: " + comments.size());
         for (int i = 0; i < comments.size(); i++)
         {
-            String s = (String) comments.get(i);
+            String s = comments.get(i);
             pw.println("\t" + i + ": '" + s + "'");
 
         }

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/ImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/ImageParser.java?rev=1221504&r1=1221503&r2=1221504&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/ImageParser.java (original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/ImageParser.java Tue Dec 20 22:09:48 2011
@@ -159,25 +159,25 @@ public abstract class ImageParser extend
         return getFormatCompliance(new ByteSourceFile(file));
     }
 
-    public List getAllBufferedImages(ByteSource byteSource)
+    public List<BufferedImage> getAllBufferedImages(ByteSource byteSource)
             throws ImageReadException, IOException
     {
         BufferedImage bi = getBufferedImage(byteSource, null);
 
-        List result = new ArrayList();
+        List<BufferedImage> result = new ArrayList<BufferedImage>();
 
         result.add(bi);
 
         return result;
     }
 
-    public final List getAllBufferedImages(byte bytes[])
+    public final List<BufferedImage> getAllBufferedImages(byte bytes[])
             throws ImageReadException, IOException
     {
         return getAllBufferedImages(new ByteSourceArray(bytes));
     }
 
-    public final List getAllBufferedImages(File file)
+    public final List<BufferedImage> getAllBufferedImages(File file)
             throws ImageReadException, IOException
     {
         if (!canAcceptExtension(file))

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/Sanselan.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/Sanselan.java?rev=1221504&r1=1221503&r2=1221504&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/Sanselan.java (original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/Sanselan.java Tue Dec 20 22:09:48 2011
@@ -1073,7 +1073,7 @@ public abstract class Sanselan implement
      *            Filename associated with image data (optional).
      * @return A vector of BufferedImages.
      */
-    public static List getAllBufferedImages(InputStream is, String filename)
+    public static List<BufferedImage> getAllBufferedImages(InputStream is, String filename)
             throws ImageReadException, IOException {
         return getAllBufferedImages(new ByteSourceInputStream(is, filename));
     }
@@ -1089,7 +1089,7 @@ public abstract class Sanselan implement
      *            Byte array containing an image file.
      * @return A vector of BufferedImages.
      */
-    public static List getAllBufferedImages(byte bytes[])
+    public static List<BufferedImage> getAllBufferedImages(byte bytes[])
             throws ImageReadException, IOException {
         return getAllBufferedImages(new ByteSourceArray(bytes));
     }
@@ -1105,12 +1105,12 @@ public abstract class Sanselan implement
      *            File containing image data.
      * @return A vector of BufferedImages.
      */
-    public static List getAllBufferedImages(File file)
+    public static List<BufferedImage> getAllBufferedImages(File file)
             throws ImageReadException, IOException {
         return getAllBufferedImages(new ByteSourceFile(file));
     }
 
-    private static List getAllBufferedImages(ByteSource byteSource)
+    private static List<BufferedImage> getAllBufferedImages(ByteSource byteSource)
             throws ImageReadException, IOException {
         ImageParser imageParser = getImageParser(byteSource);
 

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/common/BasicCParser.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/common/BasicCParser.java?rev=1221504&r1=1221503&r2=1221504&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/common/BasicCParser.java (original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/common/BasicCParser.java Tue Dec 20 22:09:48 2011
@@ -112,7 +112,7 @@ public class BasicCParser
     }
 
     public static ByteArrayOutputStream preprocess(InputStream is,
-            StringBuilder firstComment, Map defines)
+            StringBuilder firstComment, Map<String, String> defines)
             throws IOException, ImageReadException
     {
         boolean inString = false;

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/common/IImageMetadata.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/common/IImageMetadata.java?rev=1221504&r1=1221503&r2=1221504&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/common/IImageMetadata.java (original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/common/IImageMetadata.java Tue Dec 20 22:09:48 2011
@@ -22,7 +22,7 @@ public interface IImageMetadata
 {
     public String toString(String prefix);
 
-    public List getItems();
+    public List<? extends IImageMetadataItem> getItems();
 
     public interface IImageMetadataItem
     {

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/common/ImageMetadata.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/common/ImageMetadata.java?rev=1221504&r1=1221503&r2=1221504&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/common/ImageMetadata.java (original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/common/ImageMetadata.java Tue Dec 20 22:09:48 2011
@@ -21,8 +21,7 @@ import java.util.List;
 
 public class ImageMetadata implements IImageMetadata
 {
-
-    private final List items = new ArrayList();
+    private final List<IImageMetadataItem> items = new ArrayList<IImageMetadataItem>();
 
     public void add(String keyword, String text)
     {
@@ -34,13 +33,12 @@ public class ImageMetadata implements II
         items.add(item);
     }
 
-    public List getItems()
+    public List<? extends IImageMetadataItem> getItems()
     {
-        return new ArrayList(items);
+        return new ArrayList<IImageMetadataItem>(items);
     }
 
-    protected static final String newline = System
-            .getProperty("line.separator");
+    protected static final String newline = System.getProperty("line.separator");
 
     public String toString()
     {
@@ -60,7 +58,7 @@ public class ImageMetadata implements II
             //            if (null != prefix)
             //                result.append(prefix);
 
-            ImageMetadata.IImageMetadataItem item = (ImageMetadata.IImageMetadataItem) items
+            ImageMetadata.IImageMetadataItem item = items
                     .get(i);
             result.append(item.toString(prefix + "\t"));
 

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/common/itu_t4/HuffmanTree.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/common/itu_t4/HuffmanTree.java?rev=1221504&r1=1221503&r2=1221504&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/common/itu_t4/HuffmanTree.java (original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/common/itu_t4/HuffmanTree.java Tue Dec 20 22:09:48 2011
@@ -30,7 +30,7 @@ class HuffmanTree {
         boolean isEmpty = true;
         Object value = null;
     }
-    private List nodes = new ArrayList();
+    private List<Node> nodes = new ArrayList<Node>();
 
     public final void insert(String pattern, Object value) throws HuffmanTreeException {
         int position = 0;
@@ -57,14 +57,14 @@ class HuffmanTree {
         while (position >= nodes.size()) {
             nodes.add(new Node());
         }
-        Node node = (Node) nodes.get(position);
+        Node node = nodes.get(position);
         node.isEmpty = false;
         return node;
     }
     
     public final Object decode(BitInputStreamFlexible bitStream) throws HuffmanTreeException {
         int position = 0;
-        Node node = (Node) nodes.get(0);
+        Node node = nodes.get(0);
         while (node.value == null) {
             int nextBit;
             try {
@@ -80,7 +80,7 @@ class HuffmanTree {
             if (position >= nodes.size()) {
                 throw new HuffmanTreeException("Invalid bit pattern");
             }
-            node = (Node) nodes.get(position);
+            node = nodes.get(position);
             if (node.isEmpty) {
                 throw new HuffmanTreeException("Invalid bit pattern");
             }

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/common/mylzw/MyLzwCompressor.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/common/mylzw/MyLzwCompressor.java?rev=1221504&r1=1221503&r2=1221504&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/common/mylzw/MyLzwCompressor.java (original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/common/mylzw/MyLzwCompressor.java Tue Dec 20 22:09:48 2011
@@ -60,7 +60,7 @@ public class MyLzwCompressor
         InitializeStringTable();
     }
 
-    private final Map map = new HashMap();
+    private final Map<Object, Integer> map = new HashMap<Object, Integer>();
 
     private final void InitializeStringTable()
     {

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/bmp/BmpImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/bmp/BmpImageParser.java?rev=1221504&r1=1221503&r2=1221504&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/bmp/BmpImageParser.java (original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/bmp/BmpImageParser.java Tue Dec 20 22:09:48 2011
@@ -607,7 +607,7 @@ public class BmpImageParser extends Imag
         int height = bhi.height;
         int width = bhi.width;
 
-        List comments = new ArrayList();
+        List<String> comments = new ArrayList<String>();
         // TODO: comments...
 
         int bitsPerPixel = bhi.bitsPerPixel;

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/dcx/DcxImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/dcx/DcxImageParser.java?rev=1221504&r1=1221503&r2=1221504&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/dcx/DcxImageParser.java (original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/dcx/DcxImageParser.java Tue Dec 20 22:09:48 2011
@@ -139,7 +139,7 @@ public class DcxImageParser extends Imag
         {
             is = byteSource.getInputStream();
             int id = read4Bytes("Id", is, "Not a Valid DCX File");
-            List pageTable = new ArrayList(1024);
+            List<Integer> pageTable = new ArrayList<Integer>(1024);
             for (int i = 0; i < 1024; i++)
             {
                 int pageOffset = read4Bytes("PageTable", is, "Not a Valid DCX File");
@@ -185,17 +185,17 @@ public class DcxImageParser extends Imag
     public final BufferedImage getBufferedImage(ByteSource byteSource,
             Map params) throws ImageReadException, IOException
     {
-        List list = getAllBufferedImages(byteSource);
+        List<BufferedImage> list = getAllBufferedImages(byteSource);
         if (list.isEmpty())
             return null;
-        return (BufferedImage) list.get(0);
+        return list.get(0);
     }
 
-    public List getAllBufferedImages(ByteSource byteSource)
+    public List<BufferedImage> getAllBufferedImages(ByteSource byteSource)
             throws ImageReadException, IOException
     {
         DcxHeader dcxHeader = readDcxHeader(byteSource);
-        List images = new ArrayList();
+        List<BufferedImage> images = new ArrayList<BufferedImage>();
         PcxImageParser pcxImageParser = new PcxImageParser();
         for (int i = 0; i < dcxHeader.pageTable.length; i++)
         {

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/gif/GenericGifBlock.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/gif/GenericGifBlock.java?rev=1221504&r1=1221503&r2=1221504&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/gif/GenericGifBlock.java (original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/gif/GenericGifBlock.java Tue Dec 20 22:09:48 2011
@@ -22,9 +22,9 @@ import java.util.List;
 
 class GenericGifBlock extends GifBlock
 {
-    public final List subblocks;
+    public final List<byte[]> subblocks;
 
-    public GenericGifBlock(int blockCode, List subblocks)
+    public GenericGifBlock(int blockCode, List<byte[]> subblocks)
     {
         super(blockCode);
 
@@ -43,7 +43,7 @@ class GenericGifBlock extends GifBlock
 
         for (int i = 0; i < subblocks.size(); i++)
         {
-            byte subblock[] = (byte[]) subblocks.get(i);
+            byte subblock[] = subblocks.get(i);
             if(includeLengths && i>0)
                 out.write(subblock.length);
             out.write(subblock);

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/gif/GifImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/gif/GifImageParser.java?rev=1221504&r1=1221503&r2=1221504&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/gif/GifImageParser.java (original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/gif/GifImageParser.java Tue Dec 20 22:09:48 2011
@@ -202,7 +202,7 @@ public class GifImageParser extends Imag
     protected GenericGifBlock readGenericGIFBlock(InputStream is, int code,
             byte first[]) throws IOException
     {
-        List subblocks = new ArrayList();
+        List<byte[]> subblocks = new ArrayList<byte[]>();
 
         if (first != null)
             subblocks.add(first);
@@ -229,11 +229,11 @@ public class GifImageParser extends Imag
     private final static int XMP_COMPLETE_CODE = (EXTENSION_CODE << 8)
             | XMP_EXTENSION;
 
-    private List readBlocks(GifHeaderInfo ghi, InputStream is,
-            boolean stopBeforeImageData, FormatCompliance formatCompliance)
+    private List<GifBlock> readBlocks(GifHeaderInfo ghi, InputStream is,
+                                      boolean stopBeforeImageData, FormatCompliance formatCompliance)
             throws ImageReadException, IOException
     {
-        List result = new ArrayList();
+        List<GifBlock> result = new ArrayList<GifBlock>();
 
         while (true)
         {
@@ -456,11 +456,11 @@ public class GifImageParser extends Imag
         }
     }
 
-    private GifBlock findBlock(List v, int code)
+    private GifBlock findBlock(List<GifBlock> v, int code)
     {
         for (int i = 0; i < v.size(); i++)
         {
-            GifBlock gifBlock = (GifBlock) v.get(i);
+            GifBlock gifBlock = v.get(i);
             if (gifBlock.blockCode == code)
                 return gifBlock;
         }
@@ -490,7 +490,7 @@ public class GifImageParser extends Imag
                 globalColorTable = readColorTable(is,
                         ghi.sizeOfGlobalColorTable, formatCompliance);
 
-            List blocks = readBlocks(ghi, is, stopBeforeImageData, formatCompliance);
+            List<GifBlock> blocks = readBlocks(ghi, is, stopBeforeImageData, formatCompliance);
 
             ImageContents result = new ImageContents(ghi, globalColorTable, blocks);
 
@@ -553,14 +553,14 @@ public class GifImageParser extends Imag
         return null;
     }
 
-    private List getComments(List v) throws IOException
+    private List<String> getComments(List<GifBlock> v) throws IOException
     {
-        List result = new ArrayList();
+        List<String> result = new ArrayList<String>();
         int code = 0x21fe;
 
         for (int i = 0; i < v.size(); i++)
         {
-            GifBlock block = (GifBlock) v.get(i);
+            GifBlock block = v.get(i);
             if (block.blockCode == code)
             {
                 byte bytes[] = ((GenericGifBlock) block).appendSubBlocks();
@@ -596,7 +596,7 @@ public class GifImageParser extends Imag
         int height = id.imageWidth;
         int width = id.imageHeight;
 
-        List Comments;
+        List<String> Comments;
 
         Comments = getComments(blocks.blocks);
 
@@ -656,7 +656,7 @@ public class GifImageParser extends Imag
             pw.println("gif.blocks: " + blocks.blocks.size());
             for (int i = 0; i < blocks.blocks.size(); i++)
             {
-                GifBlock gifBlock = (GifBlock) blocks.blocks.get(i);
+                GifBlock gifBlock = blocks.blocks.get(i);
                 this.debugNumber(pw, "\t" + i + " ("
                         + gifBlock.getClass().getName() + ")",
                         gifBlock.blockCode, 4);
@@ -1113,12 +1113,12 @@ public class GifImageParser extends Imag
             if (ghi.globalColorTableFlag)
                 readColorTable(is, ghi.sizeOfGlobalColorTable, formatCompliance);
 
-            List blocks = readBlocks(ghi, is, true, formatCompliance);
+            List<GifBlock> blocks = readBlocks(ghi, is, true, formatCompliance);
 
-            List result = new ArrayList();
+            List<String> result = new ArrayList<String>();
             for (int i = 0; i < blocks.size(); i++)
             {
-                GifBlock block = (GifBlock) blocks.get(i);
+                GifBlock block = blocks.get(i);
                 if (block.blockCode != XMP_COMPLETE_CODE)
                     continue;
 
@@ -1166,7 +1166,7 @@ public class GifImageParser extends Imag
                 return null;
             if (result.size() > 1)
                 throw new ImageReadException("More than one XMP Block in GIF.");
-            return (String) result.get(0);
+            return result.get(0);
 
         } finally
         {

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/gif/ImageContents.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/gif/ImageContents.java?rev=1221504&r1=1221503&r2=1221504&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/gif/ImageContents.java (original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/gif/ImageContents.java Tue Dec 20 22:09:48 2011
@@ -22,10 +22,10 @@ class ImageContents
 {
     public final GifHeaderInfo gifHeaderInfo;
 
-    public final List blocks;
+    public final List<GifBlock> blocks;
     public final byte globalColorTable[];
 
-    public ImageContents(GifHeaderInfo gifHeaderInfo, byte globalColorTable[], List blocks)
+    public ImageContents(GifHeaderInfo gifHeaderInfo, byte globalColorTable[], List<GifBlock> blocks)
     {
         this.gifHeaderInfo = gifHeaderInfo;
         this.globalColorTable = globalColorTable;

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/icns/IcnsDecoder.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/icns/IcnsDecoder.java?rev=1221504&r1=1221503&r2=1221504&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/icns/IcnsDecoder.java (original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/icns/IcnsDecoder.java Tue Dec 20 22:09:48 2011
@@ -428,10 +428,10 @@ public class IcnsDecoder
         }
     }
 
-    public static List decodeAllImages(IcnsImageParser.IcnsElement[] icnsElements)
+    public static List<BufferedImage> decodeAllImages(IcnsImageParser.IcnsElement[] icnsElements)
             throws ImageReadException
     {
-        List result = new ArrayList();
+        List<BufferedImage> result = new ArrayList<BufferedImage>();
         for (int i = 0; i < icnsElements.length; i++)
         {
             IcnsImageParser.IcnsElement imageElement = icnsElements[i];

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/icns/IcnsImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/icns/IcnsImageParser.java?rev=1221504&r1=1221503&r2=1221504&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/icns/IcnsImageParser.java (original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/icns/IcnsImageParser.java Tue Dec 20 22:09:48 2011
@@ -106,11 +106,11 @@ public class IcnsImageParser extends Ima
         }
 
         IcnsContents contents = readImage(byteSource);
-        List images = IcnsDecoder.decodeAllImages(contents.icnsElements);
+        List<BufferedImage> images = IcnsDecoder.decodeAllImages(contents.icnsElements);
         if (images.isEmpty())
             throw new ImageReadException("No icons in ICNS file");
-        BufferedImage image0 = (BufferedImage) images.get(0);
-        return new ImageInfo("Icns", 32, new ArrayList(), ImageFormat.IMAGE_FORMAT_ICNS,
+        BufferedImage image0 = images.get(0);
+        return new ImageInfo("Icns", 32, new ArrayList<String>(), ImageFormat.IMAGE_FORMAT_ICNS,
                 "ICNS Apple Icon Image", image0.getHeight(), "image/x-icns", images.size(),
                 0, 0, 0, 0, image0.getWidth(), false, true, false, ImageInfo.COLOR_TYPE_RGB,
                 ImageInfo.COMPRESSION_ALGORITHM_UNKNOWN);
@@ -136,10 +136,10 @@ public class IcnsImageParser extends Ima
         }
 
         IcnsContents contents = readImage(byteSource);
-        List images = IcnsDecoder.decodeAllImages(contents.icnsElements);
+        List<BufferedImage> images = IcnsDecoder.decodeAllImages(contents.icnsElements);
         if (images.isEmpty())
             throw new ImageReadException("No icons in ICNS file");
-        BufferedImage image0 = (BufferedImage) images.get(0);
+        BufferedImage image0 = images.get(0);
         return new Dimension(image0.getWidth(), image0.getHeight());
     }
 
@@ -246,7 +246,7 @@ public class IcnsImageParser extends Ima
             is = byteSource.getInputStream();
             IcnsHeader icnsHeader = readIcnsHeader(is);
 
-            List icnsElementList = new ArrayList();
+            List<IcnsElement> icnsElementList = new ArrayList<IcnsElement>();
             for (int remainingSize = icnsHeader.fileSize - 8;
                 remainingSize > 0; )
             {
@@ -257,7 +257,7 @@ public class IcnsImageParser extends Ima
 
             IcnsElement[] icnsElements = new IcnsElement[icnsElementList.size()];
             for (int i = 0; i < icnsElements.length; i++)
-                icnsElements[i] = (IcnsElement) icnsElementList.get(i);
+                icnsElements[i] = icnsElementList.get(i);
 
             return new IcnsContents(icnsHeader, icnsElements);
         }
@@ -288,14 +288,14 @@ public class IcnsImageParser extends Ima
             Map params) throws ImageReadException, IOException
     {
         IcnsContents icnsContents = readImage(byteSource);
-        List result = IcnsDecoder.decodeAllImages(icnsContents.icnsElements);
+        List<BufferedImage> result = IcnsDecoder.decodeAllImages(icnsContents.icnsElements);
         if (result.size() > 0)
-            return (BufferedImage) result.get(0);
+            return result.get(0);
         else
             throw new ImageReadException("No icons in ICNS file");
     }
 
-    public List getAllBufferedImages(ByteSource byteSource)
+    public List<BufferedImage> getAllBufferedImages(ByteSource byteSource)
             throws ImageReadException, IOException
     {
         IcnsContents icnsContents = readImage(byteSource);

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/ico/IcoImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/ico/IcoImageParser.java?rev=1221504&r1=1221503&r2=1221504&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/ico/IcoImageParser.java (original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/ico/IcoImageParser.java Tue Dec 20 22:09:48 2011
@@ -562,10 +562,10 @@ public class IcoImageParser extends Imag
             throw new ImageReadException("No icons in ICO file");
     }
 
-    public List getAllBufferedImages(ByteSource byteSource)
+    public List<BufferedImage> getAllBufferedImages(ByteSource byteSource)
             throws ImageReadException, IOException
     {
-        List result = new ArrayList();
+        List<BufferedImage> result = new ArrayList<BufferedImage>();
         ImageContents contents = readImage(byteSource);
 
         FileHeader fileHeader = contents.fileHeader;

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/JpegImageMetadata.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/JpegImageMetadata.java?rev=1221504&r1=1221503&r2=1221504&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/JpegImageMetadata.java (original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/JpegImageMetadata.java Tue Dec 20 22:09:48 2011
@@ -165,7 +165,7 @@ public class JpegImageMetadata implement
     }
 
     public List getItems() {
-        List result = new ArrayList();
+        List<Object> result = new ArrayList<Object>();
 
         if (null != exif)
             result.addAll(exif.getItems());

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/decoder/JpegDecoder.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/decoder/JpegDecoder.java?rev=1221504&r1=1221503&r2=1221504&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/decoder/JpegDecoder.java (original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/decoder/JpegDecoder.java Tue Dec 20 22:09:48 2011
@@ -209,8 +209,7 @@ public class JpegDecoder extends BinaryF
             DqtSegment dqtSegment = new DqtSegment(marker, segmentData);
             for (int i = 0; i < dqtSegment.quantizationTables.size(); i++)
             {
-                DqtSegment.QuantizationTable table = (DqtSegment.QuantizationTable)
-                        dqtSegment.quantizationTables.get(i);
+                DqtSegment.QuantizationTable table = dqtSegment.quantizationTables.get(i);
                 if (0 > table.destinationIdentifier ||
                         table.destinationIdentifier >= quantizationTables.length)
                     throw new ImageReadException("Invalid quantization table identifier " +
@@ -231,8 +230,7 @@ public class JpegDecoder extends BinaryF
             DhtSegment dhtSegment = new DhtSegment(marker, segmentData);
             for (int i = 0; i < dhtSegment.huffmanTables.size(); i++)
             {
-                DhtSegment.HuffmanTable table = (DhtSegment.HuffmanTable)
-                        dhtSegment.huffmanTables.get(i);
+                DhtSegment.HuffmanTable table = dhtSegment.huffmanTables.get(i);
                 DhtSegment.HuffmanTable[] tables;
                 if (table.tableClass == 0)
                     tables = huffmanDCTables;

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/iptc/IptcTypeLookup.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/iptc/IptcTypeLookup.java?rev=1221504&r1=1221503&r2=1221504&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/iptc/IptcTypeLookup.java (original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/iptc/IptcTypeLookup.java Tue Dec 20 22:09:48 2011
@@ -22,7 +22,7 @@ import java.util.Map;
 public abstract class IptcTypeLookup implements IptcConstants
 {
 
-    private static final Map IPTC_TYPE_MAP = new HashMap();
+    private static final Map<Integer, IptcType> IPTC_TYPE_MAP = new HashMap<Integer, IptcType>();
     static
     {
         for (int i = 0; i < IPTC_TYPES.length; i++)
@@ -38,6 +38,6 @@ public abstract class IptcTypeLookup imp
         Integer key = new Integer(type);
         if (!IPTC_TYPE_MAP.containsKey(key))
             return IptcType.getUnknown(type);
-        return (IptcType) IPTC_TYPE_MAP.get(key);
+        return IPTC_TYPE_MAP.get(key);
     }
 }
\ No newline at end of file

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/segments/DhtSegment.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/segments/DhtSegment.java?rev=1221504&r1=1221503&r2=1221504&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/segments/DhtSegment.java (original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/segments/DhtSegment.java Tue Dec 20 22:09:48 2011
@@ -23,7 +23,7 @@ import java.util.List;
 
 public class DhtSegment extends Segment
 {
-    public final List huffmanTables = new ArrayList();
+    public final List<HuffmanTable> huffmanTables = new ArrayList<HuffmanTable>();
 
     public static class HuffmanTable
     {

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/segments/DqtSegment.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/segments/DqtSegment.java?rev=1221504&r1=1221503&r2=1221504&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/segments/DqtSegment.java (original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/segments/DqtSegment.java Tue Dec 20 22:09:48 2011
@@ -25,7 +25,7 @@ import org.apache.commons.sanselan.Image
 
 public class DqtSegment extends Segment
 {
-    public final List quantizationTables = new ArrayList();
+    public final List<QuantizationTable> quantizationTables = new ArrayList<QuantizationTable>();
 
     public static class QuantizationTable
     {

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/xmp/JpegRewriter.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/xmp/JpegRewriter.java?rev=1221504&r1=1221503&r2=1221504&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/xmp/JpegRewriter.java (original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/xmp/JpegRewriter.java Tue Dec 20 22:09:48 2011
@@ -53,9 +53,9 @@ public class JpegRewriter extends Binary
     protected static class JFIFPieces
     {
         public final List pieces;
-        public final List segmentPieces;
+        public final List<JFIFPiece> segmentPieces;
 
-        public JFIFPieces(final List pieces, final List segmentPieces)
+        public JFIFPieces(final List pieces, final List<JFIFPiece> segmentPieces)
         {
             this.pieces = pieces;
             this.segmentPieces = segmentPieces;
@@ -172,7 +172,7 @@ public class JpegRewriter extends Binary
     // , ImageWriteException
     {
         final List pieces = new ArrayList();
-        final List segmentPieces = new ArrayList();
+        final List<JFIFPiece> segmentPieces = new ArrayList<JFIFPiece>();
 
         JpegUtils.Visitor visitor = new JpegUtils.Visitor() {
             // return false to exit before reading image data.
@@ -276,13 +276,13 @@ public class JpegRewriter extends Binary
         return result;
     }
 
-    protected List insertBeforeFirstAppSegments(List segments, List newSegments)
+    protected List<JFIFPiece> insertBeforeFirstAppSegments(List<JFIFPiece> segments, List<JFIFPiece> newSegments)
             throws ImageWriteException
     {
         int firstAppIndex = -1;
         for (int i = 0; i < segments.size(); i++)
         {
-            JFIFPiece piece = (JFIFPiece) segments.get(i);
+            JFIFPiece piece = segments.get(i);
             if (!(piece instanceof JFIFPieceSegment))
                 continue;
 
@@ -294,7 +294,7 @@ public class JpegRewriter extends Binary
             }
         }
 
-        List result = new ArrayList(segments);
+        List<JFIFPiece> result = new ArrayList<JFIFPiece>(segments);
         if (firstAppIndex == -1)
             throw new ImageWriteException("JPEG file has no APP segments.");
         result.addAll(firstAppIndex, newSegments);

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/pcx/PcxImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/pcx/PcxImageParser.java?rev=1221504&r1=1221503&r2=1221504&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/pcx/PcxImageParser.java (original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/pcx/PcxImageParser.java Tue Dec 20 22:09:48 2011
@@ -110,7 +110,7 @@ public class PcxImageParser extends Imag
         Dimension size = getImageSize(byteSource, params);
         int metricHDpi = (int) (pcxHeader.hDpi * 1000.0 / 2.54);
         int metricVDpi = (int) (pcxHeader.vDpi * 1000.0 / 2.54);
-        return new ImageInfo("PCX", pcxHeader.nPlanes * pcxHeader.bitsPerPixel, new ArrayList(),
+        return new ImageInfo("PCX", pcxHeader.nPlanes * pcxHeader.bitsPerPixel, new ArrayList<String>(),
                 ImageFormat.IMAGE_FORMAT_PCX, "ZSoft PCX Image", size.height, "image/x-pcx", 1,
                 metricVDpi, pcxHeader.vDpi / metricVDpi, metricHDpi, pcxHeader.hDpi / metricHDpi,
                 size.width, false, false,

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/png/PngImageInfo.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/png/PngImageInfo.java?rev=1221504&r1=1221503&r2=1221504&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/png/PngImageInfo.java (original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/png/PngImageInfo.java Tue Dec 20 22:09:48 2011
@@ -24,15 +24,15 @@ import org.apache.commons.sanselan.Image
 
 public class PngImageInfo extends ImageInfo
 {
-    private final List textChunks;
+    private final List<PngText> textChunks;
 
     public PngImageInfo(String formatDetails, int bitsPerPixel,
-            List comments, ImageFormat format, String formatName,
+            List<String> comments, ImageFormat format, String formatName,
             int height, String mimeType, int numberOfImages,
             int physicalHeightDpi, float physicalHeightInch,
             int physicalWidthDpi, float physicalWidthInch, int width,
             boolean isProgressive, boolean isTransparent, boolean usesPalette,
-            int colorType, String compressionAlgorithm, final List textChunks)
+            int colorType, String compressionAlgorithm, final List<PngText> textChunks)
     {
         super(formatDetails, bitsPerPixel, comments, format, formatName,
                 height, mimeType, numberOfImages, physicalHeightDpi,
@@ -43,9 +43,9 @@ public class PngImageInfo extends ImageI
         this.textChunks = textChunks;
     }
 
-    public List getTextChunks()
+    public List<PngText> getTextChunks()
     {
-        return new ArrayList(textChunks);
+        return new ArrayList<PngText>(textChunks);
     }
 
 }

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/png/PngImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/png/PngImageParser.java?rev=1221504&r1=1221503&r2=1221504&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/png/PngImageParser.java (original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/png/PngImageParser.java Tue Dec 20 22:09:48 2011
@@ -109,11 +109,11 @@ public class PngImageParser extends Imag
     /**
      * @return List of String-formatted chunk types, ie. "tRNs".
      */
-    public List getChuckTypes(InputStream is) throws ImageReadException, IOException {
-        List chunks = readChunks(is, null, false);
-        List chunkTypes = new ArrayList();
+    public List<String> getChuckTypes(InputStream is) throws ImageReadException, IOException {
+        List<PngChunk> chunks = readChunks(is, null, false);
+        List<String> chunkTypes = new ArrayList<String>();
         for (int i=0; i<chunks.size(); i++) {
-            PngChunk chunk = (PngChunk) chunks.get(i);
+            PngChunk chunk = chunks.get(i);
             chunkTypes.add(getChunkTypeName(chunk.chunkType));
         }
         return chunkTypes;
@@ -127,12 +127,13 @@ public class PngImageParser extends Imag
         {
             is = byteSource.getInputStream();
 
-            List chunks = null;
+            List<PngChunk> chunks = null;
 
             readSignature(is);
             chunks = readChunks(is, new int[] { chunkType, }, true);
             return chunks.size() > 0;
-        } finally
+        } 
+        finally
         {
             try
             {
@@ -161,10 +162,9 @@ public class PngImageParser extends Imag
         return false;
     }
 
-    private List readChunks(InputStream is, int chunkTypes[],
-            boolean returnAfterFirst) throws ImageReadException, IOException
+    private List<PngChunk> readChunks(InputStream is, int chunkTypes[], boolean returnAfterFirst) throws ImageReadException, IOException
     {
-        List result = new ArrayList();
+        List<PngChunk> result = new ArrayList<PngChunk>();
 
         while (true)
         {
@@ -239,7 +239,7 @@ public class PngImageParser extends Imag
 
     }
 
-    private List readChunks(ByteSource byteSource, int chunkTypes[],
+    private List<PngChunk> readChunks(ByteSource byteSource, int chunkTypes[],
             boolean returnAfterFirst) throws ImageReadException, IOException
     {
         InputStream is = null;
@@ -248,12 +248,11 @@ public class PngImageParser extends Imag
         {
             is = byteSource.getInputStream();
 
-            List chunks = null;
-
             readSignature(is);
-            chunks = readChunks(is, chunkTypes, returnAfterFirst);
-            return chunks;
-        } finally
+            
+            return readChunks(is, chunkTypes, returnAfterFirst);
+        }
+        finally
         {
             try
             {
@@ -270,7 +269,7 @@ public class PngImageParser extends Imag
     public byte[] getICCProfileBytes(ByteSource byteSource, Map params)
             throws ImageReadException, IOException
     {
-        List chunks = readChunks(byteSource, new int[] { iCCP, }, true);
+        List<PngChunk> chunks = readChunks(byteSource, new int[] { iCCP, }, true);
 
         if ((chunks == null) || (chunks.size() < 1))
         {
@@ -291,7 +290,7 @@ public class PngImageParser extends Imag
     public Dimension getImageSize(ByteSource byteSource, Map params)
             throws ImageReadException, IOException
     {
-        List chunks = readChunks(byteSource, new int[] { IHDR, }, true);
+        List<PngChunk> chunks = readChunks(byteSource, new int[] { IHDR, }, true);
 
         if ((chunks == null) || (chunks.size() < 1))
             throw new ImageReadException("Png: No chunks");
@@ -317,7 +316,7 @@ public class PngImageParser extends Imag
     public IImageMetadata getMetadata(ByteSource byteSource, Map params)
             throws ImageReadException, IOException
     {
-        List chunks = readChunks(byteSource, new int[] { tEXt, zTXt, }, true);
+        List<PngChunk> chunks = readChunks(byteSource, new int[] { tEXt, zTXt, }, true);
 
         if ((chunks == null) || (chunks.size() < 1))
             return null;
@@ -430,13 +429,13 @@ public class PngImageParser extends Imag
         throw new ImageReadException("PNG: unknown color type: " + colorType);
     }
 
-    private List filterChunks(List v, int type)
+    private List<PngChunk> filterChunks(List<PngChunk> v, int type)
     {
-        List result = new ArrayList();
+        List<PngChunk> result = new ArrayList<PngChunk>();
 
         for (int i = 0; i < v.size(); i++)
         {
-            PngChunk chunk = (PngChunk) v.get(i);
+            PngChunk chunk = v.get(i);
             if (chunk.chunkType == type)
                 result.add(chunk);
         }
@@ -523,8 +522,7 @@ public class PngImageParser extends Imag
     public ImageInfo getImageInfo(ByteSource byteSource, Map params)
             throws ImageReadException, IOException
     {
-        List chunks = readChunks(byteSource, new int[] { IHDR, pHYs, tEXt,
-                zTXt, tRNS, PLTE, iTXt, }, false);
+        List<PngChunk> chunks = readChunks(byteSource, new int[] { IHDR, pHYs, tEXt, zTXt, tRNS, PLTE, iTXt, }, false);
 
         // if(chunks!=null)
         // System.out.println("chunks: " + chunks.size());
@@ -532,7 +530,7 @@ public class PngImageParser extends Imag
         if ((chunks == null) || (chunks.size() < 1))
             throw new ImageReadException("PNG: no chunks");
 
-        List IHDRs = filterChunks(chunks, IHDR);
+        List<PngChunk> IHDRs = filterChunks(chunks, IHDR);
         if (IHDRs.size() != 1)
             throw new ImageReadException("PNG contains more than one Header");
 
@@ -541,11 +539,11 @@ public class PngImageParser extends Imag
 
         boolean isTransparent = false;
 
-        List tRNSs = filterChunks(chunks, tRNS);
+        List<PngChunk> tRNSs = filterChunks(chunks, tRNS);
         if (tRNSs.size() > 0)
         {
             isTransparent = true;
-            pngChunktRNS = (PngChunk) IHDRs.get(0);
+            pngChunktRNS = IHDRs.get(0);
         } else {
             // CE - Fix Alpha.
             isTransparent = hasAlphaChannel(pngChunkIHDR.colorType);
@@ -554,20 +552,20 @@ public class PngImageParser extends Imag
 
         PngChunkPhys pngChunkpHYs = null;
 
-        List pHYss = filterChunks(chunks, pHYs);
+        List<PngChunk> pHYss = filterChunks(chunks, pHYs);
         if (pHYss.size() > 1)
             throw new ImageReadException("PNG contains more than one pHYs: "
                     + pHYss.size());
         else if (pHYss.size() == 1)
             pngChunkpHYs = (PngChunkPhys) pHYss.get(0);
 
-        List tEXts = filterChunks(chunks, tEXt);
-        List zTXts = filterChunks(chunks, zTXt);
-        List iTXts = filterChunks(chunks, iTXt);
+        List<PngChunk> tEXts = filterChunks(chunks, tEXt);
+        List<PngChunk> zTXts = filterChunks(chunks, zTXt);
+        List<PngChunk> iTXts = filterChunks(chunks, iTXt);
 
         {
-            List comments = new ArrayList();
-            List textChunks = new ArrayList();
+            List<String> comments = new ArrayList<String>();
+            List<PngText> textChunks = new ArrayList<PngText>();
 
             for (int i = 0; i < tEXts.size(); i++)
             {
@@ -632,7 +630,7 @@ public class PngImageParser extends Imag
 
             boolean usesPalette = false;
 
-            List PLTEs = filterChunks(chunks, PLTE);
+            List<PngChunk> PLTEs = filterChunks(chunks, PLTE);
             if (PLTEs.size() > 1)
                 usesPalette = true;
 
@@ -661,14 +659,12 @@ public class PngImageParser extends Imag
 
             String compressionAlgorithm = ImageInfo.COMPRESSION_ALGORITHM_PNG_FILTER;
 
-            ImageInfo result = new PngImageInfo(FormatDetails, BitsPerPixel,
+            return new PngImageInfo(FormatDetails, BitsPerPixel,
                     comments, Format, FormatName, Height, MimeType,
                     NumberOfImages, PhysicalHeightDpi, PhysicalHeightInch,
                     PhysicalWidthDpi, PhysicalWidthInch, Width, isProgressive,
                     isTransparent, usesPalette, ColorType,
                     compressionAlgorithm, textChunks);
-
-            return result;
         }
     }
 
@@ -686,19 +682,19 @@ public class PngImageParser extends Imag
         // throw new ImageWriteException("Unknown parameter: " + firstKey);
         // }
 
-        List chunks = readChunks(byteSource, new int[] { IHDR, PLTE, IDAT,
+        List<PngChunk> chunks = readChunks(byteSource, new int[] { IHDR, PLTE, IDAT,
                 tRNS, iCCP, gAMA, sRGB, }, false);
 
         if ((chunks == null) || (chunks.size() < 1))
             throw new ImageReadException("PNG: no chunks");
 
-        List IHDRs = filterChunks(chunks, IHDR);
+        List<PngChunk> IHDRs = filterChunks(chunks, IHDR);
         if (IHDRs.size() != 1)
             throw new ImageReadException("PNG contains more than one Header");
 
         PngChunkIhdr pngChunkIHDR = (PngChunkIhdr) IHDRs.get(0);
 
-        List PLTEs = filterChunks(chunks, PLTE);
+        List<PngChunk> PLTEs = filterChunks(chunks, PLTE);
         if (PLTEs.size() > 1)
             throw new ImageReadException("PNG contains more than one Palette");
 
@@ -708,7 +704,7 @@ public class PngImageParser extends Imag
 
         // -----
 
-        List IDATs = filterChunks(chunks, IDAT);
+        List<PngChunk> IDATs = filterChunks(chunks, IDAT);
         if (IDATs.size() < 1)
             throw new ImageReadException("PNG missing image data");
 
@@ -727,10 +723,10 @@ public class PngImageParser extends Imag
 
         TransparencyFilter transparencyFilter = null;
 
-        List tRNSs = filterChunks(chunks, tRNS);
+        List<PngChunk> tRNSs = filterChunks(chunks, tRNS);
         if (tRNSs.size() > 0)
         {
-            PngChunk pngChunktRNS = (PngChunk) tRNSs.get(0);
+            PngChunk pngChunktRNS = tRNSs.get(0);
             transparencyFilter = getTransparencyFilter(pngChunkIHDR.colorType,
                     pngChunktRNS);
         }
@@ -738,9 +734,9 @@ public class PngImageParser extends Imag
         ICC_Profile icc_profile = null;
         GammaCorrection gammaCorrection = null;
         {
-            List sRGBs = filterChunks(chunks, sRGB);
-            List gAMAs = filterChunks(chunks, gAMA);
-            List iCCPs = filterChunks(chunks, iCCP);
+            List<PngChunk> sRGBs = filterChunks(chunks, sRGB);
+            List<PngChunk> gAMAs = filterChunks(chunks, gAMA);
+            List<PngChunk> iCCPs = filterChunks(chunks, iCCP);
             if (sRGBs.size() > 1)
                 throw new ImageReadException("PNG: unexpected sRGB chunk");
             if (gAMAs.size() > 1)
@@ -859,9 +855,9 @@ public class PngImageParser extends Imag
         imageInfo.toString(pw, "");
 
         {
-            List chunks = readChunks(byteSource, null, false);
+            List<PngChunk> chunks = readChunks(byteSource, null, false);
             {
-                List IHDRs = filterChunks(chunks, IHDR);
+                List<PngChunk> IHDRs = filterChunks(chunks, IHDR);
                 if (IHDRs.size() != 1)
                 {
                     if (debug)
@@ -880,7 +876,7 @@ public class PngImageParser extends Imag
 
             for (int i = 0; i < chunks.size(); i++)
             {
-                PngChunk chunk = (PngChunk) chunks.get(i);
+                PngChunk chunk = chunks.get(i);
                 printCharQuad(pw, "\t" + i + ": ", chunk.chunkType);
             }
         }
@@ -912,12 +908,12 @@ public class PngImageParser extends Imag
             throws ImageReadException, IOException
     {
 
-        List chunks = readChunks(byteSource, new int[] { iTXt, }, false);
+        List<PngChunk> chunks = readChunks(byteSource, new int[] { iTXt, }, false);
 
         if ((chunks == null) || (chunks.size() < 1))
             return null;
 
-        List xmpChunks = new ArrayList();
+        List<PngChunkItxt> xmpChunks = new ArrayList<PngChunkItxt>();
         for (int i = 0; i < chunks.size(); i++)
         {
             PngChunkItxt chunk = (PngChunkItxt) chunks.get(i);
@@ -932,7 +928,7 @@ public class PngImageParser extends Imag
             throw new ImageReadException(
                     "PNG contains more than one XMP chunk.");
 
-        PngChunkItxt chunk = (PngChunkItxt) xmpChunks.get(0);
+        PngChunkItxt chunk = xmpChunks.get(0);
         return chunk.getText();
     }
 

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/pnm/PnmImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/pnm/PnmImageParser.java?rev=1221504&r1=1221503&r2=1221504&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/pnm/PnmImageParser.java (original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/pnm/PnmImageParser.java Tue Dec 20 22:09:48 2011
@@ -185,7 +185,7 @@ public class PnmImageParser extends Imag
         if (info == null)
             throw new ImageReadException("PNM: Couldn't read Header");
 
-        List Comments = new ArrayList();
+        List<String> Comments = new ArrayList<String>();
 
         int BitsPerPixel = info.getBitDepth() * info.getNumComponents();
         ImageFormat Format = info.getImageType();

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/psd/PsdImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/psd/PsdImageParser.java?rev=1221504&r1=1221503&r2=1221504&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/psd/PsdImageParser.java (original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/psd/PsdImageParser.java Tue Dec 20 22:09:48 2011
@@ -173,8 +173,8 @@ public class PsdImageParser extends Imag
         return result;
     }
 
-    private List readImageResourceBlocks(byte bytes[],
-            int imageResourceIDs[], int maxBlocksToRead)
+    private List<ImageResourceBlock> readImageResourceBlocks(byte bytes[],
+                                                             int imageResourceIDs[], int maxBlocksToRead)
             throws ImageReadException, IOException
     {
         return readImageResourceBlocks(new ByteArrayInputStream(bytes),
@@ -193,11 +193,11 @@ public class PsdImageParser extends Imag
         return false;
     }
 
-    private List readImageResourceBlocks(InputStream is,
-            int imageResourceIDs[], int maxBlocksToRead, int available)
+    private List<ImageResourceBlock> readImageResourceBlocks(InputStream is,
+                                                             int imageResourceIDs[], int maxBlocksToRead, int available)
             throws ImageReadException, IOException
     {
-        List result = new ArrayList();
+        List<ImageResourceBlock> result = new ArrayList<ImageResourceBlock>();
 
         while (available > 0)
         {
@@ -253,8 +253,8 @@ public class PsdImageParser extends Imag
         return result;
     }
 
-    private List readImageResourceBlocks(ByteSource byteSource,
-            int imageResourceIDs[], int maxBlocksToRead)
+    private List<ImageResourceBlock> readImageResourceBlocks(ByteSource byteSource,
+                                                             int imageResourceIDs[], int maxBlocksToRead)
             throws ImageReadException, IOException
     {
         InputStream is = null;
@@ -458,13 +458,13 @@ public class PsdImageParser extends Imag
     public byte[] getICCProfileBytes(ByteSource byteSource, Map params)
             throws ImageReadException, IOException
     {
-        List blocks = readImageResourceBlocks(byteSource,
-                new int[] { IMAGE_RESOURCE_ID_ICC_PROFILE, }, 1);
+        List<ImageResourceBlock> blocks = readImageResourceBlocks(byteSource,
+                new int[]{IMAGE_RESOURCE_ID_ICC_PROFILE,}, 1);
 
         if ((blocks == null) || (blocks.size() < 1))
             return null;
 
-        ImageResourceBlock irb = (ImageResourceBlock) blocks.get(0);
+        ImageResourceBlock irb = blocks.get(0);
         byte bytes[] = irb.data;
         if ((bytes == null) || (bytes.length < 1))
             return null;
@@ -540,7 +540,7 @@ public class PsdImageParser extends Imag
         int Width = header.Columns;
         int Height = header.Rows;
 
-        List Comments = new ArrayList();
+        List<String> Comments = new ArrayList<String>();
         // TODO: comments...
 
         int BitsPerPixel = header.Depth * getChannelsPerMode(header.Mode);
@@ -592,11 +592,11 @@ public class PsdImageParser extends Imag
     }
 
     // TODO not used
-    private ImageResourceBlock findImageResourceBlock(List blocks, int ID)
+    private ImageResourceBlock findImageResourceBlock(List<ImageResourceBlock> blocks, int ID)
     {
         for (int i = 0; i < blocks.size(); i++)
         {
-            ImageResourceBlock block = (ImageResourceBlock) blocks.get(i);
+            ImageResourceBlock block = blocks.get(i);
 
             if (block.id == ID)
                 return block;
@@ -622,8 +622,8 @@ public class PsdImageParser extends Imag
             imageContents.dump(pw);
             imageContents.header.dump(pw);
 
-            List blocks = readImageResourceBlocks(byteSource,
-            // fImageContents.ImageResources,
+            List<ImageResourceBlock> blocks = readImageResourceBlocks(byteSource,
+                    // fImageContents.ImageResources,
                     null, -1);
 
             pw.println("blocks.size(): " + blocks.size());
@@ -631,7 +631,7 @@ public class PsdImageParser extends Imag
             // System.out.println("gif.blocks: " + blocks.blocks.size());
             for (int i = 0; i < blocks.size(); i++)
             {
-                ImageResourceBlock block = (ImageResourceBlock) blocks.get(i);
+                ImageResourceBlock block = blocks.get(i);
                 pw.println("\t" + i + " (" + Integer.toHexString(block.id)
                         + ", " + "'"
                         + new String(block.nameData)
@@ -676,8 +676,8 @@ public class PsdImageParser extends Imag
         // GraphicControlExtension gce = (GraphicControlExtension) findBlock(
         // fImageContents.blocks, kGraphicControlExtension);
 
-        List blocks = readImageResourceBlocks(byteSource,
-        // fImageContents.ImageResources,
+        List<ImageResourceBlock> blocks = readImageResourceBlocks(byteSource,
+                // fImageContents.ImageResources,
                 null, -1);
 
         int width = header.Columns;
@@ -808,19 +808,19 @@ public class PsdImageParser extends Imag
         if (header == null)
             throw new ImageReadException("PSD: Couldn't read Header");
 
-        List blocks = readImageResourceBlocks(byteSource,
-                new int[] { IMAGE_RESOURCE_ID_XMP, }, -1);
+        List<ImageResourceBlock> blocks = readImageResourceBlocks(byteSource,
+                new int[]{IMAGE_RESOURCE_ID_XMP,}, -1);
 
         if ((blocks == null) || (blocks.size() < 1))
             return null;
 
-        List xmpBlocks = new ArrayList();
+        List<ImageResourceBlock> xmpBlocks = new ArrayList<ImageResourceBlock>();
         if (false)
         {
             // TODO: for PSD 7 and later, verify "XMP" name.
             for (int i = 0; i < blocks.size(); i++)
             {
-                ImageResourceBlock block = (ImageResourceBlock) blocks.get(i);
+                ImageResourceBlock block = blocks.get(i);
                 if (!block.getName().equals(BLOCK_NAME_XMP))
                     continue;
                 xmpBlocks.add(block);
@@ -834,7 +834,7 @@ public class PsdImageParser extends Imag
             throw new ImageReadException(
                     "PSD contains more than one XMP block.");
 
-        ImageResourceBlock block = (ImageResourceBlock) xmpBlocks.get(0);
+        ImageResourceBlock block = xmpBlocks.get(0);
 
         try
         {

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/TiffContents.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/TiffContents.java?rev=1221504&r1=1221503&r2=1221504&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/TiffContents.java (original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/TiffContents.java Tue Dec 20 22:09:48 2011
@@ -27,9 +27,9 @@ import org.apache.commons.sanselan.util.
 public class TiffContents
 {
     public final TiffHeader header;
-    public final List directories;
+    public final List<TiffDirectory> directories;
 
-    public TiffContents(TiffHeader tiffHeader, List directories)
+    public TiffContents(TiffHeader tiffHeader, List<TiffDirectory> directories)
     {
         this.header = tiffHeader;
         this.directories = directories;
@@ -43,14 +43,14 @@ public class TiffContents
 
         for (int i = 0; i < directories.size(); i++)
         {
-            TiffDirectory directory = (TiffDirectory) directories.get(i);
+            TiffDirectory directory = directories.get(i);
 
             result.add(directory);
 
-            List fields = directory.entries;
+            List<TiffField> fields = directory.entries;
             for (int j = 0; j < fields.size(); j++)
             {
-                TiffField field = (TiffField) fields.get(j);
+                TiffField field = fields.get(j);
                 TiffElement oversizeValue = field.getOversizeValueElement();
                 if (null != oversizeValue)
                     result.add(oversizeValue);
@@ -69,7 +69,7 @@ public class TiffContents
     {
         for (int i = 0; i < directories.size(); i++)
         {
-            TiffDirectory directory = (TiffDirectory) directories.get(i);
+            TiffDirectory directory = directories.get(i);
 
             TiffField field = directory.findField(tag);
             if (null != field)

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/TiffDirectory.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/TiffDirectory.java?rev=1221504&r1=1221503&r2=1221504&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/TiffDirectory.java (original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/TiffDirectory.java Tue Dec 20 22:09:48 2011
@@ -45,7 +45,7 @@ public class TiffDirectory extends TiffE
         StringBuffer result = new StringBuffer();
         for (int i = 0; i < entries.size(); i++)
         {
-            TiffField entry = (TiffField) entries.get(i);
+            TiffField entry = entries.get(i);
 
             result.append("\t");
             result.append("[" + entryOffset + "]: ");
@@ -88,11 +88,11 @@ public class TiffDirectory extends TiffE
     }
 
     public final int type;
-    public final List entries;
+    public final List<TiffField> entries;
     //    public final int offset;
     public final int nextDirectoryOffset;
 
-    public TiffDirectory(int type, List entries, final int offset,
+    public TiffDirectory(int type, List<TiffField> entries, final int offset,
             int nextDirectoryOffset)
     {
         super(offset, TIFF_DIRECTORY_HEADER_LENGTH + entries.size()
@@ -103,16 +103,16 @@ public class TiffDirectory extends TiffE
         this.nextDirectoryOffset = nextDirectoryOffset;
     }
 
-    public List getDirectoryEntrys()
+    public List<TiffField> getDirectoryEntrys()
     {
-        return new ArrayList(entries);
+        return new ArrayList<TiffField>(entries);
     }
 
     public void dump()
     {
         for (int i = 0; i < entries.size(); i++)
         {
-            TiffField entry = (TiffField) entries.get(i);
+            TiffField entry = entries.get(i);
             entry.dump();
         }
 
@@ -166,7 +166,7 @@ public class TiffDirectory extends TiffE
 
         for (int i = 0; i < entries.size(); i++)
         {
-            TiffField field = (TiffField) entries.get(i);
+            TiffField field = entries.get(i);
             if (field.tag == tag.tag)
                 return field;
         }

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/TiffField.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/TiffField.java?rev=1221504&r1=1221503&r2=1221504&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/TiffField.java (original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/TiffField.java Tue Dec 20 22:09:48 2011
@@ -118,7 +118,7 @@ public class TiffField implements TiffCo
     }
 
     private static TagInfo getTag(int directoryType, int tag,
-            List possibleMatches)
+            List<TagInfo> possibleMatches)
     {
         // Please keep this method in sync with TiffImageMetadata's findField()
 
@@ -133,7 +133,7 @@ public class TiffField implements TiffCo
         // first search for exact match.
         for (int i = 0; i < possibleMatches.size(); i++)
         {
-            TagInfo tagInfo = (TagInfo) possibleMatches.get(i);
+            TagInfo tagInfo = possibleMatches.get(i);
             if (tagInfo.directoryType == EXIF_DIRECTORY_UNKNOWN)
                 // pass
                 continue;
@@ -144,7 +144,7 @@ public class TiffField implements TiffCo
         // accept an inexact match.
         for (int i = 0; i < possibleMatches.size(); i++)
         {
-            TagInfo tagInfo = (TagInfo) possibleMatches.get(i);
+            TagInfo tagInfo = possibleMatches.get(i);
 
             if (tagInfo.directoryType == EXIF_DIRECTORY_UNKNOWN)
                 // pass
@@ -160,7 +160,7 @@ public class TiffField implements TiffCo
         // accept a wildcard match.
         for (int i = 0; i < possibleMatches.size(); i++)
         {
-            TagInfo tagInfo = (TagInfo) possibleMatches.get(i);
+            TagInfo tagInfo = possibleMatches.get(i);
 
             if (tagInfo.directoryType == EXIF_DIRECTORY_UNKNOWN)
                 return tagInfo;
@@ -251,7 +251,7 @@ public class TiffField implements TiffCo
     {
         Object key = new Integer(tag);
 
-        List possibleMatches = (List) ALL_TAG_MAP.get(key);
+        List<TagInfo> possibleMatches = ALL_TAG_MAP.get(key);
 
         if (null == possibleMatches)
         {
@@ -575,21 +575,21 @@ public class TiffField implements TiffCo
         return (String) o;
     }
 
-    private static final Map makeTagMap(TagInfo tags[],
-            boolean ignoreDuplicates, String name)
+    private static final Map<Object, List<TagInfo>> makeTagMap(TagInfo tags[],
+                                                               boolean ignoreDuplicates, String name)
     {
         // make sure to use the thread-safe version; this is shared state.
-        Map map = new Hashtable();
+        Map<Object, List<TagInfo>> map = new Hashtable<Object, List<TagInfo>>();
 
         for (int i = 0; i < tags.length; i++)
         {
             TagInfo tag = tags[i];
             Object key = new Integer(tag.tag);
 
-            List tagList = (List) map.get(key);
+            List<TagInfo> tagList = map.get(key);
             if (tagList == null)
             {
-                tagList = new ArrayList();
+                tagList = new ArrayList<TagInfo>();
                 map.put(key, tagList);
             }
             tagList.add(tag);
@@ -609,13 +609,13 @@ public class TiffField implements TiffCo
         return map;
     }
 
-    private static final Map GPS_TAG_MAP = makeTagMap(ALL_GPS_TAGS, false,
+    private static final Map<Object, List<TagInfo>> GPS_TAG_MAP = makeTagMap(ALL_GPS_TAGS, false,
             "GPS");
-    private static final Map TIFF_TAG_MAP = makeTagMap(ALL_TIFF_TAGS, false,
+    private static final Map<Object, List<TagInfo>> TIFF_TAG_MAP = makeTagMap(ALL_TIFF_TAGS, false,
             "TIFF");
-    private static final Map EXIF_TAG_MAP = makeTagMap(ALL_EXIF_TAGS, true,
+    private static final Map<Object, List<TagInfo>> EXIF_TAG_MAP = makeTagMap(ALL_EXIF_TAGS, true,
             "EXIF");
-    private static final Map ALL_TAG_MAP = makeTagMap(ALL_TAGS, true, "All");
+    private static final Map<Object, List<TagInfo>> ALL_TAG_MAP = makeTagMap(ALL_TAGS, true, "All");
 
     // static
     // {

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/TiffImageMetadata.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/TiffImageMetadata.java?rev=1221504&r1=1221503&r2=1221504&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/TiffImageMetadata.java (original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/TiffImageMetadata.java Tue Dec 20 22:09:48 2011
@@ -41,23 +41,23 @@ public class TiffImageMetadata extends I
             TiffDirectoryConstants
 {
     public final TiffContents contents;
-    private static final Map tagCounts = countTags(AllTagConstants.ALL_TAGS);
+    private static final Map<Object, Integer> tagCounts = countTags(AllTagConstants.ALL_TAGS);
 
     public TiffImageMetadata(final TiffContents contents)
     {
         this.contents = contents;
     }
 
-    private static final Map countTags(TagInfo tags[])
+    private static final Map<Object, Integer> countTags(TagInfo tags[])
     {
-        Map map = new Hashtable();
+        Map<Object, Integer> map = new Hashtable<Object, Integer>();
 
         for (int i = 0; i < tags.length; i++)
         {
             TagInfo tag = tags[i];
             Object key = new Integer(tag.tag);
 
-            Integer count = (Integer) map.get(key);
+            Integer count = map.get(key);
             if (count == null)
                 map.put(key, new Integer(1));
             else
@@ -67,9 +67,7 @@ public class TiffImageMetadata extends I
         return map;
     }
 
-    public static class Directory extends ImageMetadata
-            implements
-                ImageMetadata.IImageMetadataItem
+    public static class Directory extends ImageMetadata implements ImageMetadata.IImageMetadataItem
     {
         //        private BufferedImage thumbnail = null;
 
@@ -104,7 +102,7 @@ public class TiffImageMetadata extends I
             return directory.findField(tagInfo);
         }
 
-        public List getAllFields()
+        public List<TiffField> getAllFields()
         {
             return directory.getDirectoryEntrys();
         }
@@ -192,7 +190,7 @@ public class TiffImageMetadata extends I
         return super.getItems();
     }
 
-    public List getItems()
+    public List<? extends IImageMetadataItem> getItems()
     {
         List result = new ArrayList();
 
@@ -259,7 +257,7 @@ public class TiffImageMetadata extends I
     public TiffField findField(TagInfo tagInfo, boolean exactDirectoryMatch) throws ImageReadException
     {
         // Please keep this method in sync with TiffField's getTag()
-        Integer tagCount = (Integer)tagCounts.get(new Integer(tagInfo.tag));
+        Integer tagCount = tagCounts.get(new Integer(tagInfo.tag));
         int tagsMatching = tagCount == null ? 0 : tagCount.intValue();
 
         List directories = getDirectories();
@@ -321,9 +319,9 @@ public class TiffImageMetadata extends I
         return null;
     }
 
-    public List getAllFields()
+    public List<TiffField> getAllFields()
     {
-        List result = new ArrayList();
+        List<TiffField> result = new ArrayList<TiffField>();
         List directories = getDirectories();
         for (int i = 0; i < directories.size(); i++)
         {

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/TiffImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/TiffImageParser.java?rev=1221504&r1=1221503&r2=1221504&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/TiffImageParser.java (original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/TiffImageParser.java Tue Dec 20 22:09:48 2011
@@ -85,7 +85,7 @@ public class TiffImageParser extends Ima
         FormatCompliance formatCompliance = FormatCompliance.getDefault();
         TiffContents contents = new TiffReader(isStrict(params))
                 .readFirstDirectory(byteSource, params, false, formatCompliance);
-        TiffDirectory directory = (TiffDirectory) contents.directories.get(0);
+        TiffDirectory directory = contents.directories.get(0);
 
         TiffField field = directory.findField(EXIF_TAG_ICC_PROFILE);
         if (null == field)
@@ -99,7 +99,7 @@ public class TiffImageParser extends Ima
         FormatCompliance formatCompliance = FormatCompliance.getDefault();
         TiffContents contents = new TiffReader(isStrict(params))
                 .readFirstDirectory(byteSource, params, false, formatCompliance);
-        TiffDirectory directory = (TiffDirectory) contents.directories.get(0);
+        TiffDirectory directory = contents.directories.get(0);
 
         int width = directory.findField(TIFF_TAG_IMAGE_WIDTH).getIntValue();
         int height = directory.findField(TIFF_TAG_IMAGE_LENGTH).getIntValue();
@@ -124,21 +124,21 @@ public class TiffImageParser extends Ima
         TiffContents contents = new TiffReader(isStrict(params)).readContents(
                 byteSource, params, formatCompliance);
 
-        List directories = contents.directories;
+        List<TiffDirectory> directories = contents.directories;
 
         TiffImageMetadata result = new TiffImageMetadata(contents);
 
         for (int i = 0; i < directories.size(); i++)
         {
-            TiffDirectory dir = (TiffDirectory) directories.get(i);
+            TiffDirectory dir = directories.get(i);
 
             TiffImageMetadata.Directory metadataDirectory = new TiffImageMetadata.Directory(dir);
 
-            List entries = dir.getDirectoryEntrys();
+            List<TiffField> entries = dir.getDirectoryEntrys();
 
             for (int j = 0; j < entries.size(); j++)
             {
-                TiffField entry = (TiffField) entries.get(j);
+                TiffField entry = entries.get(j);
                 metadataDirectory.add(entry);
             }
 
@@ -154,7 +154,7 @@ public class TiffImageParser extends Ima
         FormatCompliance formatCompliance = FormatCompliance.getDefault();
         TiffContents contents = new TiffReader(isStrict(params))
                 .readDirectories(byteSource, false, formatCompliance);
-        TiffDirectory directory = (TiffDirectory) contents.directories.get(0);
+        TiffDirectory directory = contents.directories.get(0);
 
         TiffField widthField = directory.findField(TIFF_TAG_IMAGE_WIDTH, true);
         TiffField heightField = directory
@@ -233,11 +233,11 @@ public class TiffImageParser extends Ima
 
         // -------------------
 
-        List comments = new ArrayList();
-        List entries = directory.entries;
+        List<String> comments = new ArrayList<String>();
+        List<TiffField> entries = directory.entries;
         for (int i = 0; i < entries.size(); i++)
         {
-            TiffField field = (TiffField) entries.get(i);
+            TiffField field = entries.get(i);
             String comment = field.toString();
             comments.add(comment);
         }
@@ -310,7 +310,7 @@ public class TiffImageParser extends Ima
         FormatCompliance formatCompliance = FormatCompliance.getDefault();
         TiffContents contents = new TiffReader(isStrict(params))
                 .readDirectories(byteSource, false, formatCompliance);
-        TiffDirectory directory = (TiffDirectory) contents.directories.get(0);
+        TiffDirectory directory = contents.directories.get(0);
 
         TiffField xmpField = directory.findField(TIFF_TAG_XMP, false);
         if (xmpField == null)
@@ -354,17 +354,17 @@ public class TiffImageParser extends Ima
                 TiffContents contents = new TiffReader(true).readContents(
                         byteSource, params, formatCompliance);
 
-                List directories = contents.directories;
+                List<TiffDirectory> directories = contents.directories;
 
                 if (directories == null)
                     return false;
 
                 for (int d = 0; d < directories.size(); d++)
                 {
-                    TiffDirectory directory = (TiffDirectory) directories
+                    TiffDirectory directory = directories
                             .get(d);
 
-                    List entries = directory.entries;
+                    List<TiffField> entries = directory.entries;
 
                     if (entries == null)
                         return false;
@@ -373,7 +373,7 @@ public class TiffImageParser extends Ima
 
                     for (int i = 0; i < entries.size(); i++)
                     {
-                        TiffField field = (TiffField) entries.get(i);
+                        TiffField field = entries.get(i);
 
                         field.dump(pw, d + "");
                     }
@@ -405,17 +405,17 @@ public class TiffImageParser extends Ima
         return formatCompliance;
     }
 
-    public List collectRawImageData(ByteSource byteSource, Map params)
+    public List<byte[]> collectRawImageData(ByteSource byteSource, Map params)
             throws ImageReadException, IOException
     {
         FormatCompliance formatCompliance = FormatCompliance.getDefault();
         TiffContents contents = new TiffReader(isStrict(params))
                 .readDirectories(byteSource, true, formatCompliance);
 
-        List result = new ArrayList();
+        List<byte[]> result = new ArrayList<byte[]>();
         for (int i = 0; i < contents.directories.size(); i++)
         {
-            TiffDirectory directory = (TiffDirectory) contents.directories
+            TiffDirectory directory = contents.directories
                     .get(i);
             List dataElements = directory.getTiffRawImageDataElements();
             for (int j = 0; j < dataElements.size(); j++)
@@ -436,22 +436,22 @@ public class TiffImageParser extends Ima
         FormatCompliance formatCompliance = FormatCompliance.getDefault();
         TiffContents contents = new TiffReader(isStrict(params))
                 .readFirstDirectory(byteSource, params, true, formatCompliance);
-        TiffDirectory directory = (TiffDirectory) contents.directories.get(0);
+        TiffDirectory directory = contents.directories.get(0);
         BufferedImage result = directory.getTiffImage(params);
         if (null == result)
             throw new ImageReadException("TIFF does not contain an image.");
         return result;
     }
 
-    public List getAllBufferedImages(ByteSource byteSource)
+    public List<BufferedImage> getAllBufferedImages(ByteSource byteSource)
             throws ImageReadException, IOException
     {
         FormatCompliance formatCompliance = FormatCompliance.getDefault();
         TiffContents contents = new TiffReader(true).readDirectories(byteSource, true, formatCompliance);
-        List results = new ArrayList();
+        List<BufferedImage> results = new ArrayList<BufferedImage>();
         for (int i = 0; i < contents.directories.size(); i++)
         {
-            TiffDirectory directory = (TiffDirectory) contents.directories.get(i);
+            TiffDirectory directory = contents.directories.get(i);
             BufferedImage result = directory.getTiffImage(null);
             if (result != null)
             {
@@ -464,7 +464,7 @@ public class TiffImageParser extends Ima
     protected BufferedImage getBufferedImage(TiffDirectory directory, Map params)
             throws ImageReadException, IOException
     {
-        List entries = directory.entries;
+        List<TiffField> entries = directory.entries;
 
         if (entries == null)
             throw new ImageReadException("TIFF missing entries");



Mime
View raw message