Return-Path: X-Original-To: apmail-commons-commits-archive@minotaur.apache.org Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id C76EF9DB2 for ; Sat, 4 Feb 2012 09:21:46 +0000 (UTC) Received: (qmail 42649 invoked by uid 500); 4 Feb 2012 09:21:42 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 42299 invoked by uid 500); 4 Feb 2012 09:21:27 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 42287 invoked by uid 99); 4 Feb 2012 09:21:24 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 04 Feb 2012 09:21:24 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 04 Feb 2012 09:21:21 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id DBDE423889B8 for ; Sat, 4 Feb 2012 09:21:01 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1240468 - in /commons/proper/sanselan/trunk/src: main/java/org/apache/commons/sanselan/common/itu_t4/ main/java/org/apache/commons/sanselan/formats/jpeg/ main/java/org/apache/commons/sanselan/formats/jpeg/iptc/ test/java/org/apache/commons... Date: Sat, 04 Feb 2012 09:21:01 -0000 To: commits@commons.apache.org From: damjan@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120204092101.DBDE423889B8@eris.apache.org> Author: damjan Date: Sat Feb 4 09:21:00 2012 New Revision: 1240468 URL: http://svn.apache.org/viewvc?rev=1240468&view=rev Log: API immutability changes and Java 1.5 updates. Deleted the unused legacy IptcConstants.IPTC_PREFIX array (= IPTC_RECORD_TAG_MARKER + IPTC_APPLICATION_2_RECORD_NUMBER). Converted IptcConstants.IPTC_TYPE_* to an enum. Made some collections and classes generic. Similar changes will be applied to the whole tree, I am just starting here. Added: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/iptc/IptcTypes.java (with props) Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/common/itu_t4/HuffmanTree.java commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/JpegPhotoshopMetadata.java commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/iptc/IptcConstants.java commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/iptc/IptcParser.java commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/iptc/IptcRecord.java commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/iptc/IptcType.java commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/iptc/IptcTypeLookup.java commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/iptc/JpegIptcRewriter.java commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/iptc/PhotoshopApp13Data.java commons/proper/sanselan/trunk/src/test/java/org/apache/commons/sanselan/formats/jpeg/iptc/IptcDumpTest.java commons/proper/sanselan/trunk/src/test/java/org/apache/commons/sanselan/formats/jpeg/iptc/IptcUpdateTest.java Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/common/itu_t4/HuffmanTree.java URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/common/itu_t4/HuffmanTree.java?rev=1240468&r1=1240467&r2=1240468&view=diff ============================================================================== --- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/common/itu_t4/HuffmanTree.java (original) +++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/common/itu_t4/HuffmanTree.java Sat Feb 4 09:21:00 2012 @@ -26,7 +26,7 @@ import org.apache.commons.sanselan.commo * A Huffman tree implemented as 1 array for high locality of reference. */ class HuffmanTree { - private static class Node { + private final static class Node { boolean isEmpty = true; Object value = null; } Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/JpegPhotoshopMetadata.java URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/JpegPhotoshopMetadata.java?rev=1240468&r1=1240467&r2=1240468&view=diff ============================================================================== --- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/JpegPhotoshopMetadata.java (original) +++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/JpegPhotoshopMetadata.java Sat Feb 4 09:21:00 2012 @@ -22,6 +22,7 @@ import java.util.List; import org.apache.commons.sanselan.common.ImageMetadata; import org.apache.commons.sanselan.formats.jpeg.iptc.IptcConstants; import org.apache.commons.sanselan.formats.jpeg.iptc.IptcRecord; +import org.apache.commons.sanselan.formats.jpeg.iptc.IptcTypes; import org.apache.commons.sanselan.formats.jpeg.iptc.PhotoshopApp13Data; import org.apache.commons.sanselan.util.Debug; @@ -35,12 +36,12 @@ public class JpegPhotoshopMetadata exten { this.photoshopApp13Data = photoshopApp13Data; - List records = photoshopApp13Data.getRecords(); + List records = photoshopApp13Data.getRecords(); Collections.sort(records, IptcRecord.COMPARATOR); for (int j = 0; j < records.size(); j++) { IptcRecord element = (IptcRecord) records.get(j); - if (element.iptcType.type != IPTC_TYPE_RECORD_VERSION.type) + if (element.iptcType != IptcTypes.RECORD_VERSION) add(element.getIptcTypeName(), element.getValue()); } } Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/iptc/IptcConstants.java URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/iptc/IptcConstants.java?rev=1240468&r1=1240467&r2=1240468&view=diff ============================================================================== --- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/iptc/IptcConstants.java (original) +++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/iptc/IptcConstants.java Sat Feb 4 09:21:00 2012 @@ -20,9 +20,6 @@ import org.apache.commons.sanselan.forma public interface IptcConstants extends JpegConstants { - - public static final byte IPTC_PREFIX[] = { 0x1C, 0x02, }; - public static final int IPTC_NON_EXTENDED_RECORD_MAXIMUM_SIZE = 32767; public static final int IMAGE_RESOURCE_BLOCK_PHOTOSHOP2_INFO = 0x03e8; @@ -90,153 +87,7 @@ public interface IptcConstants extends J public static final int IMAGE_RESOURCE_BLOCK_CLIPPING_PATH_NAME = 0x0bb7; public static final int IMAGE_RESOURCE_BLOCK_PRINT_FLAGS_INFO = 0x2710; - // public static final int IPTC_RECORD_PREFIX = 0x1c02; public static final int IPTC_RECORD_TAG_MARKER = 0x1c; public static final int IPTC_ENVELOPE_RECORD_NUMBER = 0x01; public static final int IPTC_APPLICATION_2_RECORD_NUMBER = 0x02; - - public static final IptcType IPTC_TYPE_RECORD_VERSION = new IptcType(0, - "Record Version"); - public static final IptcType IPTC_TYPE_OBJECT_TYPE_REFERENCE = new IptcType( - 3, "Object Type Reference"); - public static final IptcType IPTC_TYPE_OBJECT_ATTRIBUTE_REFERENCE = new IptcType( - 4, "Object Attribute Reference"); - public static final IptcType IPTC_TYPE_OBJECT_NAME = new IptcType(5, - "Object Name"); - public static final IptcType IPTC_TYPE_EDIT_STATUS = new IptcType(7, - "Edit Status"); - public static final IptcType IPTC_TYPE_EDITORIAL_UPDATE = new IptcType(8, - "Editorial Update"); - public static final IptcType IPTC_TYPE_URGENCY = new IptcType(10, "Urgency"); - public static final IptcType IPTC_TYPE_SUBJECT_REFERENCE = new IptcType(12, - "Subject Reference"); - public static final IptcType IPTC_TYPE_CATEGORY = new IptcType(15, - "Category"); - public static final IptcType IPTC_TYPE_SUPPLEMENTAL_CATEGORY = new IptcType( - 20, "Supplemental Category"); - public static final IptcType IPTC_TYPE_FIXTURE_IDENTIFIER = new IptcType( - 22, "Fixture Identifier"); - public static final IptcType IPTC_TYPE_KEYWORDS = new IptcType(25, - "Keywords"); - public static final IptcType IPTC_TYPE_CONTENT_LOCATION_CODE = new IptcType( - 26, "Content Location Code"); - public static final IptcType IPTC_TYPE_CONTENT_LOCATION_NAME = new IptcType( - 27, "Content Location Name"); - public static final IptcType IPTC_TYPE_RELEASE_DATE = new IptcType(30, - "Release Date"); - public static final IptcType IPTC_TYPE_RELEASE_TIME = new IptcType(35, - "Release Time"); - public static final IptcType IPTC_TYPE_EXPIRATION_DATE = new IptcType(37, - "Expiration Date"); - public static final IptcType IPTC_TYPE_EXPIRATION_TIME = new IptcType(38, - "Expiration Time"); - public static final IptcType IPTC_TYPE_SPECIAL_INSTRUCTIONS = new IptcType( - 40, "Special Instructions"); - public static final IptcType IPTC_TYPE_ACTION_ADVISED = new IptcType(42, - "Action Advised"); - public static final IptcType IPTC_TYPE_REFERENCE_SERVICE = new IptcType(45, - "Reference Service"); - public static final IptcType IPTC_TYPE_REFERENCE_DATE = new IptcType(47, - "Reference Date"); - public static final IptcType IPTC_TYPE_REFERENCE_NUMBER = new IptcType(50, - "Reference Number"); - public static final IptcType IPTC_TYPE_DATE_CREATED = new IptcType(55, - "Date Created"); - public static final IptcType IPTC_TYPE_TIME_CREATED = new IptcType(60, - "Time Created"); - public static final IptcType IPTC_TYPE_DIGITAL_CREATION_DATE = new IptcType( - 62, "Digital Creation Date"); - public static final IptcType IPTC_TYPE_DIGITAL_CREATION_TIME = new IptcType( - 63, "Digital Creation Time"); - public static final IptcType IPTC_TYPE_ORIGINATING_PROGRAM = new IptcType( - 65, "Originating Program"); - public static final IptcType IPTC_TYPE_PROGRAM_VERSION = new IptcType(70, - "Program Version"); - public static final IptcType IPTC_TYPE_OBJECT_CYCLE = new IptcType(75, - "Object Cycle"); - public static final IptcType IPTC_TYPE_BYLINE = new IptcType(80, "By-line"); - public static final IptcType IPTC_TYPE_BYLINE_TITLE = new IptcType(85, - "By-line Title"); - public static final IptcType IPTC_TYPE_CITY = new IptcType(90, "City"); - public static final IptcType IPTC_TYPE_SUBLOCATION = new IptcType(92, - "Sublocation"); - public static final IptcType IPTC_TYPE_PROVINCE_STATE = new IptcType(95, - "Province/State"); - public static final IptcType IPTC_TYPE_COUNTRY_PRIMARY_LOCATION_CODE = new IptcType( - 100, "Country/Primary Location Code"); - public static final IptcType IPTC_TYPE_COUNTRY_PRIMARY_LOCATION_NAME = new IptcType( - 101, "Country/Primary Location Name"); - public static final IptcType IPTC_TYPE_ORIGINAL_TRANSMISSION_REFERENCE = new IptcType( - 103, "Original Transmission, Reference"); - public static final IptcType IPTC_TYPE_HEADLINE = new IptcType(105, - "Headline"); - public static final IptcType IPTC_TYPE_CREDIT = new IptcType(110, "Credit"); - public static final IptcType IPTC_TYPE_SOURCE = new IptcType(115, "Source"); - public static final IptcType IPTC_TYPE_COPYRIGHT_NOTICE = new IptcType(116, - "Copyright Notice"); - public static final IptcType IPTC_TYPE_CONTACT = new IptcType(118, - "Contact"); - public static final IptcType IPTC_TYPE_CAPTION_ABSTRACT = new IptcType(120, - "Caption/Abstract"); - public static final IptcType IPTC_TYPE_WRITER_EDITOR = new IptcType(122, - "Writer/Editor"); - public static final IptcType IPTC_TYPE_RASTERIZED_CAPTION = new IptcType( - 125, "Rasterized Caption"); - public static final IptcType IPTC_TYPE_IMAGE_TYPE = new IptcType(130, - "ImageType"); - public static final IptcType IPTC_TYPE_IMAGE_ORIENTATION = new IptcType( - 131, "Image Orientation"); - public static final IptcType IPTC_TYPE_LANGUAGE_IDENTIFIER = new IptcType( - 135, "Language Identifier"); - public static final IptcType IPTC_TYPE_AUDIO_TYPE = new IptcType(150, - "Audio Type"); - public static final IptcType IPTC_TYPE_AUDIO_SAMPLING_RATE = new IptcType( - 151, "Audio Sampling Rate"); - public static final IptcType IPTC_TYPE_AUDIO_SAMPLING_RESOLUTION = new IptcType( - 152, "Audio Sampling Resolution"); - public static final IptcType IPTC_TYPE_AUDIO_DURATION = new IptcType(153, - "Audio Duration"); - public static final IptcType IPTC_TYPE_AUDIO_OUTCUE = new IptcType(154, - "Audio Outcue"); - public static final IptcType IPTC_TYPE_OBJECT_DATA_PREVIEW_FILE_FORMAT = new IptcType( - 200, "Object Data Preview, File Format"); - public static final IptcType IPTC_TYPE_OBJECT_DATA_PREVIEW_FILE_FORMAT_VERSION = new IptcType( - 201, "Object Data Preview, File Format Version"); - public static final IptcType IPTC_TYPE_OBJECT_DATA_PREVIEW_DATA = new IptcType( - 202, "Object Data Preview Data"); - // -- - // public static final IptcType IPTC_TYPE_UNKNOWN = new IptcType(-1, - // "Unknown"); - - public static final IptcType IPTC_TYPES[] = { IPTC_TYPE_RECORD_VERSION, - IPTC_TYPE_OBJECT_TYPE_REFERENCE, - IPTC_TYPE_OBJECT_ATTRIBUTE_REFERENCE, IPTC_TYPE_OBJECT_NAME, - IPTC_TYPE_EDIT_STATUS, IPTC_TYPE_EDITORIAL_UPDATE, - IPTC_TYPE_URGENCY, IPTC_TYPE_SUBJECT_REFERENCE, IPTC_TYPE_CATEGORY, - IPTC_TYPE_SUPPLEMENTAL_CATEGORY, IPTC_TYPE_FIXTURE_IDENTIFIER, - IPTC_TYPE_KEYWORDS, IPTC_TYPE_CONTENT_LOCATION_CODE, - IPTC_TYPE_CONTENT_LOCATION_NAME, IPTC_TYPE_RELEASE_DATE, - IPTC_TYPE_RELEASE_TIME, IPTC_TYPE_EXPIRATION_DATE, - IPTC_TYPE_EXPIRATION_TIME, IPTC_TYPE_SPECIAL_INSTRUCTIONS, - IPTC_TYPE_ACTION_ADVISED, IPTC_TYPE_REFERENCE_SERVICE, - IPTC_TYPE_REFERENCE_DATE, IPTC_TYPE_REFERENCE_NUMBER, - IPTC_TYPE_DATE_CREATED, IPTC_TYPE_TIME_CREATED, - IPTC_TYPE_DIGITAL_CREATION_DATE, IPTC_TYPE_DIGITAL_CREATION_TIME, - IPTC_TYPE_ORIGINATING_PROGRAM, IPTC_TYPE_PROGRAM_VERSION, - IPTC_TYPE_OBJECT_CYCLE, IPTC_TYPE_BYLINE, IPTC_TYPE_BYLINE_TITLE, - IPTC_TYPE_CITY, IPTC_TYPE_SUBLOCATION, IPTC_TYPE_PROVINCE_STATE, - IPTC_TYPE_COUNTRY_PRIMARY_LOCATION_CODE, - IPTC_TYPE_COUNTRY_PRIMARY_LOCATION_NAME, - IPTC_TYPE_ORIGINAL_TRANSMISSION_REFERENCE, IPTC_TYPE_HEADLINE, - IPTC_TYPE_CREDIT, IPTC_TYPE_SOURCE, IPTC_TYPE_COPYRIGHT_NOTICE, - IPTC_TYPE_CONTACT, IPTC_TYPE_CAPTION_ABSTRACT, - IPTC_TYPE_WRITER_EDITOR, IPTC_TYPE_RASTERIZED_CAPTION, - IPTC_TYPE_IMAGE_TYPE, IPTC_TYPE_IMAGE_ORIENTATION, - IPTC_TYPE_LANGUAGE_IDENTIFIER, IPTC_TYPE_AUDIO_TYPE, - IPTC_TYPE_AUDIO_SAMPLING_RATE, IPTC_TYPE_AUDIO_SAMPLING_RESOLUTION, - IPTC_TYPE_AUDIO_DURATION, IPTC_TYPE_AUDIO_OUTCUE, - IPTC_TYPE_OBJECT_DATA_PREVIEW_FILE_FORMAT, - IPTC_TYPE_OBJECT_DATA_PREVIEW_FILE_FORMAT_VERSION, - IPTC_TYPE_OBJECT_DATA_PREVIEW_DATA, }; - } 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=1240468&r1=1240467&r2=1240468&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 Sat Feb 4 09:21:00 2012 @@ -111,9 +111,9 @@ public class IptcParser extends BinaryFi boolean verbose, boolean strict) throws ImageReadException, IOException { - List records = new ArrayList(); + List records = new ArrayList(); - List allBlocks = parseAllBlocks(bytes, verbose, strict); + List allBlocks = parseAllBlocks(bytes, verbose, strict); for (int i = 0; i < allBlocks.size(); i++) { @@ -129,10 +129,10 @@ public class IptcParser extends BinaryFi return new PhotoshopApp13Data(records, allBlocks); } - protected List parseIPTCBlock(byte bytes[], boolean verbose) + protected List parseIPTCBlock(byte bytes[], boolean verbose) throws ImageReadException, IOException { - List elements = new ArrayList(); + List elements = new ArrayList(); int index = 0; // Integer recordVersion = null; @@ -256,10 +256,10 @@ public class IptcParser extends BinaryFi return elements; } - protected List parseAllBlocks(byte bytes[], boolean verbose, boolean strict) + protected List parseAllBlocks(byte bytes[], boolean verbose, boolean strict) throws ImageReadException, IOException { - List blocks = new ArrayList(); + List blocks = new ArrayList(); BinaryInputStream bis = new BinaryInputStream(bytes, APP13_BYTE_ORDER); @@ -353,7 +353,7 @@ public class IptcParser extends BinaryFi bos.write(PHOTOSHOP_IDENTIFICATION_STRING); - List blocks = data.getRawBlocks(); + List blocks = data.getRawBlocks(); for (int i = 0; i < blocks.size(); i++) { IptcBlock block = (IptcBlock) blocks.get(i); @@ -386,7 +386,7 @@ public class IptcParser extends BinaryFi return os.toByteArray(); } - public byte[] writeIPTCBlock(List elements) throws ImageWriteException, + public byte[] writeIPTCBlock(List elements) throws ImageWriteException, IOException { byte blockData[]; @@ -398,21 +398,19 @@ public class IptcParser extends BinaryFi // first, right record version record bos.write(IPTC_RECORD_TAG_MARKER); bos.write(IPTC_APPLICATION_2_RECORD_NUMBER); - bos.write(IPTC_TYPE_RECORD_VERSION.type); // record version record + bos.write(IptcTypes.RECORD_VERSION.type); // record version record // type. bos.write2Bytes(2); // record version record size bos.write2Bytes(2); // record version value // make a copy of the list. - elements = new ArrayList(elements); + elements = new ArrayList(elements); // sort the list. Records must be in numerical order. - Comparator comparator = new Comparator() { - public int compare(Object o1, Object o2) + Comparator comparator = new Comparator() { + public int compare(IptcRecord e1, IptcRecord e2) { - IptcRecord e1 = (IptcRecord) o1; - IptcRecord e2 = (IptcRecord) o2; - return e2.iptcType.type - e1.iptcType.type; + return e2.iptcType.getType() - e1.iptcType.getType(); } }; Collections.sort(elements, comparator); @@ -423,15 +421,15 @@ public class IptcParser extends BinaryFi { IptcRecord element = (IptcRecord) elements.get(i); - if (element.iptcType.type == IPTC_TYPE_RECORD_VERSION.type) + if (element.iptcType == IptcTypes.RECORD_VERSION) continue; // ignore bos.write(IPTC_RECORD_TAG_MARKER); bos.write(IPTC_APPLICATION_2_RECORD_NUMBER); - if (element.iptcType.type < 0 || element.iptcType.type > 0xff) + if (element.iptcType.getType() < 0 || element.iptcType.getType() > 0xff) throw new ImageWriteException("Invalid record type: " - + element.iptcType.type); - bos.write(element.iptcType.type); + + element.iptcType.getType()); + bos.write(element.iptcType.getType()); byte recordData[] = element.value.getBytes("ISO-8859-1"); if (!new String(recordData, "ISO-8859-1").equals(element.value)) 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=1240468&r1=1240467&r2=1240468&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 Sat Feb 4 09:21:00 2012 @@ -39,15 +39,13 @@ public class IptcRecord public String getIptcTypeName() { - return iptcType.name; + return iptcType.getName(); } - public static final Comparator COMPARATOR = new Comparator() { - public int compare(Object o1, Object o2) + public static final Comparator COMPARATOR = new Comparator() { + public int compare(IptcRecord e1, IptcRecord e2) { - IptcRecord e1 = (IptcRecord) o1; - IptcRecord e2 = (IptcRecord) o2; - return e1.iptcType.type - e2.iptcType.type; + return e1.iptcType.getType() - e2.iptcType.getType(); } }; Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/iptc/IptcType.java URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/iptc/IptcType.java?rev=1240468&r1=1240467&r2=1240468&view=diff ============================================================================== --- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/iptc/IptcType.java (original) +++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/iptc/IptcType.java Sat Feb 4 09:21:00 2012 @@ -16,27 +16,10 @@ */ package org.apache.commons.sanselan.formats.jpeg.iptc; -import org.apache.commons.sanselan.formats.jpeg.JpegConstants; -public class IptcType implements JpegConstants, IptcConstants +public interface IptcType { - public final int type; - public final String name; - - public IptcType(int type, String name) - { - this.type = type; - this.name = name; - } - - public String toString() - { - return name + " (" + type + ")"; - } - - public static IptcType getUnknown(int type) - { - return new IptcType(type, "Unknown"); - } - + public int getType(); + public String getName(); + public String toString(); } \ No newline at end of file Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/iptc/IptcTypeLookup.java URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/iptc/IptcTypeLookup.java?rev=1240468&r1=1240467&r2=1240468&view=diff ============================================================================== --- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/iptc/IptcTypeLookup.java (original) +++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/iptc/IptcTypeLookup.java Sat Feb 4 09:21:00 2012 @@ -25,19 +25,16 @@ public abstract class IptcTypeLookup imp private static final Map IPTC_TYPE_MAP = new HashMap(); static { - for (int i = 0; i < IPTC_TYPES.length; i++) + for (IptcType iptcType : IptcTypes.values()) { - IptcType iptcType = IPTC_TYPES[i]; - Integer key = new Integer(iptcType.type); - IPTC_TYPE_MAP.put(key, iptcType); + IPTC_TYPE_MAP.put(iptcType.getType(), iptcType); } } public static final IptcType getIptcType(int type) { - Integer key = new Integer(type); - if (!IPTC_TYPE_MAP.containsKey(key)) - return IptcType.getUnknown(type); - return IPTC_TYPE_MAP.get(key); + if (!IPTC_TYPE_MAP.containsKey(type)) + return IptcTypes.getUnknown(type); + return IPTC_TYPE_MAP.get(type); } } \ No newline at end of file Added: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/iptc/IptcTypes.java URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/iptc/IptcTypes.java?rev=1240468&view=auto ============================================================================== --- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/iptc/IptcTypes.java (added) +++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/iptc/IptcTypes.java Sat Feb 4 09:21:00 2012 @@ -0,0 +1,156 @@ +package org.apache.commons.sanselan.formats.jpeg.iptc; + +public enum IptcTypes implements IptcType { + RECORD_VERSION( + 0, "Record Version"), + OBJECT_TYPE_REFERENCE( + 3, "Object Type Reference"), + OBJECT_ATTRIBUTE_REFERENCE( + 4, "Object Attribute Reference"), + OBJECT_NAME( + 5, "Object Name"), + EDIT_STATUS( + 7, "Edit Status"), + EDITORIAL_UPDATE( + 8, "Editorial Update"), + URGENCY( + 10, "Urgency"), + SUBJECT_REFERENCE( + 12, "Subject Reference"), + CATEGORY( + 15, "Category"), + SUPPLEMENTAL_CATEGORY( + 20, "Supplemental Category"), + FIXTURE_IDENTIFIER( + 22, "Fixture Identifier"), + KEYWORDS( + 25, "Keywords"), + CONTENT_LOCATION_CODE( + 26, "Content Location Code"), + CONTENT_LOCATION_NAME( + 27, "Content Location Name"), + RELEASE_DATE( + 30, "Release Date"), + RELEASE_TIME( + 35, "Release Time"), + EXPIRATION_DATE( + 37, "Expiration Date"), + EXPIRATION_TIME( + 38, "Expiration Time"), + SPECIAL_INSTRUCTIONS( + 40, "Special Instructions"), + ACTION_ADVISED( + 42, "Action Advised"), + REFERENCE_SERVICE( + 45, "Reference Service"), + REFERENCE_DATE( + 47, "Reference Date"), + REFERENCE_NUMBER( + 50, "Reference Number"), + DATE_CREATED( + 55, "Date Created"), + TIME_CREATED( + 60, "Time Created"), + DIGITAL_CREATION_DATE( + 62, "Digital Creation Date"), + DIGITAL_CREATION_TIME( + 63, "Digital Creation Time"), + ORIGINATING_PROGRAM( + 65, "Originating Program"), + PROGRAM_VERSION( + 70, "Program Version"), + OBJECT_CYCLE( + 75, "Object Cycle"), + BYLINE( + 80, "By-line"), + BYLINE_TITLE( + 85, "By-line Title"), + CITY( + 90, "City"), + SUBLOCATION( + 92, "Sublocation"), + PROVINCE_STATE( + 95, "Province/State"), + COUNTRY_PRIMARY_LOCATION_CODE( + 100, "Country/Primary Location Code"), + COUNTRY_PRIMARY_LOCATION_NAME( + 101, "Country/Primary Location Name"), + ORIGINAL_TRANSMISSION_REFERENCE( + 103, "Original Transmission, Reference"), + HEADLINE( + 105, "Headline"), + CREDIT( + 110, "Credit"), + SOURCE( + 115, "Source"), + COPYRIGHT_NOTICE( + 116, "Copyright Notice"), + CONTACT( + 118, "Contact"), + CAPTION_ABSTRACT( + 120, "Caption/Abstract"), + WRITER_EDITOR( + 122, "Writer/Editor"), + RASTERIZED_CAPTION( + 125, "Rasterized Caption"), + IMAGE_TYPE( + 130, "ImageType"), + IMAGE_ORIENTATION( + 131, "Image Orientation"), + LANGUAGE_IDENTIFIER( + 135, "Language Identifier"), + AUDIO_TYPE( + 150, "Audio Type"), + AUDIO_SAMPLING_RATE( + 151, "Audio Sampling Rate"), + AUDIO_SAMPLING_RESOLUTION( + 152, "Audio Sampling Resolution"), + AUDIO_DURATION( + 153, "Audio Duration"), + AUDIO_OUTCUE( + 154, "Audio Outcue"), + OBJECT_DATA_PREVIEW_FILE_FORMAT( + 200, "Object Data Preview, File Format"), + OBJECT_DATA_PREVIEW_FILE_FORMAT_VERSION( + 201, "Object Data Preview, File Format Version"), + OBJECT_DATA_PREVIEW_DATA( + 202, "Object Data Preview Data"); + + public final int type; + public final String name; + + IptcTypes(int type, String name) + { + this.type = type; + this.name = name; + } + + public String getName() { + return name; + } + + public int getType() { + return type; + } + + public String toString() + { + return name + " (" + type + ")"; + } + + public static IptcType getUnknown(final int type) { + return new IptcType() { + public String getName() { + return "Unknown"; + } + + public int getType() { + return type; + } + + public String toString() { + return "Unknown (" + type + ")"; + } + }; + } +} Propchange: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/iptc/IptcTypes.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/iptc/JpegIptcRewriter.java URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/iptc/JpegIptcRewriter.java?rev=1240468&r1=1240467&r2=1240468&view=diff ============================================================================== --- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/iptc/JpegIptcRewriter.java (original) +++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/iptc/JpegIptcRewriter.java Sat Feb 4 09:21:00 2012 @@ -131,8 +131,8 @@ public class JpegIptcRewriter extends Jp Map params = new HashMap(); PhotoshopApp13Data oldData = new IptcParser() .parsePhotoshopSegment(oldSegment.segmentData, params); - List newBlocks = oldData.getNonIptcBlocks(); - List newRecords = new ArrayList(); + List newBlocks = oldData.getNonIptcBlocks(); + List newRecords = new ArrayList(); PhotoshopApp13Data newData = new PhotoshopApp13Data(newRecords, newBlocks); byte segmentBytes[] = new IptcParser() Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/iptc/PhotoshopApp13Data.java URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/iptc/PhotoshopApp13Data.java?rev=1240468&r1=1240467&r2=1240468&view=diff ============================================================================== --- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/iptc/PhotoshopApp13Data.java (original) +++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/jpeg/iptc/PhotoshopApp13Data.java Sat Feb 4 09:21:00 2012 @@ -22,31 +22,31 @@ import java.util.List; public class PhotoshopApp13Data implements IptcConstants { - private final List records; - private final List rawBlocks; + private final List records; + private final List rawBlocks; - public PhotoshopApp13Data(List records, List rawBlocks) + public PhotoshopApp13Data(List records, List rawBlocks) { this.rawBlocks = rawBlocks; this.records = records; } - public List getRecords() + public List getRecords() { - return new ArrayList(records); + return new ArrayList(records); } - public List getRawBlocks() + public List getRawBlocks() { - return new ArrayList(rawBlocks); + return new ArrayList(rawBlocks); } - public List getNonIptcBlocks() + public List getNonIptcBlocks() { - List result = new ArrayList(); + List result = new ArrayList(); for (int i = 0; i < rawBlocks.size(); i++) { - IptcBlock block = (IptcBlock) rawBlocks.get(i); + IptcBlock block = rawBlocks.get(i); if (!block.isIPTCBlock()) result.add(block); } Modified: commons/proper/sanselan/trunk/src/test/java/org/apache/commons/sanselan/formats/jpeg/iptc/IptcDumpTest.java URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/test/java/org/apache/commons/sanselan/formats/jpeg/iptc/IptcDumpTest.java?rev=1240468&r1=1240467&r2=1240468&view=diff ============================================================================== --- commons/proper/sanselan/trunk/src/test/java/org/apache/commons/sanselan/formats/jpeg/iptc/IptcDumpTest.java (original) +++ commons/proper/sanselan/trunk/src/test/java/org/apache/commons/sanselan/formats/jpeg/iptc/IptcDumpTest.java Sat Feb 4 09:21:00 2012 @@ -72,9 +72,9 @@ public class IptcDumpTest extends IptcBa for (int j = 0; j < oldRecords.size(); j++) { IptcRecord record = (IptcRecord) oldRecords.get(j); - if (record.iptcType.type != IptcConstants.IPTC_TYPE_CITY.type) - Debug.debug("Key: " + record.iptcType.name + " (0x" - + Integer.toHexString(record.iptcType.type) + if (record.iptcType != IptcTypes.CITY) + Debug.debug("Key: " + record.iptcType.getName() + " (0x" + + Integer.toHexString(record.iptcType.getType()) + "), value: " + record.value); } Debug.debug(); Modified: commons/proper/sanselan/trunk/src/test/java/org/apache/commons/sanselan/formats/jpeg/iptc/IptcUpdateTest.java URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/test/java/org/apache/commons/sanselan/formats/jpeg/iptc/IptcUpdateTest.java?rev=1240468&r1=1240467&r2=1240468&view=diff ============================================================================== --- commons/proper/sanselan/trunk/src/test/java/org/apache/commons/sanselan/formats/jpeg/iptc/IptcUpdateTest.java (original) +++ commons/proper/sanselan/trunk/src/test/java/org/apache/commons/sanselan/formats/jpeg/iptc/IptcUpdateTest.java Sat Feb 4 09:21:00 2012 @@ -177,14 +177,14 @@ public class IptcUpdateTest extends Iptc for (int j = 0; j < oldRecords.size(); j++) { IptcRecord record = (IptcRecord) oldRecords.get(j); - if (record.iptcType.type != IptcConstants.IPTC_TYPE_CITY.type - && record.iptcType.type != IptcConstants.IPTC_TYPE_CREDIT.type) + if (record.iptcType != IptcTypes.CITY + && record.iptcType != IptcTypes.CREDIT) newRecords.add(record); } - newRecords.add(new IptcRecord(IptcConstants.IPTC_TYPE_CITY, + newRecords.add(new IptcRecord(IptcTypes.CITY, "Albany, NY")); - newRecords.add(new IptcRecord(IptcConstants.IPTC_TYPE_CREDIT, + newRecords.add(new IptcRecord(IptcTypes.CREDIT, "William Sorensen")); PhotoshopApp13Data newData = new PhotoshopApp13Data(newRecords, @@ -228,9 +228,9 @@ public class IptcUpdateTest extends Iptc List newBlocks = metadata.photoshopApp13Data.getNonIptcBlocks(); List newRecords = new ArrayList(); - newRecords.add(new IptcRecord(IptcConstants.IPTC_TYPE_CITY, + newRecords.add(new IptcRecord(IptcTypes.CITY, "Albany, NY")); - newRecords.add(new IptcRecord(IptcConstants.IPTC_TYPE_CREDIT, + newRecords.add(new IptcRecord(IptcTypes.CREDIT, "William Sorensen")); PhotoshopApp13Data newData = new PhotoshopApp13Data(newRecords, @@ -274,9 +274,9 @@ public class IptcUpdateTest extends Iptc List newBlocks = new ArrayList(); List newRecords = new ArrayList(); - newRecords.add(new IptcRecord(IptcConstants.IPTC_TYPE_CITY, + newRecords.add(new IptcRecord(IptcTypes.CITY, "Albany, NY")); - newRecords.add(new IptcRecord(IptcConstants.IPTC_TYPE_CREDIT, + newRecords.add(new IptcRecord(IptcTypes.CREDIT, "William Sorensen")); PhotoshopApp13Data newData = new PhotoshopApp13Data(newRecords, @@ -368,16 +368,16 @@ public class IptcUpdateTest extends Iptc for (int j = 0; j < oldRecords.size(); j++) { IptcRecord record = (IptcRecord) oldRecords.get(j); - if (record.iptcType.type != IptcConstants.IPTC_TYPE_CITY.type - && record.iptcType.type != IptcConstants.IPTC_TYPE_CREDIT.type) + if (record.iptcType != IptcTypes.CITY + && record.iptcType != IptcTypes.CREDIT) newRecords.add(record); } } } - newRecords.add(new IptcRecord(IptcConstants.IPTC_TYPE_CITY, + newRecords.add(new IptcRecord(IptcTypes.CITY, "Albany, NY")); - newRecords.add(new IptcRecord(IptcConstants.IPTC_TYPE_CREDIT, + newRecords.add(new IptcRecord(IptcTypes.CREDIT, "William Sorensen")); PhotoshopApp13Data newData = new PhotoshopApp13Data(newRecords,