commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject svn commit: r1417043 [13/21] - in /commons/proper/imaging/trunk/src: main/java/org/apache/commons/imaging/ main/java/org/apache/commons/imaging/color/ main/java/org/apache/commons/imaging/common/ main/java/org/apache/commons/imaging/common/bytesource/ ...
Date Tue, 04 Dec 2012 17:24:32 GMT
Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffImageMetadata.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffImageMetadata.java?rev=1417043&r1=1417042&r2=1417043&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffImageMetadata.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffImageMetadata.java Tue Dec  4 17:23:16 2012
@@ -60,13 +60,13 @@ public class TiffImageMetadata extends I
         this.contents = contents;
     }
 
-    private static final Map<Object, Integer> countTags(List<TagInfo> tags) {
-        Map<Object, Integer> map = new Hashtable<Object, Integer>();
+    private static final Map<Object, Integer> countTags(final List<TagInfo> tags) {
+        final Map<Object, Integer> map = new Hashtable<Object, Integer>();
 
         for (int i = 0; i < tags.size(); i++) {
-            TagInfo tag = tags.get(i);
+            final TagInfo tag = tags.get(i);
 
-            Integer count = map.get(tag.tag);
+            final Integer count = map.get(tag.tag);
             if (count == null) {
                 map.put(tag.tag, 1);
             } else {
@@ -86,13 +86,13 @@ public class TiffImageMetadata extends I
         private final TiffDirectory directory;
         private final ByteOrder byteOrder;
 
-        public Directory(ByteOrder byteOrder, final TiffDirectory directory) {
+        public Directory(final ByteOrder byteOrder, final TiffDirectory directory) {
             this.type = directory.type;
             this.directory = directory;
             this.byteOrder = byteOrder;
         }
 
-        public void add(TiffField entry) {
+        public void add(final TiffField entry) {
             add(new TiffImageMetadata.Item(entry));
         }
 
@@ -105,7 +105,7 @@ public class TiffImageMetadata extends I
             return directory.getTiffImageData();
         }
 
-        public TiffField findField(TagInfo tagInfo) throws ImageReadException {
+        public TiffField findField(final TagInfo tagInfo) throws ImageReadException {
             return directory.findField(tagInfo);
         }
 
@@ -118,7 +118,7 @@ public class TiffImageMetadata extends I
         }
 
         @Override
-        public String toString(String prefix) {
+        public String toString(final String prefix) {
             return (prefix != null ? prefix : "") + directory.description()
                     + ": " //
                     + (getTiffImageData() != null ? " (tiffImageData)" : "") //
@@ -126,17 +126,17 @@ public class TiffImageMetadata extends I
                     + "\n" + super.toString(prefix) + "\n";
         }
 
-        public TiffOutputDirectory getOutputDirectory(ByteOrder byteOrder)
+        public TiffOutputDirectory getOutputDirectory(final ByteOrder byteOrder)
                 throws ImageWriteException {
             try {
-                TiffOutputDirectory dstDir = new TiffOutputDirectory(type,
+                final TiffOutputDirectory dstDir = new TiffOutputDirectory(type,
                         byteOrder);
 
-                List<? extends IImageMetadataItem> entries = getItems();
+                final List<? extends IImageMetadataItem> entries = getItems();
                 for (int i = 0; i < entries.size(); i++) {
-                    TiffImageMetadata.Item item = (TiffImageMetadata.Item) entries
+                    final TiffImageMetadata.Item item = (TiffImageMetadata.Item) entries
                             .get(i);
-                    TiffField srcField = item.getTiffField();
+                    final TiffField srcField = item.getTiffField();
 
                     if (null != dstDir.findField(srcField.tag)) {
                         // ignore duplicate tags in a directory.
@@ -146,17 +146,17 @@ public class TiffImageMetadata extends I
                         continue;
                     }
 
-                    TagInfo tagInfo = srcField.tagInfo;
-                    FieldType fieldType = srcField.fieldType;
+                    final TagInfo tagInfo = srcField.tagInfo;
+                    final FieldType fieldType = srcField.fieldType;
                     // byte bytes[] = srcField.fieldType.getRawBytes(srcField);
 
                     // Debug.debug("tagInfo", tagInfo);
 
-                    Object value = srcField.getValue();
+                    final Object value = srcField.getValue();
 
                     // Debug.debug("value", Debug.getType(value));
 
-                    byte bytes[] = tagInfo.encodeValue(fieldType, value,
+                    final byte bytes[] = tagInfo.encodeValue(fieldType, value,
                             byteOrder);
 
                     // if (tagInfo.isUnknown())
@@ -165,8 +165,8 @@ public class TiffImageMetadata extends I
                     // + Integer.toHexString(srcField.tag)
                     // + ") bytes", bytes);
 
-                    int count = bytes.length / fieldType.length;
-                    TiffOutputField dstField = new TiffOutputField(
+                    final int count = bytes.length / fieldType.length;
+                    final TiffOutputField dstField = new TiffOutputField(
                             srcField.tag, tagInfo, fieldType, count, bytes);
                     dstField.setSortHint(srcField.getSortHint());
                     dstDir.add(dstField);
@@ -176,7 +176,7 @@ public class TiffImageMetadata extends I
                 dstDir.setJpegImageData(getJpegImageData());
 
                 return dstDir;
-            } catch (ImageReadException e) {
+            } catch (final ImageReadException e) {
                 throw new ImageWriteException(e.getMessage(), e);
             }
         }
@@ -189,11 +189,11 @@ public class TiffImageMetadata extends I
 
     @Override
     public List<? extends IImageMetadataItem> getItems() {
-        List<IImageMetadataItem> result = new ArrayList<IImageMetadataItem>();
+        final List<IImageMetadataItem> result = new ArrayList<IImageMetadataItem>();
 
-        List<? extends IImageMetadataItem> items = super.getItems();
+        final List<? extends IImageMetadataItem> items = super.getItems();
         for (int i = 0; i < items.size(); i++) {
-            Directory dir = (Directory) items.get(i);
+            final Directory dir = (Directory) items.get(i);
             result.addAll(dir.getItems());
         }
 
@@ -203,7 +203,7 @@ public class TiffImageMetadata extends I
     public static class Item extends ImageMetadata.Item {
         private final TiffField entry;
 
-        public Item(TiffField entry) {
+        public Item(final TiffField entry) {
             // super(entry.getTagName() + " (" + entry.getFieldTypeName() + ")",
             super(entry.getTagName(), entry.getValueDescription());
             this.entry = entry;
@@ -216,12 +216,12 @@ public class TiffImageMetadata extends I
     }
 
     public TiffOutputSet getOutputSet() throws ImageWriteException {
-        ByteOrder byteOrder = contents.header.byteOrder;
-        TiffOutputSet result = new TiffOutputSet(byteOrder);
+        final ByteOrder byteOrder = contents.header.byteOrder;
+        final TiffOutputSet result = new TiffOutputSet(byteOrder);
 
-        List<? extends IImageMetadataItem> srcDirs = getDirectories();
+        final List<? extends IImageMetadataItem> srcDirs = getDirectories();
         for (int i = 0; i < srcDirs.size(); i++) {
-            TiffImageMetadata.Directory srcDir = (TiffImageMetadata.Directory) srcDirs
+            final TiffImageMetadata.Directory srcDir = (TiffImageMetadata.Directory) srcDirs
                     .get(i);
 
             if (null != result.findDirectory(srcDir.type)) {
@@ -231,7 +231,7 @@ public class TiffImageMetadata extends I
                 continue;
             }
 
-            TiffOutputDirectory outputDirectory = srcDir
+            final TiffOutputDirectory outputDirectory = srcDir
                     .getOutputDirectory(byteOrder);
             result.addDirectory(outputDirectory);
         }
@@ -239,23 +239,23 @@ public class TiffImageMetadata extends I
         return result;
     }
 
-    public TiffField findField(TagInfo tagInfo) throws ImageReadException {
+    public TiffField findField(final TagInfo tagInfo) throws ImageReadException {
         return findField(tagInfo, false);
     }
 
-    public TiffField findField(TagInfo tagInfo, boolean exactDirectoryMatch)
+    public TiffField findField(final TagInfo tagInfo, final boolean exactDirectoryMatch)
             throws ImageReadException {
         // Please keep this method in sync with TiffField's getTag()
-        Integer tagCount = tagCounts.get(tagInfo.tag);
-        int tagsMatching = tagCount == null ? 0 : tagCount.intValue();
+        final Integer tagCount = tagCounts.get(tagInfo.tag);
+        final int tagsMatching = tagCount == null ? 0 : tagCount.intValue();
 
-        List<? extends IImageMetadataItem> directories = getDirectories();
+        final List<? extends IImageMetadataItem> directories = getDirectories();
         if (exactDirectoryMatch
                 || tagInfo.directoryType != TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN) {
             for (int i = 0; i < directories.size(); i++) {
-                Directory directory = (Directory) directories.get(i);
+                final Directory directory = (Directory) directories.get(i);
                 if (directory.type == tagInfo.directoryType.directoryType) {
-                    TiffField field = directory.findField(tagInfo);
+                    final TiffField field = directory.findField(tagInfo);
                     if (field != null) {
                         return field;
                     }
@@ -265,16 +265,16 @@ public class TiffImageMetadata extends I
                 return null;
             }
             for (int i = 0; i < directories.size(); i++) {
-                Directory directory = (Directory) directories.get(i);
+                final Directory directory = (Directory) directories.get(i);
                 if (tagInfo.directoryType.isImageDirectory()
                         && directory.type >= 0) {
-                    TiffField field = directory.findField(tagInfo);
+                    final TiffField field = directory.findField(tagInfo);
                     if (field != null) {
                         return field;
                     }
                 } else if (!tagInfo.directoryType.isImageDirectory()
                         && directory.type < 0) {
-                    TiffField field = directory.findField(tagInfo);
+                    final TiffField field = directory.findField(tagInfo);
                     if (field != null) {
                         return field;
                     }
@@ -283,8 +283,8 @@ public class TiffImageMetadata extends I
         }
 
         for (int i = 0; i < directories.size(); i++) {
-            Directory directory = (Directory) directories.get(i);
-            TiffField field = directory.findField(tagInfo);
+            final Directory directory = (Directory) directories.get(i);
+            final TiffField field = directory.findField(tagInfo);
             if (field != null) {
                 return field;
             }
@@ -293,16 +293,16 @@ public class TiffImageMetadata extends I
         return null;
     }
 
-    public Object getFieldValue(TagInfo tag) throws ImageReadException {
-        TiffField field = findField(tag);
+    public Object getFieldValue(final TagInfo tag) throws ImageReadException {
+        final TiffField field = findField(tag);
         if (field == null) {
             return null;
         }
         return field.getValue();
     }
 
-    public byte[] getFieldValue(TagInfoByte tag) throws ImageReadException {
-        TiffField field = findField(tag);
+    public byte[] getFieldValue(final TagInfoByte tag) throws ImageReadException {
+        final TiffField field = findField(tag);
         if (field == null) {
             return null;
         }
@@ -312,57 +312,57 @@ public class TiffImageMetadata extends I
         return field.fieldType.getRawBytes(field);
     }
 
-    public String[] getFieldValue(TagInfoAscii tag) throws ImageReadException {
-        TiffField field = findField(tag);
+    public String[] getFieldValue(final TagInfoAscii tag) throws ImageReadException {
+        final TiffField field = findField(tag);
         if (field == null) {
             return null;
         }
         if (!tag.dataTypes.contains(field.fieldType)) {
             return null;
         }
-        byte[] bytes = field.fieldType.getRawBytes(field);
+        final byte[] bytes = field.fieldType.getRawBytes(field);
         return tag.getValue(field.byteOrder, bytes);
     }
 
-    public short[] getFieldValue(TagInfoShort tag) throws ImageReadException {
-        TiffField field = findField(tag);
+    public short[] getFieldValue(final TagInfoShort tag) throws ImageReadException {
+        final TiffField field = findField(tag);
         if (field == null) {
             return null;
         }
         if (!tag.dataTypes.contains(field.fieldType)) {
             return null;
         }
-        byte[] bytes = field.fieldType.getRawBytes(field);
+        final byte[] bytes = field.fieldType.getRawBytes(field);
         return tag.getValue(field.byteOrder, bytes);
     }
 
-    public int[] getFieldValue(TagInfoLong tag) throws ImageReadException {
-        TiffField field = findField(tag);
+    public int[] getFieldValue(final TagInfoLong tag) throws ImageReadException {
+        final TiffField field = findField(tag);
         if (field == null) {
             return null;
         }
         if (!tag.dataTypes.contains(field.fieldType)) {
             return null;
         }
-        byte[] bytes = field.fieldType.getRawBytes(field);
+        final byte[] bytes = field.fieldType.getRawBytes(field);
         return tag.getValue(field.byteOrder, bytes);
     }
 
-    public RationalNumber[] getFieldValue(TagInfoRational tag)
+    public RationalNumber[] getFieldValue(final TagInfoRational tag)
             throws ImageReadException {
-        TiffField field = findField(tag);
+        final TiffField field = findField(tag);
         if (field == null) {
             return null;
         }
         if (!tag.dataTypes.contains(field.fieldType)) {
             return null;
         }
-        byte[] bytes = field.fieldType.getRawBytes(field);
+        final byte[] bytes = field.fieldType.getRawBytes(field);
         return tag.getValue(field.byteOrder, bytes);
     }
 
-    public byte[] getFieldValue(TagInfoSByte tag) throws ImageReadException {
-        TiffField field = findField(tag);
+    public byte[] getFieldValue(final TagInfoSByte tag) throws ImageReadException {
+        final TiffField field = findField(tag);
         if (field == null) {
             return null;
         }
@@ -372,87 +372,87 @@ public class TiffImageMetadata extends I
         return field.fieldType.getRawBytes(field);
     }
 
-    public short[] getFieldValue(TagInfoSShort tag) throws ImageReadException {
-        TiffField field = findField(tag);
+    public short[] getFieldValue(final TagInfoSShort tag) throws ImageReadException {
+        final TiffField field = findField(tag);
         if (field == null) {
             return null;
         }
         if (!tag.dataTypes.contains(field.fieldType)) {
             return null;
         }
-        byte[] bytes = field.fieldType.getRawBytes(field);
+        final byte[] bytes = field.fieldType.getRawBytes(field);
         return tag.getValue(field.byteOrder, bytes);
     }
 
-    public int[] getFieldValue(TagInfoSLong tag) throws ImageReadException {
-        TiffField field = findField(tag);
+    public int[] getFieldValue(final TagInfoSLong tag) throws ImageReadException {
+        final TiffField field = findField(tag);
         if (field == null) {
             return null;
         }
         if (!tag.dataTypes.contains(field.fieldType)) {
             return null;
         }
-        byte[] bytes = field.fieldType.getRawBytes(field);
+        final byte[] bytes = field.fieldType.getRawBytes(field);
         return tag.getValue(field.byteOrder, bytes);
     }
 
-    public RationalNumber[] getFieldValue(TagInfoSRational tag)
+    public RationalNumber[] getFieldValue(final TagInfoSRational tag)
             throws ImageReadException {
-        TiffField field = findField(tag);
+        final TiffField field = findField(tag);
         if (field == null) {
             return null;
         }
         if (!tag.dataTypes.contains(field.fieldType)) {
             return null;
         }
-        byte[] bytes = field.fieldType.getRawBytes(field);
+        final byte[] bytes = field.fieldType.getRawBytes(field);
         return tag.getValue(field.byteOrder, bytes);
     }
 
-    public float[] getFieldValue(TagInfoFloat tag) throws ImageReadException {
-        TiffField field = findField(tag);
+    public float[] getFieldValue(final TagInfoFloat tag) throws ImageReadException {
+        final TiffField field = findField(tag);
         if (field == null) {
             return null;
         }
         if (!tag.dataTypes.contains(field.fieldType)) {
             return null;
         }
-        byte[] bytes = field.fieldType.getRawBytes(field);
+        final byte[] bytes = field.fieldType.getRawBytes(field);
         return tag.getValue(field.byteOrder, bytes);
     }
 
-    public double[] getFieldValue(TagInfoDouble tag) throws ImageReadException {
-        TiffField field = findField(tag);
+    public double[] getFieldValue(final TagInfoDouble tag) throws ImageReadException {
+        final TiffField field = findField(tag);
         if (field == null) {
             return null;
         }
         if (!tag.dataTypes.contains(field.fieldType)) {
             return null;
         }
-        byte[] bytes = field.fieldType.getRawBytes(field);
+        final byte[] bytes = field.fieldType.getRawBytes(field);
         return tag.getValue(field.byteOrder, bytes);
     }
 
-    public String getFieldValue(TagInfoGpsText tag) throws ImageReadException {
-        TiffField field = findField(tag);
+    public String getFieldValue(final TagInfoGpsText tag) throws ImageReadException {
+        final TiffField field = findField(tag);
         if (field == null) {
             return null;
         }
         return tag.getValue(field);
     }
 
-    public String getFieldValue(TagInfoXpString tag) throws ImageReadException {
-        TiffField field = findField(tag);
+    public String getFieldValue(final TagInfoXpString tag) throws ImageReadException {
+        final TiffField field = findField(tag);
         if (field == null) {
             return null;
         }
         return tag.getValue(field);
     }
 
-    public TiffDirectory findDirectory(int directoryType) {
-        List<? extends IImageMetadataItem> directories = getDirectories();
+    public TiffDirectory findDirectory(final int directoryType) {
+        final List<? extends IImageMetadataItem> directories = getDirectories();
         for (int i = 0; i < directories.size(); i++) {
-            Directory directory = (Directory) directories.get(i);
+            final Directory directory = (Directory) directories.get(i);
             if (directory.type == directoryType) {
                 return directory.directory;
             }
@@ -461,29 +461,29 @@ public class TiffImageMetadata extends I
     }
 
     public List<TiffField> getAllFields() {
-        List<TiffField> result = new ArrayList<TiffField>();
-        List<? extends IImageMetadataItem> directories = getDirectories();
+        final List<TiffField> result = new ArrayList<TiffField>();
+        final List<? extends IImageMetadataItem> directories = getDirectories();
         for (int i = 0; i < directories.size(); i++) {
-            Directory directory = (Directory) directories.get(i);
+            final Directory directory = (Directory) directories.get(i);
             result.addAll(directory.getAllFields());
         }
         return result;
     }
 
     public GPSInfo getGPS() throws ImageReadException {
-        TiffDirectory gpsDirectory = findDirectory(DIRECTORY_TYPE_GPS);
+        final TiffDirectory gpsDirectory = findDirectory(DIRECTORY_TYPE_GPS);
         if (null == gpsDirectory) {
             return null;
         }
 
         // more specific example of how to access GPS values.
-        TiffField latitudeRefField = gpsDirectory
+        final TiffField latitudeRefField = gpsDirectory
                 .findField(GpsTagConstants.GPS_TAG_GPS_LATITUDE_REF);
-        TiffField latitudeField = gpsDirectory
+        final TiffField latitudeField = gpsDirectory
                 .findField(GpsTagConstants.GPS_TAG_GPS_LATITUDE);
-        TiffField longitudeRefField = gpsDirectory
+        final TiffField longitudeRefField = gpsDirectory
                 .findField(GpsTagConstants.GPS_TAG_GPS_LONGITUDE_REF);
-        TiffField longitudeField = gpsDirectory
+        final TiffField longitudeField = gpsDirectory
                 .findField(GpsTagConstants.GPS_TAG_GPS_LONGITUDE);
 
         if (latitudeRefField == null || latitudeField == null
@@ -492,10 +492,10 @@ public class TiffImageMetadata extends I
         }
 
         // all of these values are strings.
-        String latitudeRef = latitudeRefField.getStringValue();
-        RationalNumber latitude[] = (RationalNumber[]) latitudeField.getValue();
-        String longitudeRef = longitudeRefField.getStringValue();
-        RationalNumber longitude[] = (RationalNumber[]) longitudeField
+        final String latitudeRef = latitudeRefField.getStringValue();
+        final RationalNumber latitude[] = (RationalNumber[]) latitudeField.getValue();
+        final String longitudeRef = longitudeRefField.getStringValue();
+        final RationalNumber longitude[] = (RationalNumber[]) longitudeField
                 .getValue();
 
         if (latitude.length != 3 || longitude.length != 3) {
@@ -503,13 +503,13 @@ public class TiffImageMetadata extends I
                     "Expected three values for latitude and longitude.");
         }
 
-        RationalNumber latitudeDegrees = latitude[0];
-        RationalNumber latitudeMinutes = latitude[1];
-        RationalNumber latitudeSeconds = latitude[2];
-
-        RationalNumber longitudeDegrees = longitude[0];
-        RationalNumber longitudeMinutes = longitude[1];
-        RationalNumber longitudeSeconds = longitude[2];
+        final RationalNumber latitudeDegrees = latitude[0];
+        final RationalNumber latitudeMinutes = latitude[1];
+        final RationalNumber latitudeSeconds = latitude[2];
+
+        final RationalNumber longitudeDegrees = longitude[0];
+        final RationalNumber longitudeMinutes = longitude[1];
+        final RationalNumber longitudeSeconds = longitude[2];
 
         return new GPSInfo(latitudeRef, longitudeRef, latitudeDegrees,
                 latitudeMinutes, latitudeSeconds, longitudeDegrees,
@@ -551,7 +551,7 @@ public class TiffImageMetadata extends I
             // latitude: 8 degrees, 40 minutes, 42.2 seconds S
             // longitude: 115 degrees, 26 minutes, 21.8 seconds E
 
-            StringBuilder result = new StringBuilder();
+            final StringBuilder result = new StringBuilder();
             result.append("[GPS. ");
             result.append("Latitude: " + latitudeDegrees.toDisplayString()
                     + " degrees, " + latitudeMinutes.toDisplayString()
@@ -567,7 +567,7 @@ public class TiffImageMetadata extends I
         }
 
         public double getLongitudeAsDegreesEast() throws ImageReadException {
-            double result = longitudeDegrees.doubleValue()
+            final double result = longitudeDegrees.doubleValue()
                     + (longitudeMinutes.doubleValue() / 60.0)
                     + (longitudeSeconds.doubleValue() / 3600.0);
 
@@ -582,7 +582,7 @@ public class TiffImageMetadata extends I
         }
 
         public double getLatitudeAsDegreesNorth() throws ImageReadException {
-            double result = latitudeDegrees.doubleValue()
+            final double result = latitudeDegrees.doubleValue()
                     + (latitudeMinutes.doubleValue() / 60.0)
                     + (latitudeSeconds.doubleValue() / 3600.0);
 

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffImageParser.java?rev=1417043&r1=1417042&r2=1417043&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffImageParser.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffImageParser.java Tue Dec  4 17:23:16 2012
@@ -83,71 +83,71 @@ public class TiffImageParser extends Ima
     }
 
     @Override
-    public byte[] getICCProfileBytes(ByteSource byteSource, Map<String,Object> params)
+    public byte[] getICCProfileBytes(final ByteSource byteSource, final Map<String,Object> params)
             throws ImageReadException, IOException {
-        FormatCompliance formatCompliance = FormatCompliance.getDefault();
-        TiffContents contents = new TiffReader(isStrict(params))
+        final FormatCompliance formatCompliance = FormatCompliance.getDefault();
+        final TiffContents contents = new TiffReader(isStrict(params))
                 .readFirstDirectory(byteSource, params, false, formatCompliance);
-        TiffDirectory directory = contents.directories.get(0);
+        final TiffDirectory directory = contents.directories.get(0);
 
         return directory.getFieldValue(AllTagConstants.EXIF_TAG_INTER_COLOR_PROFILE,
                 false);
     }
 
     @Override
-    public Dimension getImageSize(ByteSource byteSource, Map<String,Object> params)
+    public Dimension getImageSize(final ByteSource byteSource, final Map<String,Object> params)
             throws ImageReadException, IOException {
-        FormatCompliance formatCompliance = FormatCompliance.getDefault();
-        TiffContents contents = new TiffReader(isStrict(params))
+        final FormatCompliance formatCompliance = FormatCompliance.getDefault();
+        final TiffContents contents = new TiffReader(isStrict(params))
                 .readFirstDirectory(byteSource, params, false, formatCompliance);
-        TiffDirectory directory = contents.directories.get(0);
+        final TiffDirectory directory = contents.directories.get(0);
 
-        TiffField widthField = directory.findField(
+        final TiffField widthField = directory.findField(
                 TiffTagConstants.TIFF_TAG_IMAGE_WIDTH, true);
-        TiffField heightField = directory.findField(
+        final TiffField heightField = directory.findField(
                 TiffTagConstants.TIFF_TAG_IMAGE_LENGTH, true);
 
         if ((widthField == null) || (heightField == null)) {
             throw new ImageReadException("TIFF image missing size info.");
         }
 
-        int height = heightField.getIntValue();
-        int width = widthField.getIntValue();
+        final int height = heightField.getIntValue();
+        final int width = widthField.getIntValue();
 
         return new Dimension(width, height);
     }
 
-    public byte[] embedICCProfile(byte image[], byte profile[]) {
+    public byte[] embedICCProfile(final byte image[], final byte profile[]) {
         return null;
     }
 
     @Override
-    public boolean embedICCProfile(File src, File dst, byte profile[]) {
+    public boolean embedICCProfile(final File src, final File dst, final byte profile[]) {
         return false;
     }
 
     @Override
-    public IImageMetadata getMetadata(ByteSource byteSource, Map<String,Object> params)
+    public IImageMetadata getMetadata(final ByteSource byteSource, final Map<String,Object> params)
             throws ImageReadException, IOException {
-        FormatCompliance formatCompliance = FormatCompliance.getDefault();
-        TiffReader tiffReader = new TiffReader(isStrict(params));
-        TiffContents contents = tiffReader.readContents(byteSource, params,
+        final FormatCompliance formatCompliance = FormatCompliance.getDefault();
+        final TiffReader tiffReader = new TiffReader(isStrict(params));
+        final TiffContents contents = tiffReader.readContents(byteSource, params,
                 formatCompliance);
 
-        List<TiffDirectory> directories = contents.directories;
+        final List<TiffDirectory> directories = contents.directories;
 
-        TiffImageMetadata result = new TiffImageMetadata(contents);
+        final TiffImageMetadata result = new TiffImageMetadata(contents);
 
         for (int i = 0; i < directories.size(); i++) {
-            TiffDirectory dir = directories.get(i);
+            final TiffDirectory dir = directories.get(i);
 
-            TiffImageMetadata.Directory metadataDirectory = new TiffImageMetadata.Directory(
+            final TiffImageMetadata.Directory metadataDirectory = new TiffImageMetadata.Directory(
                     tiffReader.getByteOrder(), dir);
 
-            List<TiffField> entries = dir.getDirectoryEntrys();
+            final List<TiffField> entries = dir.getDirectoryEntrys();
 
             for (int j = 0; j < entries.size(); j++) {
-                TiffField entry = entries.get(j);
+                final TiffField entry = entries.get(j);
                 metadataDirectory.add(entry);
             }
 
@@ -158,28 +158,28 @@ public class TiffImageParser extends Ima
     }
 
     @Override
-    public ImageInfo getImageInfo(ByteSource byteSource, Map<String,Object> params)
+    public ImageInfo getImageInfo(final ByteSource byteSource, final Map<String,Object> params)
             throws ImageReadException, IOException {
-        FormatCompliance formatCompliance = FormatCompliance.getDefault();
-        TiffContents contents = new TiffReader(isStrict(params))
+        final FormatCompliance formatCompliance = FormatCompliance.getDefault();
+        final TiffContents contents = new TiffReader(isStrict(params))
                 .readDirectories(byteSource, false, formatCompliance);
-        TiffDirectory directory = contents.directories.get(0);
+        final TiffDirectory directory = contents.directories.get(0);
 
-        TiffField widthField = directory.findField(
+        final TiffField widthField = directory.findField(
                 TiffTagConstants.TIFF_TAG_IMAGE_WIDTH, true);
-        TiffField heightField = directory.findField(
+        final TiffField heightField = directory.findField(
                 TiffTagConstants.TIFF_TAG_IMAGE_LENGTH, true);
 
         if ((widthField == null) || (heightField == null)) {
             throw new ImageReadException("TIFF image missing size info.");
         }
 
-        int height = heightField.getIntValue();
-        int width = widthField.getIntValue();
+        final int height = heightField.getIntValue();
+        final int width = widthField.getIntValue();
 
         // -------------------
 
-        TiffField resolutionUnitField = directory
+        final TiffField resolutionUnitField = directory
                 .findField(TiffTagConstants.TIFF_TAG_RESOLUTION_UNIT);
         int resolutionUnit = 2; // Inch
         if ((resolutionUnitField != null)
@@ -201,9 +201,9 @@ public class TiffImageParser extends Ima
             break;
 
         }
-        TiffField xResolutionField = directory
+        final TiffField xResolutionField = directory
                 .findField(TiffTagConstants.TIFF_TAG_XRESOLUTION);
-        TiffField yResolutionField = directory
+        final TiffField yResolutionField = directory
                 .findField(TiffTagConstants.TIFF_TAG_YRESOLUTION);
 
         int physicalWidthDpi = -1;
@@ -214,7 +214,7 @@ public class TiffImageParser extends Ima
         if (unitsPerInch > 0) {
             if ((xResolutionField != null)
                     && (xResolutionField.getValue() != null)) {
-                double XResolutionPixelsPerUnit = xResolutionField
+                final double XResolutionPixelsPerUnit = xResolutionField
                         .getDoubleValue();
                 physicalWidthDpi = (int) Math
                         .round((XResolutionPixelsPerUnit * unitsPerInch));
@@ -222,7 +222,7 @@ public class TiffImageParser extends Ima
             }
             if ((yResolutionField != null)
                     && (yResolutionField.getValue() != null)) {
-                double YResolutionPixelsPerUnit = yResolutionField
+                final double YResolutionPixelsPerUnit = yResolutionField
                         .getDoubleValue();
                 physicalHeightDpi = (int) Math
                         .round((YResolutionPixelsPerUnit * unitsPerInch));
@@ -232,7 +232,7 @@ public class TiffImageParser extends Ima
 
         // -------------------
 
-        TiffField bitsPerSampleField = directory
+        final TiffField bitsPerSampleField = directory
                 .findField(TiffTagConstants.TIFF_TAG_BITS_PER_SAMPLE);
 
         int bitsPerSample = 1;
@@ -241,40 +241,40 @@ public class TiffImageParser extends Ima
             bitsPerSample = bitsPerSampleField.getIntValueOrArraySum();
         }
 
-        int bitsPerPixel = bitsPerSample; // assume grayscale;
+        final int bitsPerPixel = bitsPerSample; // assume grayscale;
         // dunno if this handles colormapped images correctly.
 
         // -------------------
 
-        List<String> comments = new ArrayList<String>();
-        List<TiffField> entries = directory.entries;
+        final List<String> comments = new ArrayList<String>();
+        final List<TiffField> entries = directory.entries;
         for (int i = 0; i < entries.size(); i++) {
-            TiffField field = entries.get(i);
-            String comment = field.toString();
+            final TiffField field = entries.get(i);
+            final String comment = field.toString();
             comments.add(comment);
         }
 
-        ImageFormat format = ImageFormat.IMAGE_FORMAT_TIFF;
-        String formatName = "TIFF Tag-based Image File Format";
-        String mimeType = "image/tiff";
-        int numberOfImages = contents.directories.size();
+        final ImageFormat format = ImageFormat.IMAGE_FORMAT_TIFF;
+        final String formatName = "TIFF Tag-based Image File Format";
+        final String mimeType = "image/tiff";
+        final int numberOfImages = contents.directories.size();
         // not accurate ... only reflects first
-        boolean isProgressive = false;
+        final boolean isProgressive = false;
         // is TIFF ever interlaced/progressive?
 
-        String formatDetails = "Tiff v." + contents.header.tiffVersion;
+        final String formatDetails = "Tiff v." + contents.header.tiffVersion;
 
-        boolean isTransparent = false; // TODO: wrong
+        final boolean isTransparent = false; // TODO: wrong
         boolean usesPalette = false;
-        TiffField colorMapField = directory
+        final TiffField colorMapField = directory
                 .findField(TiffTagConstants.TIFF_TAG_COLOR_MAP);
         if (colorMapField != null) {
             usesPalette = true;
         }
 
-        int colorType = ImageInfo.COLOR_TYPE_RGB;
+        final int colorType = ImageInfo.COLOR_TYPE_RGB;
 
-        int compression = 0xffff & directory
+        final int compression = 0xffff & directory
                 .getSingleFieldValue(TiffTagConstants.TIFF_TAG_COMPRESSION);
         String compressionAlgorithm;
 
@@ -308,7 +308,7 @@ public class TiffImageParser extends Ima
             break;
         }
 
-        ImageInfo result = new ImageInfo(formatDetails, bitsPerPixel, comments,
+        final ImageInfo result = new ImageInfo(formatDetails, bitsPerPixel, comments,
                 format, formatName, height, mimeType, numberOfImages,
                 physicalHeightDpi, physicalHeightInch, physicalWidthDpi,
                 physicalWidthInch, width, isProgressive, isTransparent,
@@ -318,14 +318,14 @@ public class TiffImageParser extends Ima
     }
 
     @Override
-    public String getXmpXml(ByteSource byteSource, Map<String,Object> params)
+    public String getXmpXml(final ByteSource byteSource, final Map<String,Object> params)
             throws ImageReadException, IOException {
-        FormatCompliance formatCompliance = FormatCompliance.getDefault();
-        TiffContents contents = new TiffReader(isStrict(params))
+        final FormatCompliance formatCompliance = FormatCompliance.getDefault();
+        final TiffContents contents = new TiffReader(isStrict(params))
                 .readDirectories(byteSource, false, formatCompliance);
-        TiffDirectory directory = contents.directories.get(0);
+        final TiffDirectory directory = contents.directories.get(0);
 
-        byte bytes[] = directory.getFieldValue(TiffTagConstants.TIFF_TAG_XMP,
+        final byte bytes[] = directory.getFieldValue(TiffTagConstants.TIFF_TAG_XMP,
                 false);
         if (bytes == null) {
             return null;
@@ -333,21 +333,21 @@ public class TiffImageParser extends Ima
 
         try {
             // segment data is UTF-8 encoded xml.
-            String xml = new String(bytes, "utf-8");
+            final String xml = new String(bytes, "utf-8");
             return xml;
-        } catch (UnsupportedEncodingException e) {
+        } catch (final UnsupportedEncodingException e) {
             throw new ImageReadException("Invalid JPEG XMP Segment.");
         }
     }
 
     @Override
-    public boolean dumpImageFile(PrintWriter pw, ByteSource byteSource)
+    public boolean dumpImageFile(final PrintWriter pw, final ByteSource byteSource)
             throws ImageReadException, IOException {
         try {
             pw.println("tiff.dumpImageFile");
 
             {
-                ImageInfo imageData = getImageInfo(byteSource);
+                final ImageInfo imageData = getImageInfo(byteSource);
                 if (imageData == null) {
                     return false;
                 }
@@ -359,22 +359,22 @@ public class TiffImageParser extends Ima
 
             // try
             {
-                FormatCompliance formatCompliance = FormatCompliance
+                final FormatCompliance formatCompliance = FormatCompliance
                         .getDefault();
-                Map<String,Object> params = null;
-                TiffContents contents = new TiffReader(true).readContents(
+                final Map<String,Object> params = null;
+                final TiffContents contents = new TiffReader(true).readContents(
                         byteSource, params, formatCompliance);
 
-                List<TiffDirectory> directories = contents.directories;
+                final List<TiffDirectory> directories = contents.directories;
 
                 if (directories == null) {
                     return false;
                 }
 
                 for (int d = 0; d < directories.size(); d++) {
-                    TiffDirectory directory = directories.get(d);
+                    final TiffDirectory directory = directories.get(d);
 
-                    List<TiffField> entries = directory.entries;
+                    final List<TiffField> entries = directory.entries;
 
                     if (entries == null) {
                         return false;
@@ -383,7 +383,7 @@ public class TiffImageParser extends Ima
                     // Debug.debug("directory offset", directory.offset);
 
                     for (int i = 0; i < entries.size(); i++) {
-                        TiffField field = entries.get(i);
+                        final TiffField field = entries.get(i);
 
                         field.dump(pw, d + "");
                     }
@@ -405,29 +405,29 @@ public class TiffImageParser extends Ima
     }
 
     @Override
-    public FormatCompliance getFormatCompliance(ByteSource byteSource)
+    public FormatCompliance getFormatCompliance(final ByteSource byteSource)
             throws ImageReadException, IOException {
-        FormatCompliance formatCompliance = FormatCompliance.getDefault();
-        Map<String,Object> params = null;
+        final FormatCompliance formatCompliance = FormatCompliance.getDefault();
+        final Map<String,Object> params = null;
         new TiffReader(isStrict(params)).readContents(byteSource, params,
                 formatCompliance);
         return formatCompliance;
     }
 
-    public List<byte[]> collectRawImageData(ByteSource byteSource, Map<String,Object> params)
+    public List<byte[]> collectRawImageData(final ByteSource byteSource, final Map<String,Object> params)
             throws ImageReadException, IOException {
-        FormatCompliance formatCompliance = FormatCompliance.getDefault();
-        TiffContents contents = new TiffReader(isStrict(params))
+        final FormatCompliance formatCompliance = FormatCompliance.getDefault();
+        final TiffContents contents = new TiffReader(isStrict(params))
                 .readDirectories(byteSource, true, formatCompliance);
 
-        List<byte[]> result = new ArrayList<byte[]>();
+        final List<byte[]> result = new ArrayList<byte[]>();
         for (int i = 0; i < contents.directories.size(); i++) {
-            TiffDirectory directory = contents.directories.get(i);
-            List<ImageDataElement> dataElements = directory
+            final TiffDirectory directory = contents.directories.get(i);
+            final List<ImageDataElement> dataElements = directory
                     .getTiffRawImageDataElements();
             for (int j = 0; j < dataElements.size(); j++) {
-                TiffDirectory.ImageDataElement element = dataElements.get(j);
-                byte bytes[] = byteSource.getBlock(element.offset,
+                final TiffDirectory.ImageDataElement element = dataElements.get(j);
+                final byte bytes[] = byteSource.getBlock(element.offset,
                         element.length);
                 result.add(bytes);
             }
@@ -436,15 +436,15 @@ public class TiffImageParser extends Ima
     }
 
     @Override
-    public BufferedImage getBufferedImage(ByteSource byteSource, Map<String,Object> params)
+    public BufferedImage getBufferedImage(final ByteSource byteSource, final Map<String,Object> params)
             throws ImageReadException, IOException {
-        FormatCompliance formatCompliance = FormatCompliance.getDefault();
-        TiffReader reader = new TiffReader(isStrict(params));
-        TiffContents contents = reader.readFirstDirectory(byteSource, params,
+        final FormatCompliance formatCompliance = FormatCompliance.getDefault();
+        final TiffReader reader = new TiffReader(isStrict(params));
+        final TiffContents contents = reader.readFirstDirectory(byteSource, params,
                 true, formatCompliance);
-        ByteOrder byteOrder = reader.getByteOrder();
-        TiffDirectory directory = contents.directories.get(0);
-        BufferedImage result = directory.getTiffImage(byteOrder, params);
+        final ByteOrder byteOrder = reader.getByteOrder();
+        final TiffDirectory directory = contents.directories.get(0);
+        final BufferedImage result = directory.getTiffImage(byteOrder, params);
         if (null == result) {
             throw new ImageReadException("TIFF does not contain an image.");
         }
@@ -452,16 +452,16 @@ public class TiffImageParser extends Ima
     }
 
     @Override
-    public List<BufferedImage> getAllBufferedImages(ByteSource byteSource)
+    public List<BufferedImage> getAllBufferedImages(final ByteSource byteSource)
             throws ImageReadException, IOException {
-        FormatCompliance formatCompliance = FormatCompliance.getDefault();
-        TiffReader tiffReader = new TiffReader(true);
-        TiffContents contents = tiffReader.readDirectories(byteSource, true,
+        final FormatCompliance formatCompliance = FormatCompliance.getDefault();
+        final TiffReader tiffReader = new TiffReader(true);
+        final TiffContents contents = tiffReader.readDirectories(byteSource, true,
                 formatCompliance);
-        List<BufferedImage> results = new ArrayList<BufferedImage>();
+        final List<BufferedImage> results = new ArrayList<BufferedImage>();
         for (int i = 0; i < contents.directories.size(); i++) {
-            TiffDirectory directory = contents.directories.get(i);
-            BufferedImage result = directory.getTiffImage(
+            final TiffDirectory directory = contents.directories.get(i);
+            final BufferedImage result = directory.getTiffImage(
                     tiffReader.getByteOrder(), null);
             if (result != null) {
                 results.add(result);
@@ -470,31 +470,31 @@ public class TiffImageParser extends Ima
         return results;
     }
 
-    protected BufferedImage getBufferedImage(TiffDirectory directory,
-            ByteOrder byteOrder, Map<String,Object> params) throws ImageReadException, IOException {
-        List<TiffField> entries = directory.entries;
+    protected BufferedImage getBufferedImage(final TiffDirectory directory,
+            final ByteOrder byteOrder, final Map<String,Object> params) throws ImageReadException, IOException {
+        final List<TiffField> entries = directory.entries;
 
         if (entries == null) {
             throw new ImageReadException("TIFF missing entries");
         }
 
-        int photometricInterpretation = 0xffff & directory
+        final int photometricInterpretation = 0xffff & directory
                 .getSingleFieldValue(TiffTagConstants.TIFF_TAG_PHOTOMETRIC_INTERPRETATION);
-        int compression = 0xffff & directory
+        final int compression = 0xffff & directory
                 .getSingleFieldValue(TiffTagConstants.TIFF_TAG_COMPRESSION);
-        int width = directory.findField(TiffTagConstants.TIFF_TAG_IMAGE_WIDTH,
+        final int width = directory.findField(TiffTagConstants.TIFF_TAG_IMAGE_WIDTH,
                 true).getIntValue();
-        int height = directory.findField(
+        final int height = directory.findField(
                 TiffTagConstants.TIFF_TAG_IMAGE_LENGTH, true).getIntValue();
         int samplesPerPixel = 1;
-        TiffField samplesPerPixelField = directory
+        final TiffField samplesPerPixelField = directory
                 .findField(TiffTagConstants.TIFF_TAG_SAMPLES_PER_PIXEL);
         if (samplesPerPixelField != null) {
             samplesPerPixel = samplesPerPixelField.getIntValue();
         }
         int bitsPerSample[] = { 1 };
         int bitsPerPixel = samplesPerPixel;
-        TiffField bitsPerSampleField = directory
+        final TiffField bitsPerSampleField = directory
                 .findField(TiffTagConstants.TIFF_TAG_BITS_PER_SAMPLE);
         if (bitsPerSampleField != null) {
             bitsPerSample = bitsPerSampleField.getIntArrayValue();
@@ -511,7 +511,7 @@ public class TiffImageParser extends Ima
             // dumpOptionalNumberTag(entries, TIFF_TAG_FREE_OFFSETS);
             // dumpOptionalNumberTag(entries, TIFF_TAG_ORIENTATION);
             // dumpOptionalNumberTag(entries, TIFF_TAG_PLANAR_CONFIGURATION);
-            TiffField predictorField = directory
+            final TiffField predictorField = directory
                     .findField(TiffTagConstants.TIFF_TAG_PREDICTOR);
             if (null != predictorField) {
                 predictor = predictorField.getIntValueOrArraySum();
@@ -524,16 +524,16 @@ public class TiffImageParser extends Ima
                     + bitsPerSample.length + ")");
         }
 
-        boolean hasAlpha = false;
-        ImageBuilder imageBuilder = new ImageBuilder(width, height, hasAlpha);
+        final boolean hasAlpha = false;
+        final ImageBuilder imageBuilder = new ImageBuilder(width, height, hasAlpha);
 
-        PhotometricInterpreter photometricInterpreter = getPhotometricInterpreter(
+        final PhotometricInterpreter photometricInterpreter = getPhotometricInterpreter(
                 directory, photometricInterpretation, bitsPerPixel,
                 bitsPerSample, predictor, samplesPerPixel, width, height);
 
-        TiffImageData imageData = directory.getTiffImageData();
+        final TiffImageData imageData = directory.getTiffImageData();
 
-        DataReader dataReader = imageData.getDataReader(directory,
+        final DataReader dataReader = imageData.getDataReader(directory,
                 photometricInterpreter, bitsPerPixel, bitsPerSample, predictor,
                 samplesPerPixel, width, height, compression, byteOrder);
 
@@ -545,25 +545,25 @@ public class TiffImageParser extends Ima
     }
 
     private PhotometricInterpreter getPhotometricInterpreter(
-            TiffDirectory directory, int photometricInterpretation,
-            int bitsPerPixel, int bitsPerSample[], int predictor,
-            int samplesPerPixel, int width, int height)
+            final TiffDirectory directory, final int photometricInterpretation,
+            final int bitsPerPixel, final int bitsPerSample[], final int predictor,
+            final int samplesPerPixel, final int width, final int height)
             throws ImageReadException {
         switch (photometricInterpretation) {
         case 0:
         case 1:
-            boolean invert = photometricInterpretation == 0;
+            final boolean invert = photometricInterpretation == 0;
 
             return new PhotometricInterpreterBiLevel(bitsPerPixel,
                     samplesPerPixel, bitsPerSample, predictor, width, height,
                     invert);
         case 3: // Palette
         {
-            int colorMap[] = directory.findField(
+            final int colorMap[] = directory.findField(
                     TiffTagConstants.TIFF_TAG_COLOR_MAP, true)
                     .getIntArrayValue();
 
-            int expected_colormap_size = 3 * (1 << bitsPerPixel);
+            final int expected_colormap_size = 3 * (1 << bitsPerPixel);
 
             if (colorMap.length != expected_colormap_size) {
                 throw new ImageReadException("Tiff: fColorMap.length ("
@@ -582,18 +582,18 @@ public class TiffImageParser extends Ima
                     bitsPerSample, predictor, width, height);
         case 6: //
         {
-            double yCbCrCoefficients[] = directory.findField(
+            final double yCbCrCoefficients[] = directory.findField(
                     TiffTagConstants.TIFF_TAG_YCBCR_COEFFICIENTS, true)
                     .getDoubleArrayValue();
 
-            int yCbCrPositioning[] = directory.findField(
+            final int yCbCrPositioning[] = directory.findField(
                     TiffTagConstants.TIFF_TAG_YCBCR_POSITIONING, true)
                     .getIntArrayValue();
-            int yCbCrSubSampling[] = directory.findField(
+            final int yCbCrSubSampling[] = directory.findField(
                     TiffTagConstants.TIFF_TAG_YCBCR_SUB_SAMPLING, true)
                     .getIntArrayValue();
 
-            double referenceBlackWhite[] = directory.findField(
+            final double referenceBlackWhite[] = directory.findField(
                     TiffTagConstants.TIFF_TAG_REFERENCE_BLACK_WHITE, true)
                     .getDoubleArrayValue();
 
@@ -608,7 +608,7 @@ public class TiffImageParser extends Ima
 
         case 32844:
         case 32845: {
-            boolean yonly = (photometricInterpretation == 32844);
+            final boolean yonly = (photometricInterpretation == 32844);
             return new PhotometricInterpreterLogLuv(samplesPerPixel,
                     bitsPerSample, predictor, width, height, yonly);
         }
@@ -621,7 +621,7 @@ public class TiffImageParser extends Ima
     }
 
     @Override
-    public void writeImage(BufferedImage src, OutputStream os, Map<String,Object> params)
+    public void writeImage(final BufferedImage src, final OutputStream os, final Map<String,Object> params)
             throws ImageWriteException, IOException {
         new TiffImageWriterLossy().writeImage(src, os, params);
     }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffReader.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffReader.java?rev=1417043&r1=1417042&r2=1417043&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffReader.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffReader.java Tue Dec  4 17:23:16 2012
@@ -40,12 +40,12 @@ public class TiffReader extends BinaryFi
 
     private final boolean strict;
 
-    public TiffReader(boolean strict) {
+    public TiffReader(final boolean strict) {
         this.strict = strict;
     }
 
-    private TiffHeader readTiffHeader(ByteSource byteSource,
-            FormatCompliance formatCompliance) throws ImageReadException,
+    private TiffHeader readTiffHeader(final ByteSource byteSource,
+            final FormatCompliance formatCompliance) throws ImageReadException,
             IOException {
         InputStream is = null;
         try {
@@ -56,13 +56,13 @@ public class TiffReader extends BinaryFi
                 if (is != null) {
                     is.close();
                 }
-            } catch (Exception e) {
+            } catch (final Exception e) {
                 Debug.debug(e);
             }
         }
     }
     
-    private ByteOrder getTiffByteOrder(int byteOrderByte) throws ImageReadException {
+    private ByteOrder getTiffByteOrder(final int byteOrderByte) throws ImageReadException {
         if (byteOrderByte == 'I') {
             return ByteOrder.INTEL;
         } else if (byteOrderByte == 'M') {
@@ -72,24 +72,24 @@ public class TiffReader extends BinaryFi
         }
     }
 
-    private TiffHeader readTiffHeader(InputStream is,
-            FormatCompliance formatCompliance) throws ImageReadException,
+    private TiffHeader readTiffHeader(final InputStream is,
+            final FormatCompliance formatCompliance) throws ImageReadException,
             IOException {
-        int BYTE_ORDER_1 = readByte("BYTE_ORDER_1", is, "Not a Valid TIFF File");
-        int BYTE_ORDER_2 = readByte("BYTE_ORDER_2", is, "Not a Valid TIFF File");
+        final int BYTE_ORDER_1 = readByte("BYTE_ORDER_1", is, "Not a Valid TIFF File");
+        final int BYTE_ORDER_2 = readByte("BYTE_ORDER_2", is, "Not a Valid TIFF File");
         if (BYTE_ORDER_1 != BYTE_ORDER_2) {
             throw new ImageReadException("Byte Order bytes don't match (" + BYTE_ORDER_1
                     + ", " + BYTE_ORDER_2 + ").");
         }
-        ByteOrder byteOrder = getTiffByteOrder(BYTE_ORDER_1);
+        final ByteOrder byteOrder = getTiffByteOrder(BYTE_ORDER_1);
         setByteOrder(byteOrder);
 
-        int tiffVersion = read2Bytes("tiffVersion", is, "Not a Valid TIFF File");
+        final int tiffVersion = read2Bytes("tiffVersion", is, "Not a Valid TIFF File");
         if (tiffVersion != 42) {
             throw new ImageReadException("Unknown Tiff Version: " + tiffVersion);
         }
 
-        int offsetToFirstIFD = read4Bytes("offsetToFirstIFD", is,
+        final int offsetToFirstIFD = read4Bytes("offsetToFirstIFD", is,
                 "Not a Valid TIFF File");
 
         skipBytes(is, offsetToFirstIFD - 8,
@@ -102,33 +102,33 @@ public class TiffReader extends BinaryFi
         return new TiffHeader(byteOrder, tiffVersion, offsetToFirstIFD);
     }
 
-    private void readDirectories(ByteSource byteSource,
-            FormatCompliance formatCompliance, Listener listener)
+    private void readDirectories(final ByteSource byteSource,
+            final FormatCompliance formatCompliance, final Listener listener)
             throws ImageReadException, IOException {
-        TiffHeader tiffHeader = readTiffHeader(byteSource, formatCompliance);
+        final TiffHeader tiffHeader = readTiffHeader(byteSource, formatCompliance);
         if (!listener.setTiffHeader(tiffHeader)) {
             return;
         }
 
-        int offset = tiffHeader.offsetToFirstIFD;
-        int dirType = TiffDirectory.DIRECTORY_TYPE_ROOT;
+        final int offset = tiffHeader.offsetToFirstIFD;
+        final int dirType = TiffDirectory.DIRECTORY_TYPE_ROOT;
 
-        List<Number> visited = new ArrayList<Number>();
+        final List<Number> visited = new ArrayList<Number>();
         readDirectory(byteSource, offset, dirType, formatCompliance, listener,
                 visited);
     }
 
-    private boolean readDirectory(ByteSource byteSource, int offset,
-            int dirType, FormatCompliance formatCompliance, Listener listener,
-            List<Number> visited) throws ImageReadException, IOException {
-        boolean ignoreNextDirectory = false;
+    private boolean readDirectory(final ByteSource byteSource, final int offset,
+            final int dirType, final FormatCompliance formatCompliance, final Listener listener,
+            final List<Number> visited) throws ImageReadException, IOException {
+        final boolean ignoreNextDirectory = false;
         return readDirectory(byteSource, offset, dirType, formatCompliance,
                 listener, ignoreNextDirectory, visited);
     }
 
-    private boolean readDirectory(ByteSource byteSource, int offset,
-            int dirType, FormatCompliance formatCompliance, Listener listener,
-            boolean ignoreNextDirectory, List<Number> visited)
+    private boolean readDirectory(final ByteSource byteSource, final int offset,
+            final int dirType, final FormatCompliance formatCompliance, final Listener listener,
+            final boolean ignoreNextDirectory, final List<Number> visited)
             throws ImageReadException, IOException {
 
         // Debug.debug();
@@ -155,13 +155,13 @@ public class TiffReader extends BinaryFi
             is = byteSource.getInputStream();
             skipBytes(is, offset);
 
-            List<TiffField> fields = new ArrayList<TiffField>();
+            final List<TiffField> fields = new ArrayList<TiffField>();
 
             int entryCount;
             try {
                 entryCount = read2Bytes("DirectoryEntryCount", is,
                         "Not a Valid TIFF File");
-            } catch (IOException e) {
+            } catch (final IOException e) {
                 if (strict) {
                     throw e;
                 } else {
@@ -172,16 +172,16 @@ public class TiffReader extends BinaryFi
             // Debug.debug("entryCount", entryCount);
 
             for (int i = 0; i < entryCount; i++) {
-                int tag = read2Bytes("Tag", is, "Not a Valid TIFF File");
-                int type = read2Bytes("Type", is, "Not a Valid TIFF File");
-                int length = read4Bytes("Length", is, "Not a Valid TIFF File");
+                final int tag = read2Bytes("Tag", is, "Not a Valid TIFF File");
+                final int type = read2Bytes("Type", is, "Not a Valid TIFF File");
+                final int length = read4Bytes("Length", is, "Not a Valid TIFF File");
 
                 // Debug.debug("tag*", tag + " (0x" + Integer.toHexString(tag)
                 // + ")");
 
-                byte valueOffsetBytes[] = readByteArray("ValueOffset", 4, is,
+                final byte valueOffsetBytes[] = readByteArray("ValueOffset", 4, is,
                         "Not a Valid TIFF File");
-                int valueOffset = convertByteArrayToInt("ValueOffset",
+                final int valueOffset = convertByteArrayToInt("ValueOffset",
                         valueOffsetBytes);
 
                 if (tag == 0) {
@@ -194,7 +194,7 @@ public class TiffReader extends BinaryFi
 
                 // if (keepField(tag, tags))
                 // {
-                TiffField field = new TiffField(tag, dirType, type, length,
+                final TiffField field = new TiffField(tag, dirType, type, length,
                         valueOffset, valueOffsetBytes, getByteOrder());
                 field.setSortHint(i);
 
@@ -202,9 +202,9 @@ public class TiffReader extends BinaryFi
 
                 try {
                     field.fillInValue(byteSource);
-                } catch (TiffValueOutsideFileBoundsException valueOutsideFileException) {
+                } catch (final TiffValueOutsideFileBoundsException valueOutsideFileException) {
                     if (strict) {
-                        IOException ioEx = new IOException();
+                        final IOException ioEx = new IOException();
                         ioEx.initCause(valueOutsideFileException);
                         throw ioEx;
                     } else {
@@ -222,21 +222,21 @@ public class TiffReader extends BinaryFi
                 }
             }
 
-            int nextDirectoryOffset = read4Bytes("nextDirectoryOffset", is,
+            final int nextDirectoryOffset = read4Bytes("nextDirectoryOffset", is,
                     "Not a Valid TIFF File");
             // Debug.debug("nextDirectoryOffset", nextDirectoryOffset);
 
-            TiffDirectory directory = new TiffDirectory(dirType, fields,
+            final TiffDirectory directory = new TiffDirectory(dirType, fields,
                     offset, nextDirectoryOffset);
 
             if (listener.readImageData()) {
                 if (directory.hasTiffImageData()) {
-                    TiffImageData rawImageData = getTiffRawImageData(
+                    final TiffImageData rawImageData = getTiffRawImageData(
                             byteSource, directory);
                     directory.setTiffImageData(rawImageData);
                 }
                 if (directory.hasJpegImageData()) {
-                    JpegImageData rawJpegImageData = getJpegRawImageData(
+                    final JpegImageData rawJpegImageData = getJpegRawImageData(
                             byteSource, directory);
                     directory.setJpegImageData(rawJpegImageData);
                 }
@@ -258,7 +258,7 @@ public class TiffReader extends BinaryFi
                         TiffDirectory.DIRECTORY_TYPE_INTEROPERABILITY
                 };
                 for (int i = 0; i < offsetFields.length; i++) {
-                    TagInfoLong offsetField = offsetFields[i];
+                    final TagInfoLong offsetField = offsetFields[i];
                     if (directory.findField(offsetField) != null) {
                         int subDirectoryOffset;
                         int subDirectoryType;
@@ -270,7 +270,7 @@ public class TiffReader extends BinaryFi
                                     subDirectoryOffset, subDirectoryType,
                                     formatCompliance, listener, true, visited);
     
-                        } catch (ImageReadException imageReadException) {
+                        } catch (final ImageReadException imageReadException) {
                             if (strict) {
                                 throw imageReadException;
                             }
@@ -294,7 +294,7 @@ public class TiffReader extends BinaryFi
                 if (is != null) {
                     is.close();
                 }
-            } catch (Exception e) {
+            } catch (final Exception e) {
                 Debug.debug(e);
             }
         }
@@ -322,7 +322,7 @@ public class TiffReader extends BinaryFi
             this(null);
         }
 
-        public Collector(Map<String,Object> params) {
+        public Collector(final Map<String,Object> params) {
             boolean readThumbnails = true;
             if (params != null && params.containsKey(PARAM_KEY_READ_THUMBNAILS)) {
                 readThumbnails = Boolean.TRUE.equals(params
@@ -331,17 +331,17 @@ public class TiffReader extends BinaryFi
             this.readThumbnails = readThumbnails;
         }
 
-        public boolean setTiffHeader(TiffHeader tiffHeader) {
+        public boolean setTiffHeader(final TiffHeader tiffHeader) {
             this.tiffHeader = tiffHeader;
             return true;
         }
 
-        public boolean addDirectory(TiffDirectory directory) {
+        public boolean addDirectory(final TiffDirectory directory) {
             directories.add(directory);
             return true;
         }
 
-        public boolean addField(TiffField field) {
+        public boolean addField(final TiffField field) {
             fields.add(field);
             return true;
         }
@@ -367,7 +367,7 @@ public class TiffReader extends BinaryFi
         }
 
         @Override
-        public boolean addDirectory(TiffDirectory directory) {
+        public boolean addDirectory(final TiffDirectory directory) {
             super.addDirectory(directory);
             return false;
         }
@@ -386,7 +386,7 @@ public class TiffReader extends BinaryFi
         }
 
         @Override
-        public boolean addDirectory(TiffDirectory directory) {
+        public boolean addDirectory(final TiffDirectory directory) {
             super.addDirectory(directory);
             return false;
         }
@@ -397,12 +397,12 @@ public class TiffReader extends BinaryFi
         }
     }
 
-    public TiffContents readFirstDirectory(ByteSource byteSource, Map<String,Object> params,
-            boolean readImageData, FormatCompliance formatCompliance)
+    public TiffContents readFirstDirectory(final ByteSource byteSource, final Map<String,Object> params,
+            final boolean readImageData, final FormatCompliance formatCompliance)
             throws ImageReadException, IOException {
-        Collector collector = new FirstDirectoryCollector(readImageData);
+        final Collector collector = new FirstDirectoryCollector(readImageData);
         read(byteSource, params, formatCompliance, collector);
-        TiffContents contents = collector.getContents();
+        final TiffContents contents = collector.getContents();
         if (contents.directories.size() < 1) {
             throw new ImageReadException(
                     "Image did not contain any directories.");
@@ -410,12 +410,12 @@ public class TiffReader extends BinaryFi
         return contents;
     }
 
-    public TiffContents readDirectories(ByteSource byteSource,
-            boolean readImageData, FormatCompliance formatCompliance)
+    public TiffContents readDirectories(final ByteSource byteSource,
+            final boolean readImageData, final FormatCompliance formatCompliance)
             throws ImageReadException, IOException {
-        Collector collector = new Collector(null);
+        final Collector collector = new Collector(null);
         readDirectories(byteSource, formatCompliance, collector);
-        TiffContents contents = collector.getContents();
+        final TiffContents contents = collector.getContents();
         if (contents.directories.size() < 1) {
             throw new ImageReadException(
                     "Image did not contain any directories.");
@@ -423,41 +423,41 @@ public class TiffReader extends BinaryFi
         return contents;
     }
 
-    public TiffContents readContents(ByteSource byteSource, Map<String,Object> params,
-            FormatCompliance formatCompliance) throws ImageReadException,
+    public TiffContents readContents(final ByteSource byteSource, final Map<String,Object> params,
+            final FormatCompliance formatCompliance) throws ImageReadException,
             IOException {
 
-        Collector collector = new Collector(params);
+        final Collector collector = new Collector(params);
         read(byteSource, params, formatCompliance, collector);
-        TiffContents contents = collector.getContents();
+        final TiffContents contents = collector.getContents();
         return contents;
     }
 
-    public void read(ByteSource byteSource, Map<String,Object> params,
-            FormatCompliance formatCompliance, Listener listener)
+    public void read(final ByteSource byteSource, final Map<String,Object> params,
+            final FormatCompliance formatCompliance, final Listener listener)
             throws ImageReadException, IOException {
         // TiffContents contents =
         readDirectories(byteSource, formatCompliance, listener);
     }
 
-    private TiffImageData getTiffRawImageData(ByteSource byteSource,
-            TiffDirectory directory) throws ImageReadException, IOException {
+    private TiffImageData getTiffRawImageData(final ByteSource byteSource,
+            final TiffDirectory directory) throws ImageReadException, IOException {
 
-        List<ImageDataElement> elements = directory
+        final List<ImageDataElement> elements = directory
                 .getTiffRawImageDataElements();
-        TiffImageData.Data data[] = new TiffImageData.Data[elements.size()];
+        final TiffImageData.Data data[] = new TiffImageData.Data[elements.size()];
 
         if (byteSource instanceof ByteSourceFile) {
-            ByteSourceFile bsf = (ByteSourceFile) byteSource;
+            final ByteSourceFile bsf = (ByteSourceFile) byteSource;
             for (int i = 0; i < elements.size(); i++) {
-                TiffDirectory.ImageDataElement element = elements.get(i);
+                final TiffDirectory.ImageDataElement element = elements.get(i);
                 data[i] = new TiffImageData.ByteSourceData(element.offset,
                         element.length, bsf);
             }
         } else {
             for (int i = 0; i < elements.size(); i++) {
-                TiffDirectory.ImageDataElement element = elements.get(i);
-                byte bytes[] = byteSource.getBlock(element.offset,
+                final TiffDirectory.ImageDataElement element = elements.get(i);
+                final byte bytes[] = byteSource.getBlock(element.offset,
                         element.length);
                 data[i] = new TiffImageData.Data(element.offset,
                         element.length, bytes);
@@ -465,14 +465,14 @@ public class TiffReader extends BinaryFi
         }
 
         if (directory.imageDataInStrips()) {
-            TiffField rowsPerStripField = directory
+            final TiffField rowsPerStripField = directory
                     .findField(TiffTagConstants.TIFF_TAG_ROWS_PER_STRIP);
             int rowsPerStrip;
 
             if (null != rowsPerStripField) {
                 rowsPerStrip = rowsPerStripField.getIntValue();
             } else {
-                TiffField imageHeight = directory
+                final TiffField imageHeight = directory
                         .findField(TiffTagConstants.TIFF_TAG_IMAGE_LENGTH);
                 /**
                  * if rows per strip not present then rowsPerStrip is equal to
@@ -483,34 +483,34 @@ public class TiffReader extends BinaryFi
 
             return new TiffImageData.Strips(data, rowsPerStrip);
         } else {
-            TiffField tileWidthField = directory
+            final TiffField tileWidthField = directory
                     .findField(TiffTagConstants.TIFF_TAG_TILE_WIDTH);
             if (null == tileWidthField) {
                 throw new ImageReadException("Can't find tile width field.");
             }
-            int tileWidth = tileWidthField.getIntValue();
+            final int tileWidth = tileWidthField.getIntValue();
 
-            TiffField tileLengthField = directory
+            final TiffField tileLengthField = directory
                     .findField(TiffTagConstants.TIFF_TAG_TILE_LENGTH);
             if (null == tileLengthField) {
                 throw new ImageReadException("Can't find tile length field.");
             }
-            int tileLength = tileLengthField.getIntValue();
+            final int tileLength = tileLengthField.getIntValue();
 
             return new TiffImageData.Tiles(data, tileWidth, tileLength);
         }
     }
 
-    private JpegImageData getJpegRawImageData(ByteSource byteSource,
-            TiffDirectory directory) throws ImageReadException, IOException {
-        ImageDataElement element = directory.getJpegRawImageDataElement();
-        int offset = element.offset;
+    private JpegImageData getJpegRawImageData(final ByteSource byteSource,
+            final TiffDirectory directory) throws ImageReadException, IOException {
+        final ImageDataElement element = directory.getJpegRawImageDataElement();
+        final int offset = element.offset;
         int length = element.length;
         // In case the length is not correct, adjust it and check if the last read byte actually is the end of the image
         if (offset + length > byteSource.getLength()) {
             length = (int) byteSource.getLength() - offset;
         }
-        byte data[] = byteSource.getBlock(offset, length);
+        final byte data[] = byteSource.getBlock(offset, length);
         // check if the last read byte is actually the end of the image data
         if (length < 2 ||
                 (((data[data.length - 2] & 0xff) << 8) | (data[data.length - 1] & 0xff)) != JpegConstants.EOIMarker) {

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffValueOutsideFileBoundsException.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffValueOutsideFileBoundsException.java?rev=1417043&r1=1417042&r2=1417043&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffValueOutsideFileBoundsException.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffValueOutsideFileBoundsException.java Tue Dec  4 17:23:16 2012
@@ -19,7 +19,7 @@ package org.apache.commons.imaging.forma
 public class TiffValueOutsideFileBoundsException extends Exception {
     private static final long serialVersionUID = 5674955248527127823L;
 
-    public TiffValueOutsideFileBoundsException(String message) {
+    public TiffValueOutsideFileBoundsException(final String message) {
         super(message);
     }
 }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/constants/TagConstantsUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/constants/TagConstantsUtils.java?rev=1417043&r1=1417042&r2=1417043&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/constants/TagConstantsUtils.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/constants/TagConstantsUtils.java Tue Dec  4 17:23:16 2012
@@ -26,15 +26,15 @@ public class TagConstantsUtils implement
     private static final TiffDirectoryType[] tiffDirectoryTypes = TiffDirectoryType
             .values();
 
-    public static List<TagInfo> mergeTagLists(List<?>... tagLists) {
+    public static List<TagInfo> mergeTagLists(final List<?>... tagLists) {
         int count = 0;
-        for (List<?> tagList : tagLists) {
+        for (final List<?> tagList : tagLists) {
             count += tagList.size();
         }
 
-        ArrayList<TagInfo> result = new ArrayList<TagInfo>(count);
+        final ArrayList<TagInfo> result = new ArrayList<TagInfo>(count);
 
-        for (List<?> tagList : tagLists) {
+        for (final List<?> tagList : tagLists) {
             for (int j = 0; j < tagList.size(); j++) {
                 result.add((TagInfo)tagList.get(j));
             }
@@ -43,9 +43,9 @@ public class TagConstantsUtils implement
         return result;
     }
 
-    public static TiffDirectoryType getExifDirectoryType(int type) {
+    public static TiffDirectoryType getExifDirectoryType(final int type) {
 
-        for (TiffDirectoryType tiffDirectoryType : tiffDirectoryTypes) {
+        for (final TiffDirectoryType tiffDirectoryType : tiffDirectoryTypes) {
             if (tiffDirectoryType.directoryType == type) {
                 return tiffDirectoryType;
             }
@@ -53,7 +53,7 @@ public class TagConstantsUtils implement
         return TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN;
     }
 
-    public static BinaryConstant createMicrosoftHdPhotoGuidEndingWith(byte end) {
+    public static BinaryConstant createMicrosoftHdPhotoGuidEndingWith(final byte end) {
         return new BinaryConstant(new byte[] { (byte) 0x24, (byte) 0xC3,
                 (byte) 0xDD, (byte) 0x6F, (byte) 0x03, (byte) 0x4E,
                 (byte) 0xFE, (byte) 0x4B, (byte) 0xB1, (byte) 0x85,

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReader.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReader.java?rev=1417043&r1=1417042&r2=1417043&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReader.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReader.java Tue Dec  4 17:23:16 2012
@@ -43,9 +43,9 @@ public abstract class DataReader impleme
     protected final int samplesPerPixel;
     protected final int width, height;
 
-    public DataReader(TiffDirectory directory,
-            PhotometricInterpreter photometricInterpreter, int bitsPerSample[],
-            int predictor, int samplesPerPixel, int width, int height) {
+    public DataReader(final TiffDirectory directory,
+            final PhotometricInterpreter photometricInterpreter, final int bitsPerSample[],
+            final int predictor, final int samplesPerPixel, final int width, final int height) {
         this.directory = directory;
         this.photometricInterpreter = photometricInterpreter;
         this.bitsPerSample = bitsPerSample;
@@ -71,13 +71,13 @@ public abstract class DataReader impleme
      *            bitsPerSample.length
      * @throws IOException
      */
-    protected void getSamplesAsBytes(BitInputStream bis, int[] result)
+    protected void getSamplesAsBytes(final BitInputStream bis, final int[] result)
             throws IOException {
         for (int i = 0; i < bitsPerSample.length; i++) {
-            int bits = bitsPerSample[i];
+            final int bits = bitsPerSample[i];
             int sample = bis.readBits(bits);
             if (bits < 8) {
-                int sign = sample & 1;
+                final int sign = sample & 1;
                 sample = sample << (8 - bits); // scale to byte.
                 if (sign > 0) {
                     sample = sample | ((1 << (8 - bits)) - 1); // extend to byte
@@ -95,7 +95,7 @@ public abstract class DataReader impleme
         }
     }
 
-    protected int[] applyPredictor(int samples[]) {
+    protected int[] applyPredictor(final int samples[]) {
         if (predictor == 2) {
             // Horizontal differencing.
             for (int i = 0; i < samples.length; i++) {
@@ -107,10 +107,10 @@ public abstract class DataReader impleme
         return samples;
     }
 
-    protected byte[] decompress(byte compressed[], int compression,
-            int expected_size, int tileWidth, int tileHeight)
+    protected byte[] decompress(final byte compressed[], final int compression,
+            final int expected_size, final int tileWidth, final int tileHeight)
             throws ImageReadException, IOException {
-        TiffField fillOrderField = directory
+        final TiffField fillOrderField = directory
                 .findField(TiffTagConstants.TIFF_TAG_FILL_ORDER);
         int fillOrder = TiffTagConstants.FILL_ORDER_VALUE_NORMAL;
         if (fillOrderField != null) {
@@ -136,18 +136,18 @@ public abstract class DataReader impleme
                     tileWidth, tileHeight);
         case TIFF_COMPRESSION_CCITT_GROUP_3: {
             int t4Options = 0;
-            TiffField field = directory
+            final TiffField field = directory
                     .findField(TiffTagConstants.TIFF_TAG_T4_OPTIONS);
             if (field != null) {
                 t4Options = field.getIntValue();
             }
-            boolean is2D = (t4Options & TIFF_FLAG_T4_OPTIONS_2D) != 0;
-            boolean usesUncompressedMode = (t4Options & TIFF_FLAG_T4_OPTIONS_UNCOMPRESSED_MODE) != 0;
+            final boolean is2D = (t4Options & TIFF_FLAG_T4_OPTIONS_2D) != 0;
+            final boolean usesUncompressedMode = (t4Options & TIFF_FLAG_T4_OPTIONS_UNCOMPRESSED_MODE) != 0;
             if (usesUncompressedMode) {
                 throw new ImageReadException(
                         "T.4 compression with the uncompressed mode extension is not yet supported");
             }
-            boolean hasFillBitsBeforeEOL = (t4Options & TIFF_FLAG_T4_OPTIONS_FILL) != 0;
+            final boolean hasFillBitsBeforeEOL = (t4Options & TIFF_FLAG_T4_OPTIONS_FILL) != 0;
             if (is2D) {
                 return T4AndT6Compression.decompressT4_2D(compressed,
                         tileWidth, tileHeight, hasFillBitsBeforeEOL);
@@ -158,12 +158,12 @@ public abstract class DataReader impleme
         }
         case TIFF_COMPRESSION_CCITT_GROUP_4: {
             int t6Options = 0;
-            TiffField field = directory
+            final TiffField field = directory
                     .findField(TiffTagConstants.TIFF_TAG_T6_OPTIONS);
             if (field != null) {
                 t6Options = field.getIntValue();
             }
-            boolean usesUncompressedMode = (t6Options & TIFF_FLAG_T6_OPTIONS_UNCOMPRESSED_MODE) != 0;
+            final boolean usesUncompressedMode = (t6Options & TIFF_FLAG_T6_OPTIONS_UNCOMPRESSED_MODE) != 0;
             if (usesUncompressedMode) {
                 throw new ImageReadException(
                         "T.6 compression with the uncompressed mode extension is not yet supported");
@@ -173,23 +173,23 @@ public abstract class DataReader impleme
         }
         case TIFF_COMPRESSION_LZW: // LZW
         {
-            InputStream is = new ByteArrayInputStream(compressed);
+            final InputStream is = new ByteArrayInputStream(compressed);
 
-            int LZWMinimumCodeSize = 8;
+            final int LZWMinimumCodeSize = 8;
 
-            MyLzwDecompressor myLzwDecompressor = new MyLzwDecompressor(
+            final MyLzwDecompressor myLzwDecompressor = new MyLzwDecompressor(
                     LZWMinimumCodeSize, ByteOrder.NETWORK);
 
             myLzwDecompressor.setTiffLZWMode();
 
-            byte[] result = myLzwDecompressor.decompress(is, expected_size);
+            final byte[] result = myLzwDecompressor.decompress(is, expected_size);
 
             return result;
         }
 
         case TIFF_COMPRESSION_PACKBITS: // Packbits
         {
-            byte unpacked[] = new PackBits().decompress(compressed,
+            final byte unpacked[] = new PackBits().decompress(compressed,
                     expected_size);
 
             return unpacked;



Mime
View raw message