commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dam...@apache.org
Subject svn commit: r1241131 [1/3] - in /commons/proper/sanselan/trunk/src: main/java/org/apache/commons/sanselan/formats/tiff/ main/java/org/apache/commons/sanselan/formats/tiff/constants/ main/java/org/apache/commons/sanselan/formats/tiff/write/ test/java/or...
Date Mon, 06 Feb 2012 19:55:31 GMT
Author: damjan
Date: Mon Feb  6 19:55:30 2012
New Revision: 1241131

URL: http://svn.apache.org/viewvc?rev=1241131&view=rev
Log:
Refactor ExifTagConstants into an enum,
uncomment some constants that appear accidentally commented,
protect public fields from changes,
and place constants inside their corresponding enum field.

Jira issue key: SANSELAN-42


Modified:
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/TiffField.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/TiffImageMetadata.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/TiffImageParser.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/TiffReader.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/constants/AllTagConstants.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/constants/ExifTagConstants.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/constants/GpsTagConstants.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/constants/TagConstantsUtils.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/constants/TiffTagConstants.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/write/TiffImageWriterBase.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/write/TiffImageWriterLossless.java
    commons/proper/sanselan/trunk/src/test/java/org/apache/commons/sanselan/examples/MetadataExample.java
    commons/proper/sanselan/trunk/src/test/java/org/apache/commons/sanselan/examples/WriteExifMetadataExample.java
    commons/proper/sanselan/trunk/src/test/java/org/apache/commons/sanselan/formats/jpeg/exif/AsciiFieldTest.java
    commons/proper/sanselan/trunk/src/test/java/org/apache/commons/sanselan/formats/jpeg/exif/ExifRewriteTest.java
    commons/proper/sanselan/trunk/src/test/java/org/apache/commons/sanselan/formats/jpeg/exif/MakerNoteFieldTest.java
    commons/proper/sanselan/trunk/src/test/java/org/apache/commons/sanselan/formats/jpeg/exif/TextFieldTest.java
    commons/proper/sanselan/trunk/src/test/java/org/apache/commons/sanselan/formats/jpeg/exif/WriteTagsTest.java

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/TiffField.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/TiffField.java?rev=1241131&r1=1241130&r2=1241131&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/TiffField.java
(original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/TiffField.java
Mon Feb  6 19:55:30 2012
@@ -28,6 +28,7 @@ import java.util.Map;
 
 import org.apache.commons.sanselan.ImageReadException;
 import org.apache.commons.sanselan.common.bytesource.ByteSource;
+import org.apache.commons.sanselan.formats.tiff.constants.ExifTagConstants;
 import org.apache.commons.sanselan.formats.tiff.constants.GpsTagConstants;
 import org.apache.commons.sanselan.formats.tiff.constants.TagInfo;
 import org.apache.commons.sanselan.formats.tiff.constants.TiffConstants;
@@ -577,15 +578,15 @@ public class TiffField implements TiffCo
         return (String) o;
     }
 
