commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dam...@apache.org
Subject svn commit: r1291967 - in /commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/iptc: IptcParser.java IptcRecord.java
Date Tue, 21 Feb 2012 19:47:07 GMT
Author: damjan
Date: Tue Feb 21 19:47:07 2012
New Revision: 1291967

URL: http://svn.apache.org/viewvc?rev=1291967&view=rev
Log:
Add a field to IptcRecord that contains its raw bytes,
and a getter for this value.

Jira issue key: SANSELAN-33


Modified:
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/iptc/IptcParser.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/iptc/IptcRecord.java

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/iptc/IptcParser.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/iptc/IptcParser.java?rev=1291967&r1=1291966&r2=1291967&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/iptc/IptcParser.java
(original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/iptc/IptcParser.java
Tue Feb 21 19:47:07 2012
@@ -87,6 +87,7 @@ public class IptcParser extends BinaryFi
      * Record data (unlike block data) is NOT padded to have an even length.
      *
      * Record data, for IPTC record, should always be ISO-8859-1.
+     * But according to SANSELAN-33, this isn't always the case.
      *
      * The exception is the first record in the block, which must always be a
      * record version record, whose value is a two-byte number; the value is
@@ -248,7 +249,7 @@ public class IptcParser extends BinaryFi
             // Debug.debug("index", IPTC_TYPE_CREDIT.name);
             // }
 
-            IptcRecord element = new IptcRecord(iptcType, value);
+            IptcRecord element = new IptcRecord(iptcType, recordData, value);
             elements.add(element);
         }
 

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/iptc/IptcRecord.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/iptc/IptcRecord.java?rev=1291967&r1=1291966&r2=1291967&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/iptc/IptcRecord.java
(original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/iptc/IptcRecord.java
Tue Feb 21 19:47:07 2012
@@ -16,6 +16,7 @@
  */
 package org.apache.commons.sanselan.formats.jpeg.iptc;
 
+import java.io.UnsupportedEncodingException;
 import java.util.Comparator;
 
 /*
@@ -24,13 +25,32 @@ import java.util.Comparator;
 public class IptcRecord
 {
     public final IptcType iptcType;
+    private final byte[] bytes;
     public final String value;
 
+    public IptcRecord(IptcType iptcType, byte[] bytes, String value)
+    {
+        this.iptcType = iptcType;
+        this.bytes = bytes;
+        this.value = value;
+    }
+    
     public IptcRecord(IptcType iptcType, String value)
     {
         this.iptcType = iptcType;
+        byte[] bytes;
+        try {
+            bytes = value.getBytes("ISO-8859-1");
+        } catch (UnsupportedEncodingException cannotHappen) {
+            bytes = null;
+        }
+        this.bytes = bytes;
         this.value = value;
     }
+    
+    public byte[] getRawBytes() {
+        return bytes.clone();
+    }
 
     public String getValue()
     {



Mime
View raw message