Add a field to IptcRecord that contains its raw bytes,
and a getter for this value.
Jira issue key: SANSELAN-33
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/sanselan/trunk@1291967 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/main/java/org/apache/commons/sanselan/formats/jpeg/iptc/IptcParser.java b/src/main/java/org/apache/commons/sanselan/formats/jpeg/iptc/IptcParser.java
index e2dce53..ab84dd2 100644
--- a/src/main/java/org/apache/commons/sanselan/formats/jpeg/iptc/IptcParser.java
+++ b/src/main/java/org/apache/commons/sanselan/formats/jpeg/iptc/IptcParser.java
@@ -87,6 +87,7 @@
* 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 @@
// Debug.debug("index", IPTC_TYPE_CREDIT.name);
// }
- IptcRecord element = new IptcRecord(iptcType, value);
+ IptcRecord element = new IptcRecord(iptcType, recordData, value);
elements.add(element);
}
diff --git a/src/main/java/org/apache/commons/sanselan/formats/jpeg/iptc/IptcRecord.java b/src/main/java/org/apache/commons/sanselan/formats/jpeg/iptc/IptcRecord.java
index 8317332..fa233cf 100644
--- a/src/main/java/org/apache/commons/sanselan/formats/jpeg/iptc/IptcRecord.java
+++ b/src/main/java/org/apache/commons/sanselan/formats/jpeg/iptc/IptcRecord.java
@@ -16,6 +16,7 @@
*/
package org.apache.commons.sanselan.formats.jpeg.iptc;
+import java.io.UnsupportedEncodingException;
import java.util.Comparator;
/*
@@ -24,13 +25,32 @@
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()
{