-    private static final Map<Object, List<TagInfo>> makeTagMap(TagInfo tags[],
+    private static final Map<Object, List<TagInfo>> makeTagMap(List<TagInfo>
tags,
                                                                boolean ignoreDuplicates,
String name)
     {
         // make sure to use the thread-safe version; this is shared state.
         Map<Object, List<TagInfo>> map = new Hashtable<Object, List<TagInfo>>();
 
-        for (int i = 0; i < tags.length; i++)
+        for (int i = 0; i < tags.size(); i++)
         {
-            TagInfo tag = tags[i];
+            TagInfo tag = tags.get(i);
             Object key = new Integer(tag.tag);
 
             List<TagInfo> tagList = map.get(key);
@@ -615,7 +616,7 @@ public class TiffField implements TiffCo
             "GPS");
     private static final Map<Object, List<TagInfo>> TIFF_TAG_MAP = makeTagMap(TiffTagConstants.ALL_TIFF_TAGS,
false,
             "TIFF");
-    private static final Map<Object, List<TagInfo>> EXIF_TAG_MAP = makeTagMap(ALL_EXIF_TAGS,
true,
+    private static final Map<Object, List<TagInfo>> EXIF_TAG_MAP = makeTagMap(ExifTagConstants.ALL_EXIF_TAGS,
true,
             "EXIF");
     private static final Map<Object, List<TagInfo>> ALL_TAG_MAP = makeTagMap(ALL_TAGS,
true, "All");
 

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=1241131&r1=1241130&r2=1241131&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
Mon Feb  6 19:55:30 2012
@@ -49,13 +49,13 @@ public class TiffImageMetadata extends I
         this.contents = contents;
     }
 
-    private static final Map<Object, Integer> countTags(TagInfo tags[])
+    private static final Map<Object, Integer> countTags(List<TagInfo> tags)
     {
         Map<Object, Integer> map = new Hashtable<Object, Integer>();
 
-        for (int i = 0; i < tags.length; i++)
+        for (int i = 0; i < tags.size(); i++)
         {
-            TagInfo tag = tags[i];
+            TagInfo tag = tags.get(i);
             Object key = new Integer(tag.tag);
 
             Integer count = map.get(key);

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=1241131&r1=1241130&r2=1241131&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
Mon Feb  6 19:55:30 2012
@@ -36,6 +36,7 @@ import org.apache.commons.sanselan.Image
 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.ExifTagConstants;
 import org.apache.commons.sanselan.formats.tiff.constants.TiffConstants;
 import org.apache.commons.sanselan.formats.tiff.constants.TiffTagConstants;
 import org.apache.commons.sanselan.formats.tiff.datareaders.DataReader;
@@ -89,7 +90,7 @@ public class TiffImageParser extends Ima
                 .readFirstDirectory(byteSource, params, false, formatCompliance);
         TiffDirectory directory = contents.directories.get(0);
 
-        TiffField field = directory.findField(EXIF_TAG_ICC_PROFILE);
+        TiffField field = directory.findField(ExifTagConstants.ICC_PROFILE.tagInfo);
         if (null == field)
             return null;
         return field.oversizeValue;

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=1241131&r1=1241130&r2=1241131&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
Mon Feb  6 19:55:30 2012
@@ -27,6 +27,7 @@ import org.apache.commons.sanselan.Image
 import org.apache.commons.sanselan.common.BinaryFileParser;
 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.ExifTagConstants;
 import org.apache.commons.sanselan.formats.tiff.constants.TiffConstants;
 import org.apache.commons.sanselan.formats.tiff.constants.TiffTagConstants;
 import org.apache.commons.sanselan.util.Debug;
@@ -248,9 +249,9 @@ public class TiffReader extends BinaryFi
                 {
                     TiffField entry = fields.get(j);
 
-                    if (entry.tag == TiffConstants.EXIF_TAG_EXIF_OFFSET.tag
-                            || entry.tag == TiffConstants.EXIF_TAG_GPSINFO.tag
-                            || entry.tag == TiffConstants.EXIF_TAG_INTEROP_OFFSET.tag)
+                    if (entry.tag == ExifTagConstants.EXIF_OFFSET.tagInfo.tag
+                            || entry.tag == ExifTagConstants.GPSINFO.tagInfo.tag
+                            || entry.tag == ExifTagConstants.INTEROP_OFFSET.tagInfo.tag)
                     { /* do nothing */ }
                     else
                         continue;
@@ -258,11 +259,11 @@ public class TiffReader extends BinaryFi
                     int subDirectoryOffset = ((Number) entry.getValue())
                             .intValue();
                     int subDirectoryType;
-                    if (entry.tag == TiffConstants.EXIF_TAG_EXIF_OFFSET.tag)
+                    if (entry.tag == ExifTagConstants.EXIF_OFFSET.tagInfo.tag)
                         subDirectoryType = TiffDirectory.DIRECTORY_TYPE_EXIF;
-                    else if (entry.tag == TiffConstants.EXIF_TAG_GPSINFO.tag)
+                    else if (entry.tag == ExifTagConstants.GPSINFO.tagInfo.tag)
                         subDirectoryType = TiffDirectory.DIRECTORY_TYPE_GPS;
-                    else if (entry.tag == TiffConstants.EXIF_TAG_INTEROP_OFFSET.tag)
+                    else if (entry.tag == ExifTagConstants.INTEROP_OFFSET.tagInfo.tag)
                         subDirectoryType = TiffDirectory.DIRECTORY_TYPE_INTEROPERABILITY;
                     else
                         throw new ImageReadException(

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/constants/AllTagConstants.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/constants/AllTagConstants.java?rev=1241131&r1=1241130&r2=1241131&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/constants/AllTagConstants.java
(original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/constants/AllTagConstants.java
Mon Feb  6 19:55:30 2012
@@ -16,15 +16,17 @@
  */
 package org.apache.commons.sanselan.formats.tiff.constants;
 
+import java.util.Collections;
+import java.util.List;
+
 import org.apache.commons.sanselan.SanselanConstants;
 
 public interface AllTagConstants
         extends
-            SanselanConstants,
-            ExifTagConstants
+            SanselanConstants
 {
-    public static final TagInfo ALL_TAGS[] = TagConstantsUtils.mergeTagLists(new TagInfo[][]{
-                TiffTagConstants.ALL_TIFF_TAGS, ALL_EXIF_TAGS, GpsTagConstants.ALL_GPS_TAGS,
-        });
+    public static final List<TagInfo> ALL_TAGS = Collections.unmodifiableList(
+            TagConstantsUtils.mergeTagLists(TiffTagConstants.values(),
+                    GpsTagConstants.values(), ExifTagConstants.values()));
 
 }
\ No newline at end of file



Mime
View raw message