commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dam...@apache.org
Subject svn commit: r1240671 - in /commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan: formats/jpeg/ formats/jpeg/exif/ formats/jpeg/iptc/ formats/jpeg/xmp/ formats/png/ formats/tiff/ formats/tiff/write/ palette/ util/
Date Sun, 05 Feb 2012 07:47:23 GMT
Author: damjan
Date: Sun Feb  5 07:47:22 2012
New Revision: 1240671

URL: http://svn.apache.org/viewvc?rev=1240671&view=rev
Log:
Converted most collections to use generics,
converted all Comparable and Comparator instances to use generics,
and dropped most casts.


Modified:
    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/JpegImageParser.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/exif/ExifRewriter.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/iptc/IptcParser.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/png/PngWriter.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/TiffElement.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/TiffImageWriterLossless.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/write/TiffImageWriterLossy.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/palette/ColorSpaceSubset.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/util/Debug.java

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=1240671&r1=1240670&r2=1240671&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
Sun Feb  5 07:47:22 2012
@@ -93,7 +93,7 @@ public class JpegImageMetadata implement
      * @throws IOException
      */
     public byte[] getEXIFThumbnailData() throws ImageReadException, IOException {
-        List dirs = exif.getDirectories();
+        List<? extends IImageMetadataItem> dirs = exif.getDirectories();
         for (int i = 0; i < dirs.size(); i++) {
             TiffImageMetadata.Directory dir = (TiffImageMetadata.Directory) dirs
                     .get(i);
@@ -126,7 +126,7 @@ public class JpegImageMetadata implement
             return null;
         }
 
-        List dirs = exif.getDirectories();
+        List<? extends IImageMetadataItem> dirs = exif.getDirectories();
         for (int i = 0; i < dirs.size(); i++) {
             TiffImageMetadata.Directory dir = (TiffImageMetadata.Directory) dirs
                     .get(i);
@@ -151,7 +151,7 @@ public class JpegImageMetadata implement
     }
 
     public TiffImageData getRawImageData() {
-        List dirs = exif.getDirectories();
+        List<? extends IImageMetadataItem> dirs = exif.getDirectories();
         for (int i = 0; i < dirs.size(); i++) {
             TiffImageMetadata.Directory dir = (TiffImageMetadata.Directory) dirs
                     .get(i);
@@ -164,8 +164,8 @@ public class JpegImageMetadata implement
         return null;
     }
 
-    public List getItems() {
-        List<Object> result = new ArrayList<Object>();
+    public List<IImageMetadataItem> getItems() {
+        List<IImageMetadataItem> result = new ArrayList<IImageMetadataItem>();
 
         if (null != exif)
             result.addAll(exif.getItems());

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/JpegImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/JpegImageParser.java?rev=1240671&r1=1240670&r2=1240671&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/JpegImageParser.java
(original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/JpegImageParser.java
Sun Feb  5 07:47:22 2012
@@ -45,8 +45,8 @@ import org.apache.commons.sanselan.forma
 import org.apache.commons.sanselan.formats.jpeg.segments.DqtSegment;
 import org.apache.commons.sanselan.formats.jpeg.segments.GenericSegment;
 import org.apache.commons.sanselan.formats.jpeg.segments.JfifSegment;
-import org.apache.commons.sanselan.formats.jpeg.segments.SofnSegment;
 import org.apache.commons.sanselan.formats.jpeg.segments.Segment;
+import org.apache.commons.sanselan.formats.jpeg.segments.SofnSegment;
 import org.apache.commons.sanselan.formats.jpeg.segments.UnknownSegment;
 import org.apache.commons.sanselan.formats.jpeg.xmp.JpegXmpParser;
 import org.apache.commons.sanselan.formats.tiff.TiffField;

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/exif/ExifRewriter.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/exif/ExifRewriter.java?rev=1240671&r1=1240670&r2=1240671&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/exif/ExifRewriter.java
(original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/exif/ExifRewriter.java
Sun Feb  5 07:47:22 2012
@@ -33,7 +33,6 @@ import org.apache.commons.sanselan.commo
 import org.apache.commons.sanselan.common.bytesource.ByteSourceInputStream;
 import org.apache.commons.sanselan.formats.jpeg.JpegConstants;
 import org.apache.commons.sanselan.formats.jpeg.JpegUtils;
-import org.apache.commons.sanselan.formats.jpeg.segments.JfifSegment;
 import org.apache.commons.sanselan.formats.tiff.write.TiffImageWriterBase;
 import org.apache.commons.sanselan.formats.tiff.write.TiffImageWriterLossless;
 import org.apache.commons.sanselan.formats.tiff.write.TiffImageWriterLossy;
@@ -478,7 +477,7 @@ public class ExifRewriter extends Binary
 
             for (int i = 0; i < segments.size(); i++)
             {
-                JFIFPiece piece = (JFIFPiece) segments.get(i);
+                JFIFPiece piece = segments.get(i);
                 if (piece instanceof JFIFPieceSegmentExif)
                     hasExif = true;
             }
@@ -507,7 +506,7 @@ public class ExifRewriter extends Binary
 
             for (int i = 0; i < segments.size(); i++)
             {
-                JFIFPiece piece = (JFIFPiece) segments.get(i);
+                JFIFPiece piece = segments.get(i);
                 if (piece instanceof JFIFPieceSegmentExif)
                 {
                     // only replace first APP1 segment; skips others.

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/iptc/IptcParser.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/iptc/IptcParser.java?rev=1240671&r1=1240670&r2=1240671&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/iptc/IptcParser.java
(original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/iptc/IptcParser.java
Sun Feb  5 07:47:22 2012
@@ -117,7 +117,7 @@ public class IptcParser extends BinaryFi
 
         for (int i = 0; i < allBlocks.size(); i++)
         {
-            IptcBlock block = (IptcBlock) allBlocks.get(i);
+            IptcBlock block = allBlocks.get(i);
 
             // Ignore everything but IPTC data.
             if (!block.isIPTCBlock())
@@ -356,7 +356,7 @@ public class IptcParser extends BinaryFi
         List<IptcBlock> blocks = data.getRawBlocks();
         for (int i = 0; i < blocks.size(); i++)
         {
-            IptcBlock block = (IptcBlock) blocks.get(i);
+            IptcBlock block = blocks.get(i);
 
             bos.write(CONST_8BIM);
 
@@ -419,7 +419,7 @@ public class IptcParser extends BinaryFi
             // write the list.
             for (int i = 0; i < elements.size(); i++)
             {
-                IptcRecord element = (IptcRecord) elements.get(i);
+                IptcRecord element = elements.get(i);
 
                 if (element.iptcType == IptcTypes.RECORD_VERSION)
                     continue; // ignore

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=1240671&r1=1240670&r2=1240671&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
Sun Feb  5 07:47:22 2012
@@ -232,41 +232,41 @@ public class JpegRewriter extends Binary
         }
     };
 
-    protected List<JFIFPiece> removeXmpSegments(List<? extends JFIFPiece> segments)
+    protected <T extends JFIFPiece> List<T> removeXmpSegments(List<T> segments)
     {
         return filterSegments(segments, XMP_SEGMENT_FILTER);
     }
 
-    protected List<JFIFPiece> removePhotoshopApp13Segments(List<? extends JFIFPiece>
segments)
+    protected <T extends JFIFPiece> List<T> removePhotoshopApp13Segments(List<T>
segments)
     {
         return filterSegments(segments, PHOTOSHOP_APP13_SEGMENT_FILTER);
     }
 
-    protected List<JFIFPiece> findPhotoshopApp13Segments(List<? extends JFIFPiece>
segments)
+    protected <T extends JFIFPiece> List<T> findPhotoshopApp13Segments(List<T>
segments)
     {
         return filterSegments(segments, PHOTOSHOP_APP13_SEGMENT_FILTER, true);
     }
 
-    protected List<JFIFPiece> removeExifSegments(List<? extends JFIFPiece> segments)
+    protected <T extends JFIFPiece> List<T> removeExifSegments(List<T>
segments)
     {
         return filterSegments(segments, EXIF_SEGMENT_FILTER);
     }
 
-    protected List<JFIFPiece> filterSegments(List<? extends JFIFPiece> segments,
SegmentFilter filter)
+    protected <T extends JFIFPiece> List<T> filterSegments(List<T> segments,
SegmentFilter filter)
     {
         return filterSegments(segments, filter, false);
     }
 
-    protected List<JFIFPiece> filterSegments(
-            List<? extends JFIFPiece> segments,
+    protected <T extends JFIFPiece> List<T> filterSegments(
+            List<T> segments,
             SegmentFilter filter,
             boolean reverse)
     {
-        List<JFIFPiece> result = new ArrayList<JFIFPiece>();
+        List<T> result = new ArrayList<T>();
 
         for (int i = 0; i < segments.size(); i++)
         {
-            JFIFPiece piece = segments.get(i);
+            T piece = segments.get(i);
             if (piece instanceof JFIFPieceSegment)
             {
                 if (filter.filter((JFIFPieceSegment) piece) ^ !reverse)
@@ -278,9 +278,9 @@ public class JpegRewriter extends Binary
         return result;
     }
 
-    protected List<JFIFPiece> insertBeforeFirstAppSegments(
-            List<? extends JFIFPiece> segments,
-            List<? extends JFIFPiece> newSegments)
+    protected <T extends JFIFPiece, U extends JFIFPiece> List<JFIFPiece> insertBeforeFirstAppSegments(
+            List<T> segments,
+            List<U> newSegments)
                     throws ImageWriteException
     {
         int firstAppIndex = -1;
@@ -305,9 +305,9 @@ public class JpegRewriter extends Binary
         return result;
     }
 
-    protected List<JFIFPiece> insertAfterLastAppSegments(
-            List<? extends JFIFPiece> segments,
-            List<? extends JFIFPiece> newSegments)
+    protected <T extends JFIFPiece, U extends JFIFPiece> List<JFIFPiece> insertAfterLastAppSegments(
+            List<T> segments,
+            List<U> newSegments)
                     throws ImageWriteException
     {
         int lastAppIndex = -1;

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/png/PngWriter.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/png/PngWriter.java?rev=1240671&r1=1240670&r2=1240671&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/png/PngWriter.java
(original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/png/PngWriter.java
Sun Feb  5 07:47:22 2012
@@ -487,7 +487,7 @@ public class PngWriter implements PngCon
 
         if (params.containsKey(PARAM_KEY_PNG_TEXT_CHUNKS))
         {
-            List outputTexts = (List) params.get(PARAM_KEY_PNG_TEXT_CHUNKS);
+            List<PngText> outputTexts = (List<PngText>) params.get(PARAM_KEY_PNG_TEXT_CHUNKS);
             for (int i = 0; i < outputTexts.size(); i++)
             {
                 PngText text = (PngText) outputTexts.get(i);

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=1240671&r1=1240670&r2=1240671&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
Sun Feb  5 07:47:22 2012
@@ -35,9 +35,9 @@ public class TiffContents
         this.directories = directories;
     }
 
-    public List getElements() throws ImageReadException
+    public List<TiffElement> getElements() throws ImageReadException
     {
-        List result = new ArrayList();
+        List<TiffElement> result = new ArrayList<TiffElement>();
 
         result.add(header);
 
@@ -81,14 +81,14 @@ public class TiffContents
 
     public void dissect(boolean verbose) throws ImageReadException
     {
-        List elements = getElements();
+        List<TiffElement> elements = getElements();
 
         Collections.sort(elements, TiffElement.COMPARATOR);
 
         int lastEnd = 0;
         for (int i = 0; i < elements.size(); i++)
         {
-            TiffElement element = (TiffElement) elements.get(i);
+            TiffElement element = elements.get(i);
 
             if (element.offset > lastEnd)
                 Debug.debug("\t" + "gap: " + (element.offset - lastEnd));

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=1240671&r1=1240670&r2=1240671&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
Sun Feb  5 07:47:22 2012
@@ -193,7 +193,7 @@ public class TiffDirectory extends TiffE
         }
     }
 
-    private List getRawImageDataElements(TiffField offsetsField,
+    private List<ImageDataElement> getRawImageDataElements(TiffField offsetsField,
             TiffField byteCountsField) throws ImageReadException
     {
         int offsets[] = offsetsField.getIntArrayValue();
@@ -203,7 +203,7 @@ public class TiffDirectory extends TiffE
             throw new ImageReadException("offsets.length(" + offsets.length
                     + ") != byteCounts.length(" + byteCounts.length + ")");
 
-        List result = new ArrayList();
+        List<ImageDataElement> result = new ArrayList<ImageDataElement>();
         for (int i = 0; i < offsets.length; i++)
         {
             result.add(new ImageDataElement(offsets[i], byteCounts[i]));
@@ -211,7 +211,7 @@ public class TiffDirectory extends TiffE
         return result;
     }
 
-    public List getTiffRawImageDataElements() throws ImageReadException
+    public List<ImageDataElement> getTiffRawImageDataElements() throws ImageReadException
     {
         TiffField tileOffsets = findField(TIFF_TAG_TILE_OFFSETS);
         TiffField tileByteCounts = findField(TIFF_TAG_TILE_BYTE_COUNTS);

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/TiffElement.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/TiffElement.java?rev=1240671&r1=1240670&r2=1240671&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/TiffElement.java
(original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/TiffElement.java
Sun Feb  5 07:47:22 2012
@@ -36,12 +36,10 @@ public abstract class TiffElement
 
     public abstract String getElementDescription(boolean verbose);
 
-    public static final Comparator COMPARATOR = new Comparator()
+    public static final Comparator<TiffElement> COMPARATOR = new Comparator<TiffElement>()
     {
-        public int compare(Object o1, Object o2)
+        public int compare(TiffElement e1, TiffElement e2)
         {
-            TiffElement e1 = (TiffElement) o1;
-            TiffElement e2 = (TiffElement) o2;
             return e1.offset - e2.offset;
         }
     };

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=1240671&r1=1240670&r2=1240671&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
Sun Feb  5 07:47:22 2012
@@ -128,7 +128,7 @@ public class TiffImageMetadata extends I
             {
                 TiffOutputDirectory dstDir = new TiffOutputDirectory(type);
 
-                List entries = getItems();
+                List<? extends IImageMetadataItem> entries = getItems();
                 for (int i = 0; i < entries.size(); i++)
                 {
                     TiffImageMetadata.Item item = (TiffImageMetadata.Item) entries
@@ -185,16 +185,16 @@ public class TiffImageMetadata extends I
 
     }
 
-    public List getDirectories()
+    public List<? extends IImageMetadataItem> getDirectories()
     {
         return super.getItems();
     }
 
     public List<? extends IImageMetadataItem> getItems()
     {
-        List result = new ArrayList();
+        List<IImageMetadataItem> result = new ArrayList<IImageMetadataItem>();
 
-        List items = super.getItems();
+        List<? extends IImageMetadataItem> items = super.getItems();
         for (int i = 0; i < items.size(); i++)
         {
             Directory dir = (Directory) items.get(i);
@@ -227,7 +227,7 @@ public class TiffImageMetadata extends I
         int byteOrder = contents.header.byteOrder;
         TiffOutputSet result = new TiffOutputSet(byteOrder);
 
-        List srcDirs = getDirectories();
+        List<? extends IImageMetadataItem> srcDirs = getDirectories();
         for (int i = 0; i < srcDirs.size(); i++)
         {
             TiffImageMetadata.Directory srcDir = (TiffImageMetadata.Directory) srcDirs
@@ -260,7 +260,7 @@ public class TiffImageMetadata extends I
         Integer tagCount = tagCounts.get(new Integer(tagInfo.tag));
         int tagsMatching = tagCount == null ? 0 : tagCount.intValue();
 
-        List directories = getDirectories();
+        List<? extends IImageMetadataItem> directories = getDirectories();
         if (exactDirectoryMatch || tagInfo.directoryType != EXIF_DIRECTORY_UNKNOWN)
         {
             for (int i = 0; i < directories.size(); i++)
@@ -309,7 +309,7 @@ public class TiffImageMetadata extends I
 
     public TiffDirectory findDirectory(int directoryType)
     {
-        List directories = getDirectories();
+        List<? extends IImageMetadataItem> directories = getDirectories();
         for (int i = 0; i < directories.size(); i++)
         {
             Directory directory = (Directory) directories.get(i);
@@ -322,7 +322,7 @@ public class TiffImageMetadata extends I
     public List<TiffField> getAllFields()
     {
         List<TiffField> result = new ArrayList<TiffField>();
-        List directories = getDirectories();
+        List<? extends IImageMetadataItem> directories = getDirectories();
         for (int i = 0; i < directories.size(); i++)
         {
             Directory directory = (Directory) directories.get(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=1240671&r1=1240670&r2=1240671&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
Sun Feb  5 07:47:22 2012
@@ -35,6 +35,7 @@ import org.apache.commons.sanselan.Image
 import org.apache.commons.sanselan.ImageWriteException;
 import org.apache.commons.sanselan.common.IImageMetadata;
 import org.apache.commons.sanselan.common.bytesource.ByteSource;
+import org.apache.commons.sanselan.formats.tiff.TiffDirectory.ImageDataElement;
 import org.apache.commons.sanselan.formats.tiff.constants.TiffConstants;
 import org.apache.commons.sanselan.formats.tiff.datareaders.DataReader;
 import org.apache.commons.sanselan.formats.tiff.photometricinterpreters.PhotometricInterpreter;
@@ -417,7 +418,7 @@ public class TiffImageParser extends Ima
         {
             TiffDirectory directory = contents.directories
                     .get(i);
-            List dataElements = directory.getTiffRawImageDataElements();
+            List<ImageDataElement> dataElements = directory.getTiffRawImageDataElements();
             for (int j = 0; j < dataElements.size(); j++)
             {
                 TiffDirectory.ImageDataElement element = (TiffDirectory.ImageDataElement)
dataElements

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/TiffReader.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/TiffReader.java?rev=1240671&r1=1240670&r2=1240671&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/TiffReader.java
(original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/TiffReader.java
Sun Feb  5 07:47:22 2012
@@ -464,12 +464,11 @@ public class TiffReader extends BinaryFi
             TiffDirectory directory) throws ImageReadException, IOException
     {
 
-        List elements = directory.getTiffRawImageDataElements();
+        List<ImageDataElement> elements = directory.getTiffRawImageDataElements();
         TiffImageData.Data data[] = new TiffImageData.Data[elements.size()];
         for (int i = 0; i < elements.size(); i++)
         {
-            TiffDirectory.ImageDataElement element = (TiffDirectory.ImageDataElement) elements
-                    .get(i);
+            TiffDirectory.ImageDataElement element = elements.get(i);
             byte bytes[] = byteSource.getBlock(element.offset, element.length);
             data[i] = new TiffImageData.Data(element.offset, element.length,
                     bytes);

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/write/TiffImageWriterLossless.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/write/TiffImageWriterLossless.java?rev=1240671&r1=1240670&r2=1240671&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/write/TiffImageWriterLossless.java
(original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/write/TiffImageWriterLossless.java
Sun Feb  5 07:47:22 2012
@@ -119,7 +119,7 @@ public class TiffImageWriterLossless ext
         Debug.debug();
     }
 
-    private List analyzeOldTiff() throws ImageWriteException, IOException
+    private List<TiffElement> analyzeOldTiff() throws ImageWriteException, IOException
     {
         try
         {
@@ -129,7 +129,7 @@ public class TiffImageWriterLossless ext
             TiffContents contents = new TiffReader(false).readContents(byteSource,
                     params, formatCompliance);
 
-            List elements = new ArrayList();
+            List<TiffElement> elements = new ArrayList<TiffElement>();
             //            result.add(contents.header); // ?
 
             List<TiffDirectory> directories = contents.directories;
@@ -179,7 +179,7 @@ public class TiffImageWriterLossless ext
 
             //            dumpElements(byteSource, elements);
 
-            List result = new ArrayList();
+            List<TiffElement> result = new ArrayList<TiffElement>();
             {
                 final int TOLERANCE = 3;
                 //                int last = TIFF_HEADER_SIZE;
@@ -224,7 +224,7 @@ public class TiffImageWriterLossless ext
     public void write(OutputStream os, TiffOutputSet outputSet)
             throws IOException, ImageWriteException
     {
-        List analysis = analyzeOldTiff();
+        List<TiffElement> analysis = analyzeOldTiff();
         int oldLength = exifBytes.length;
         if (analysis.size() < 1)
             throw new ImageWriteException("Couldn't analyze old tiff data.");
@@ -249,7 +249,7 @@ public class TiffImageWriterLossless ext
 
         TiffOutputSummary outputSummary = validateDirectories(outputSet);
 
-        List outputItems = outputSet.getOutputItems(outputSummary);
+        List<TiffOutputItem> outputItems = outputSet.getOutputItems(outputSummary);
 
         int outputLength = updateOffsetsStep(analysis, outputItems);
         //        Debug.debug("outputLength", outputLength);
@@ -260,33 +260,29 @@ public class TiffImageWriterLossless ext
 
     }
 
-    private static final Comparator ELEMENT_SIZE_COMPARATOR = new Comparator()
+    private static final Comparator<TiffElement> ELEMENT_SIZE_COMPARATOR = new Comparator<TiffElement>()
     {
-        public int compare(Object o1, Object o2)
+        public int compare(TiffElement e1, TiffElement e2)
         {
-            TiffElement e1 = (TiffElement) o1;
-            TiffElement e2 = (TiffElement) o2;
             return e1.length - e2.length;
         }
     };
 
-    private static final Comparator ITEM_SIZE_COMPARATOR = new Comparator()
+    private static final Comparator<TiffOutputItem> ITEM_SIZE_COMPARATOR = new Comparator<TiffOutputItem>()
     {
-        public int compare(Object o1, Object o2)
+        public int compare(TiffOutputItem e1, TiffOutputItem e2)
         {
-            TiffOutputItem e1 = (TiffOutputItem) o1;
-            TiffOutputItem e2 = (TiffOutputItem) o2;
             return e1.getItemLength() - e2.getItemLength();
         }
     };
 
-    private int updateOffsetsStep(List analysis, List outputItems)
+    private int updateOffsetsStep(List<TiffElement> analysis, List<TiffOutputItem>
outputItems)
     {
         // items we cannot fit into a gap, we shall append to tail.
         int overflowIndex = exifBytes.length;
 
         // make copy.
-        List unusedElements = new ArrayList(analysis);
+        List<TiffElement> unusedElements = new ArrayList<TiffElement>(analysis);
 
         // should already be in order of offset, but make sure.
         Collections.sort(unusedElements, TiffElement.COMPARATOR);
@@ -313,7 +309,7 @@ public class TiffImageWriterLossless ext
         //        dumpElements(unusedElements);
 
         // make copy.
-        List unplacedItems = new ArrayList(outputItems);
+        List<TiffOutputItem> unplacedItems = new ArrayList<TiffOutputItem>(outputItems);
         Collections.sort(unplacedItems, ITEM_SIZE_COMPARATOR);
         Collections.reverse(unplacedItems);
 
@@ -411,7 +407,7 @@ public class TiffImageWriterLossless ext
     }
 
     private void writeStep(OutputStream os, TiffOutputSet outputSet,
-            List analysis, List outputItems, int outputLength)
+            List<TiffElement> analysis, List<TiffOutputItem> outputItems, int
outputLength)
             throws IOException, ImageWriteException
     {
         TiffOutputDirectory rootDirectory = outputSet.getRootDirectory();

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/write/TiffImageWriterLossy.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/write/TiffImageWriterLossy.java?rev=1240671&r1=1240670&r2=1240671&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/write/TiffImageWriterLossy.java
(original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/write/TiffImageWriterLossy.java
Sun Feb  5 07:47:22 2012
@@ -40,7 +40,7 @@ public class TiffImageWriterLossy extend
     {
         TiffOutputSummary outputSummary = validateDirectories(outputSet);
 
-        List outputItems = outputSet.getOutputItems(outputSummary);
+        List<TiffOutputItem> outputItems = outputSet.getOutputItems(outputSummary);
 
         updateOffsetsStep(outputItems);
 
@@ -51,13 +51,13 @@ public class TiffImageWriterLossy extend
         writeStep(bos, outputItems);
     }
 
-    private void updateOffsetsStep(List outputItems)
+    private void updateOffsetsStep(List<TiffOutputItem> outputItems)
     {
         int offset = TIFF_HEADER_SIZE;
 
         for (int i = 0; i < outputItems.size(); i++)
         {
-            TiffOutputItem outputItem = (TiffOutputItem) outputItems.get(i);
+            TiffOutputItem outputItem = outputItems.get(i);
 
             outputItem.setOffset(offset);
             int itemLength = outputItem.getItemLength();
@@ -68,14 +68,14 @@ public class TiffImageWriterLossy extend
         }
     }
 
-    private void writeStep(BinaryOutputStream bos, List outputItems)
+    private void writeStep(BinaryOutputStream bos, List<TiffOutputItem> outputItems)
             throws IOException, ImageWriteException
     {
         writeImageFileHeader(bos);
 
         for (int i = 0; i < outputItems.size(); i++)
         {
-            TiffOutputItem outputItem = (TiffOutputItem) outputItems.get(i);
+            TiffOutputItem outputItem = outputItems.get(i);
 
             outputItem.writeItem(bos);
 

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/write/TiffOutputDirectory.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/write/TiffOutputDirectory.java?rev=1240671&r1=1240670&r2=1240671&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/write/TiffOutputDirectory.java
(original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/write/TiffOutputDirectory.java
Sun Feb  5 07:47:22 2012
@@ -37,7 +37,7 @@ public final class TiffOutputDirectory e
         TiffConstants
 {
     public final int type;
-    private final List fields = new ArrayList();
+    private final List<TiffOutputField> fields = new ArrayList<TiffOutputField>();
 
     private TiffOutputDirectory nextDirectory = null;
 
@@ -56,9 +56,9 @@ public final class TiffOutputDirectory e
         fields.add(field);
     }
 
-    public List getFields()
+    public List<TiffOutputField> getFields()
     {
-        return new ArrayList(fields);
+        return new ArrayList<TiffOutputField>(fields);
     }
 
     public void removeField(TagInfo tagInfo)
@@ -96,12 +96,9 @@ public final class TiffOutputDirectory e
 
     public void sortFields()
     {
-        Comparator comparator = new Comparator() {
-            public int compare(Object o1, Object o2)
+        Comparator<TiffOutputField> comparator = new Comparator<TiffOutputField>()
{
+            public int compare(TiffOutputField e1, TiffOutputField e2)
             {
-                TiffOutputField e1 = (TiffOutputField) o1;
-                TiffOutputField e2 = (TiffOutputField) o2;
-
                 if (e1.tag != e2.tag)
                     return e1.tag - e2.tag;
                 return e1.getSortHint() - e2.getSortHint();
@@ -188,7 +185,7 @@ public final class TiffOutputDirectory e
             fields.remove(field);
     }
 
-    protected List getOutputItems(TiffOutputSummary outputSummary)
+    protected List<TiffOutputItem> getOutputItems(TiffOutputSummary outputSummary)
             throws ImageWriteException
     {
         // first validate directory fields.
@@ -281,13 +278,13 @@ public final class TiffOutputDirectory e
 
         // --------------------------------------------------------------
 
-        List result = new ArrayList();
+        List<TiffOutputItem> result = new ArrayList<TiffOutputItem>();
         result.add(this);
         sortFields();
 
         for (int i = 0; i < fields.size(); i++)
         {
-            TiffOutputField field = (TiffOutputField) fields.get(i);
+            TiffOutputField field = fields.get(i);
             if (field.isLocalValue())
                 continue;
 

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/write/TiffOutputSet.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/write/TiffOutputSet.java?rev=1240671&r1=1240670&r2=1240671&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/write/TiffOutputSet.java
(original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/write/TiffOutputSet.java
Sun Feb  5 07:47:22 2012
@@ -40,10 +40,10 @@ public final class TiffOutputSet impleme
         this.byteOrder = byteOrder;
     }
 
-    protected List getOutputItems(TiffOutputSummary outputSummary)
+    protected List<TiffOutputItem> getOutputItems(TiffOutputSummary outputSummary)
             throws ImageWriteException
     {
-        List result = new ArrayList();
+        List<TiffOutputItem> result = new ArrayList<TiffOutputItem>();
 
         for (int i = 0; i < directories.size(); i++)
         {
@@ -308,7 +308,7 @@ public final class TiffOutputSet impleme
                     + directory.description() + " (" + directory.type + ")");
             result.append(newline);
 
-            List fields = directory.getFields();
+            List<TiffOutputField> fields = directory.getFields();
             for (int j = 0; j < fields.size(); j++)
             {
                 TiffOutputField field = (TiffOutputField) fields.get(j);

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/palette/ColorSpaceSubset.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/palette/ColorSpaceSubset.java?rev=1240671&r1=1240670&r2=1240671&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/palette/ColorSpaceSubset.java
(original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/palette/ColorSpaceSubset.java
Sun Feb  5 07:47:22 2012
@@ -16,7 +16,7 @@
  */
 package org.apache.commons.sanselan.palette;
 
-class ColorSpaceSubset implements Comparable
+class ColorSpaceSubset implements Comparable<ColorSpaceSubset>
 {
     public final int mins[], maxs[];
     public final int precision;
@@ -162,9 +162,8 @@ class ColorSpaceSubset implements Compar
         }
     }
 
-    public int compareTo(Object o)
+    public int compareTo(ColorSpaceSubset other)
     {
-        ColorSpaceSubset other = (ColorSpaceSubset) o;
         return rgb - other.rgb;
     }
 

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/util/Debug.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/util/Debug.java?rev=1240671&r1=1240670&r2=1240671&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/util/Debug.java
(original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/util/Debug.java
Sun Feb  5 07:47:22 2012
@@ -158,7 +158,7 @@ public final class Debug
 
     private static long counter = 0;
 
-    public static String getDebug(String message, java.util.List v)
+    public static String getDebug(String message, java.util.List<?> v)
     {
         StringBuffer result = new StringBuffer();
 



Mime
View raw message