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 1770BE5B9 for ; Tue, 4 Dec 2012 17:26:44 +0000 (UTC) Received: (qmail 54728 invoked by uid 500); 4 Dec 2012 17:26:43 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 54645 invoked by uid 500); 4 Dec 2012 17:26:43 -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 54623 invoked by uid 99); 4 Dec 2012 17:26:42 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 04 Dec 2012 17:26:42 +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; Tue, 04 Dec 2012 17:26:29 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 834B82388C73; Tue, 4 Dec 2012 17:25:34 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: svn commit: r1417043 [14/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 -0000 To: commits@commons.apache.org From: ggregory@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20121204172534.834B82388C73@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderStrips.java URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderStrips.java?rev=1417043&r1=1417042&r2=1417043&view=diff ============================================================================== --- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderStrips.java (original) +++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderStrips.java Tue Dec 4 17:23:16 2012 @@ -37,11 +37,11 @@ public final class DataReaderStrips exte private final TiffImageData.Strips imageData; - public DataReaderStrips(TiffDirectory directory, - PhotometricInterpreter photometricInterpreter, int bitsPerPixel, - int bitsPerSample[], int predictor, int samplesPerPixel, int width, - int height, int compression, ByteOrder byteOrder, int rowsPerStrip, - TiffImageData.Strips imageData) { + public DataReaderStrips(final TiffDirectory directory, + final PhotometricInterpreter photometricInterpreter, final int bitsPerPixel, + final int bitsPerSample[], final int predictor, final int samplesPerPixel, final int width, + final int height, final int compression, final ByteOrder byteOrder, final int rowsPerStrip, + final TiffImageData.Strips imageData) { super(directory, photometricInterpreter, bitsPerSample, predictor, samplesPerPixel, width, height); @@ -52,8 +52,8 @@ public final class DataReaderStrips exte this.byteOrder = byteOrder; } - private void interpretStrip(ImageBuilder imageBuilder, byte bytes[], - int pixels_per_strip) throws ImageReadException, IOException { + private void interpretStrip(final ImageBuilder imageBuilder, final byte bytes[], + final int pixels_per_strip) throws ImageReadException, IOException { if (y >= height) { return; } @@ -101,7 +101,7 @@ public final class DataReaderStrips exte // verify that all samples are one byte in size boolean allSamplesAreOneByte = true; - for (int element : bitsPerSample) { + for (final int element : bitsPerSample) { if (element != 8) { allSamplesAreOneByte = false; break; @@ -114,11 +114,11 @@ public final class DataReaderStrips exte if (y + nRows > height) { nRows = height - y; } - int i0 = y; - int i1 = y + nRows; + final int i0 = y; + final int i1 = y + nRows; x = 0; y += nRows; - int[] samples = new int[1]; + final int[] samples = new int[1]; for (int i = i0; i < i1; i++) { for (int j = 0; j < width; j++) { samples[0] = bytes[k++] & 0xff; @@ -133,21 +133,21 @@ public final class DataReaderStrips exte if (y + nRows > height) { nRows = height - y; } - int i0 = y; - int i1 = y + nRows; + final int i0 = y; + final int i1 = y + nRows; x = 0; y += nRows; if (photometricInterpreter instanceof PhotometricInterpreterRgb) { for (int i = i0; i < i1; i++) { for (int j = 0; j < width; j++, k += 3) { - int rgb = 0xff000000 + final int rgb = 0xff000000 | (((bytes[k] << 8) | (bytes[k + 1] & 0xff)) << 8) | (bytes[k + 2] & 0xff); imageBuilder.setRGB(j, i, rgb); } } } else { - int samples[] = new int[3]; + final int samples[] = new int[3]; for (int i = i0; i < i1; i++) { for (int j = 0; j < width; j++) { samples[0] = bytes[k++] & 0xff; @@ -167,8 +167,8 @@ public final class DataReaderStrips exte // this logic will handle all cases not conforming to the // special case handled above - ByteArrayInputStream bais = new ByteArrayInputStream(bytes); - BitInputStream bis = new BitInputStream(bais, byteOrder); + final ByteArrayInputStream bais = new ByteArrayInputStream(bytes); + final BitInputStream bis = new BitInputStream(bais, byteOrder); int[] samples = new int[bitsPerSample.length]; resetPredictor(); @@ -198,19 +198,19 @@ public final class DataReaderStrips exte private int x = 0, y = 0; @Override - public void readImageData(ImageBuilder imageBuilder) + public void readImageData(final ImageBuilder imageBuilder) throws ImageReadException, IOException { for (int strip = 0; strip < imageData.strips.length; strip++) { - long rowsPerStripLong = 0xFFFFffffL & rowsPerStrip; - long rowsRemaining = height - (strip * rowsPerStripLong); - long rowsInThisStrip = Math.min(rowsRemaining, rowsPerStripLong); - long bytesPerRow = (bitsPerPixel * width + 7) / 8; - long bytesPerStrip = rowsInThisStrip * bytesPerRow; - long pixelsPerStrip = rowsInThisStrip * width; + final long rowsPerStripLong = 0xFFFFffffL & rowsPerStrip; + final long rowsRemaining = height - (strip * rowsPerStripLong); + final long rowsInThisStrip = Math.min(rowsRemaining, rowsPerStripLong); + final long bytesPerRow = (bitsPerPixel * width + 7) / 8; + final long bytesPerStrip = rowsInThisStrip * bytesPerRow; + final long pixelsPerStrip = rowsInThisStrip * width; - byte compressed[] = imageData.strips[strip].getData(); + final byte compressed[] = imageData.strips[strip].getData(); - byte decompressed[] = decompress(compressed, compression, + final byte decompressed[] = decompress(compressed, compression, (int) bytesPerStrip, width, (int) rowsInThisStrip); interpretStrip(imageBuilder, decompressed, (int) pixelsPerStrip); Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderTiled.java URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderTiled.java?rev=1417043&r1=1417042&r2=1417043&view=diff ============================================================================== --- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderTiled.java (original) +++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderTiled.java Tue Dec 4 17:23:16 2012 @@ -41,11 +41,11 @@ public final class DataReaderTiled exten private final TiffImageData.Tiles imageData; - public DataReaderTiled(TiffDirectory directory, - PhotometricInterpreter photometricInterpreter, int tileWidth, - int tileLength, int bitsPerPixel, int bitsPerSample[], - int predictor, int samplesPerPixel, int width, int height, - int compression, ByteOrder byteOrder, TiffImageData.Tiles imageData) { + public DataReaderTiled(final TiffDirectory directory, + final PhotometricInterpreter photometricInterpreter, final int tileWidth, + final int tileLength, final int bitsPerPixel, final int bitsPerSample[], + final int predictor, final int samplesPerPixel, final int width, final int height, + final int compression, final ByteOrder byteOrder, final TiffImageData.Tiles imageData) { super(directory, photometricInterpreter, bitsPerSample, predictor, samplesPerPixel, width, height); @@ -59,8 +59,8 @@ public final class DataReaderTiled exten this.byteOrder = byteOrder; } - private void interpretTile(ImageBuilder imageBuilder, byte bytes[], - int startX, int startY) throws ImageReadException, IOException { + private void interpretTile(final ImageBuilder imageBuilder, final byte bytes[], + final int startX, final int startY) throws ImageReadException, IOException { // changes introduced May 2012 // The following block of code implements changes that // reduce image loading time by using special-case processing @@ -71,7 +71,7 @@ public final class DataReaderTiled exten // verify that all samples are one byte in size boolean allSamplesAreOneByte = true; - for (int element : bitsPerSample) { + for (final int element : bitsPerSample) { if (element != 8) { allSamplesAreOneByte = false; break; @@ -80,13 +80,13 @@ public final class DataReaderTiled exten if (predictor != 2 && bitsPerPixel == 24 && allSamplesAreOneByte) { int k = 0; - int i0 = startY; + final int i0 = startY; int i1 = startY + tileLength; if (i1 > height) { // the tile is padded past bottom of image i1 = height; } - int j0 = startX; + final int j0 = startX; int j1 = startX + tileWidth; if (j1 > width) { // the tile is padded to beyond the tile width @@ -96,14 +96,14 @@ public final class DataReaderTiled exten for (int i = i0; i < i1; i++) { k = (i - i0) * tileWidth * 3; for (int j = j0; j < j1; j++, k += 3) { - int rgb = 0xff000000 + final int rgb = 0xff000000 | (((bytes[k] << 8) | (bytes[k + 1] & 0xff)) << 8) | (bytes[k + 2] & 0xff); imageBuilder.setRGB(j, i, rgb); } } } else { - int samples[] = new int[3]; + final int samples[] = new int[3]; for (int i = i0; i < i1; i++) { k = (i - i0) * tileWidth * 3; for (int j = j0; j < j1; j++) { @@ -120,10 +120,10 @@ public final class DataReaderTiled exten // End of May 2012 changes - ByteArrayInputStream bais = new ByteArrayInputStream(bytes); - BitInputStream bis = new BitInputStream(bais, byteOrder); + final ByteArrayInputStream bais = new ByteArrayInputStream(bytes); + final BitInputStream bis = new BitInputStream(bais, byteOrder); - int pixelsPerTile = tileWidth * tileLength; + final int pixelsPerTile = tileWidth * tileLength; int tileX = 0, tileY = 0; @@ -131,8 +131,8 @@ public final class DataReaderTiled exten resetPredictor(); for (int i = 0; i < pixelsPerTile; i++) { - int x = tileX + startX; - int y = tileY + startY; + final int x = tileX + startX; + final int y = tileY + startY; getSamplesAsBytes(bis, samples); @@ -158,17 +158,17 @@ public final class DataReaderTiled exten } @Override - public void readImageData(ImageBuilder imageBuilder) + public void readImageData(final ImageBuilder imageBuilder) throws ImageReadException, IOException { - int bitsPerRow = tileWidth * bitsPerPixel; - int bytesPerRow = (bitsPerRow + 7) / 8; - int bytesPerTile = bytesPerRow * tileLength; + final int bitsPerRow = tileWidth * bitsPerPixel; + final int bytesPerRow = (bitsPerRow + 7) / 8; + final int bytesPerTile = bytesPerRow * tileLength; int x = 0, y = 0; - for (DataElement tile2 : imageData.tiles) { - byte compressed[] = tile2.getData(); + for (final DataElement tile2 : imageData.tiles) { + final byte compressed[] = tile2.getData(); - byte decompressed[] = decompress(compressed, compression, + final byte decompressed[] = decompress(compressed, compression, bytesPerTile, tileWidth, tileLength); interpretTile(imageBuilder, decompressed, x, y); Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldType.java URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldType.java?rev=1417043&r1=1417042&r2=1417043&view=diff ============================================================================== --- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldType.java (original) +++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldType.java Tue Dec 4 17:23:16 2012 @@ -28,22 +28,22 @@ public abstract class FieldType extends public final int type, length; public final String name; - public FieldType(int type, int length, String name) { + public FieldType(final int type, final int length, final String name) { this.type = type; this.length = length; this.name = name; } - public boolean isLocalValue(TiffField entry) { + public boolean isLocalValue(final TiffField entry) { // FIXME: we should use unsigned ints for offsets and lengths // when parsing TIFF files. But since we don't, // at least make this method treat length as unsigned, // so that corrupt lengths are caught early. - long entryLength = 0xffffffffL & entry.length; + final long entryLength = 0xffffffffL & entry.length; return ((length > 0) && ((length * entryLength) <= TIFF_ENTRY_MAX_VALUE_LENGTH)); } - public int getBytesLength(TiffField entry) throws ImageReadException { + public int getBytesLength(final TiffField entry) throws ImageReadException { if (length < 1) { throw new ImageReadException("Unknown field type"); } @@ -58,22 +58,22 @@ public abstract class FieldType extends return new byte[TIFF_ENTRY_MAX_VALUE_LENGTH]; } - public final byte[] getStubValue(int count) { + public final byte[] getStubValue(final int count) { return new byte[count * length]; } - public String getDisplayValue(TiffField entry) throws ImageReadException { - Object o = getSimpleValue(entry); + public String getDisplayValue(final TiffField entry) throws ImageReadException { + final Object o = getSimpleValue(entry); if (o == null) { return "NULL"; } return o.toString(); } - public final byte[] getRawBytes(TiffField entry) { + public final byte[] getRawBytes(final TiffField entry) { if (isLocalValue(entry)) { - int rawLength = length * entry.length; - byte result[] = new byte[rawLength]; + final int rawLength = length * entry.length; + final byte result[] = new byte[rawLength]; System.arraycopy(entry.valueOffsetBytes, 0, result, 0, rawLength); return result; // return readBytearray(name, entry.valueOffsetBytes, 0, length Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeAscii.java URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeAscii.java?rev=1417043&r1=1417042&r2=1417043&view=diff ============================================================================== --- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeAscii.java (original) +++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeAscii.java Tue Dec 4 17:23:16 2012 @@ -23,22 +23,22 @@ import org.apache.commons.imaging.common import org.apache.commons.imaging.formats.tiff.TiffField; public class FieldTypeAscii extends FieldType { - public FieldTypeAscii(int type, String name) { + public FieldTypeAscii(final int type, final String name) { super(type, 1, name); } @Override - public Object getSimpleValue(TiffField entry) { + public Object getSimpleValue(final TiffField entry) { // According to EXIF specification // "2 = ASCII An 8-bit byte containing one 7-bit ASCII code. The final byte is terminated with NULL." - byte bytes[] = getRawBytes(entry); + final byte bytes[] = getRawBytes(entry); int nullCount = 1; for (int i = 0; i < bytes.length - 1; i++) { if (bytes[i] == 0) { nullCount++; } } - String[] strings = new String[nullCount]; + final String[] strings = new String[nullCount]; int stringsAdded = 0; strings[0] = ""; // if we have a 0 length string int nextStringPos = 0; @@ -48,10 +48,10 @@ public class FieldTypeAscii extends Fiel for (int i = 0; i < bytes.length; i++) { if (bytes[i] == 0) { try { - String string = new String(bytes, nextStringPos, i + final String string = new String(bytes, nextStringPos, i - nextStringPos, "UTF-8"); strings[stringsAdded++] = string; - } catch (UnsupportedEncodingException unsupportedEncoding) { + } catch (final UnsupportedEncodingException unsupportedEncoding) { } nextStringPos = i + 1; } @@ -59,10 +59,10 @@ public class FieldTypeAscii extends Fiel if (nextStringPos < bytes.length) { // Buggy file, string wasn't null terminated try { - String string = new String(bytes, nextStringPos, bytes.length + final String string = new String(bytes, nextStringPos, bytes.length - nextStringPos, "UTF-8"); strings[stringsAdded++] = string; - } catch (UnsupportedEncodingException unsupportedEncoding) { + } catch (final UnsupportedEncodingException unsupportedEncoding) { } } if (strings.length == 1) { @@ -73,10 +73,10 @@ public class FieldTypeAscii extends Fiel } @Override - public byte[] writeData(Object o, ByteOrder byteOrder) throws ImageWriteException { + public byte[] writeData(final Object o, final ByteOrder byteOrder) throws ImageWriteException { if (o instanceof byte[]) { - byte bytes[] = (byte[]) o; - byte result[] = new byte[bytes.length + 1]; + final byte bytes[] = (byte[]) o; + final byte result[] = new byte[bytes.length + 1]; System.arraycopy(bytes, 0, result, 0, bytes.length); result[result.length - 1] = 0; return result; @@ -84,32 +84,32 @@ public class FieldTypeAscii extends Fiel byte[] bytes = null; try { bytes = ((String) o).getBytes("UTF-8"); - } catch (UnsupportedEncodingException cannotHappen) { + } catch (final UnsupportedEncodingException cannotHappen) { throw new IllegalArgumentException("Your Java doesn't support UTF-8"); } - byte result[] = new byte[bytes.length + 1]; + final byte result[] = new byte[bytes.length + 1]; System.arraycopy(bytes, 0, result, 0, bytes.length); result[result.length - 1] = 0; return result; } else if (o instanceof String[]) { - String[] strings = (String[]) o; + final String[] strings = (String[]) o; int totalLength = 0; - for (String string : strings) { + for (final String string : strings) { byte[] bytes = null; try { bytes = string.getBytes("UTF-8"); - } catch (UnsupportedEncodingException cannotHappen) { + } catch (final UnsupportedEncodingException cannotHappen) { throw new IllegalArgumentException("Your Java doesn't support UTF-8"); } totalLength += (bytes.length + 1); } - byte[] result = new byte[totalLength]; + final byte[] result = new byte[totalLength]; int position = 0; - for (String string : strings) { + for (final String string : strings) { byte[] bytes = null; try { bytes = string.getBytes("UTF-8"); - } catch (UnsupportedEncodingException cannotHappen) { + } catch (final UnsupportedEncodingException cannotHappen) { throw new IllegalArgumentException("Your Java doesn't support UTF-8"); } System.arraycopy(bytes, 0, result, position, bytes.length); Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeByte.java URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeByte.java?rev=1417043&r1=1417042&r2=1417043&view=diff ============================================================================== --- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeByte.java (original) +++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeByte.java Tue Dec 4 17:23:16 2012 @@ -22,12 +22,12 @@ import org.apache.commons.imaging.format import org.apache.commons.imaging.util.Debug; public class FieldTypeByte extends FieldType { - public FieldTypeByte(int type, String name) { + public FieldTypeByte(final int type, final String name) { super(type, 1, name); } @Override - public Object getSimpleValue(TiffField entry) { + public Object getSimpleValue(final TiffField entry) { if (entry.length == 1) { return entry.valueOffsetBytes[0]; } @@ -36,7 +36,7 @@ public class FieldTypeByte extends Field } @Override - public byte[] writeData(Object o, ByteOrder byteOrder) throws ImageWriteException { + public byte[] writeData(final Object o, final ByteOrder byteOrder) throws ImageWriteException { if (o instanceof Byte) { return new byte[] { ((Byte) o).byteValue(), }; } else if (o instanceof byte[]) { Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeDouble.java URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeDouble.java?rev=1417043&r1=1417042&r2=1417043&view=diff ============================================================================== --- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeDouble.java (original) +++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeDouble.java Tue Dec 4 17:23:16 2012 @@ -28,21 +28,21 @@ public class FieldTypeDouble extends Fie } @Override - public Object getSimpleValue(TiffField entry) { + public Object getSimpleValue(final TiffField entry) { return "?"; } @Override - public byte[] writeData(Object o, ByteOrder byteOrder) throws ImageWriteException { + public byte[] writeData(final Object o, final ByteOrder byteOrder) throws ImageWriteException { if (o instanceof Double) { return BinaryConversions.toBytes(((Double) o).doubleValue(), byteOrder); } else if (o instanceof double[]) { - double numbers[] = (double[]) o; + final double numbers[] = (double[]) o; return BinaryConversions.toBytes(numbers, byteOrder); } else if (o instanceof Double[]) { - Double numbers[] = (Double[]) o; - double values[] = new double[numbers.length]; + final Double numbers[] = (Double[]) o; + final double values[] = new double[numbers.length]; for (int i = 0; i < values.length; i++) { values[i] = numbers[i].doubleValue(); } Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeFloat.java URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeFloat.java?rev=1417043&r1=1417042&r2=1417043&view=diff ============================================================================== --- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeFloat.java (original) +++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeFloat.java Tue Dec 4 17:23:16 2012 @@ -30,7 +30,7 @@ public class FieldTypeFloat extends Fiel // = new FieldType(11, 4, "Float") @Override - public Object getSimpleValue(TiffField entry) { + public Object getSimpleValue(final TiffField entry) { if (entry.length == 1) { return new Float(BinaryConversions.toFloat( entry.valueOffsetBytes, @@ -42,15 +42,15 @@ public class FieldTypeFloat extends Fiel } @Override - public byte[] writeData(Object o, ByteOrder byteOrder) throws ImageWriteException { + public byte[] writeData(final Object o, final ByteOrder byteOrder) throws ImageWriteException { if (o instanceof Float) { return BinaryConversions.toBytes(((Float) o).floatValue(), byteOrder); } else if (o instanceof float[]) { - float numbers[] = (float[]) o; + final float numbers[] = (float[]) o; return BinaryConversions.toBytes(numbers, byteOrder); } else if (o instanceof Float[]) { - Float numbers[] = (Float[]) o; - float values[] = new float[numbers.length]; + final Float numbers[] = (Float[]) o; + final float values[] = new float[numbers.length]; for (int i = 0; i < values.length; i++) { values[i] = numbers[i].floatValue(); } Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeLong.java URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeLong.java?rev=1417043&r1=1417042&r2=1417043&view=diff ============================================================================== --- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeLong.java (original) +++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeLong.java Tue Dec 4 17:23:16 2012 @@ -23,12 +23,12 @@ import org.apache.commons.imaging.format import org.apache.commons.imaging.util.Debug; public class FieldTypeLong extends FieldType { - public FieldTypeLong(int type, String name) { + public FieldTypeLong(final int type, final String name) { super(type, 4, name); } @Override - public Object getSimpleValue(TiffField entry) { + public Object getSimpleValue(final TiffField entry) { if (entry.length == 1) { return BinaryConversions.toInt( entry.valueOffsetBytes, entry.byteOrder); @@ -39,15 +39,15 @@ public class FieldTypeLong extends Field } @Override - public byte[] writeData(Object o, ByteOrder byteOrder) throws ImageWriteException { + public byte[] writeData(final Object o, final ByteOrder byteOrder) throws ImageWriteException { if (o instanceof Integer) { return BinaryConversions.toBytes(((Integer)o).intValue(), byteOrder); } else if (o instanceof int[]) { - int numbers[] = (int[]) o; + final int numbers[] = (int[]) o; return BinaryConversions.toBytes(numbers, byteOrder); } else if (o instanceof Integer[]) { - Integer numbers[] = (Integer[]) o; - int values[] = new int[numbers.length]; + final Integer numbers[] = (Integer[]) o; + final int values[] = new int[numbers.length]; for (int i = 0; i < values.length; i++) { values[i] = numbers[i].intValue(); } Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeRational.java URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeRational.java?rev=1417043&r1=1417042&r2=1417043&view=diff ============================================================================== --- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeRational.java (original) +++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeRational.java Tue Dec 4 17:23:16 2012 @@ -25,12 +25,12 @@ import org.apache.commons.imaging.format import org.apache.commons.imaging.util.Debug; public class FieldTypeRational extends FieldType { - public FieldTypeRational(int type, String name) { + public FieldTypeRational(final int type, final String name) { super(type, 8, name); } @Override - public Object getSimpleValue(TiffField entry) { + public Object getSimpleValue(final TiffField entry) { if (entry.length == 1) { return BinaryConversions.toRational(entry.oversizeValue, entry.byteOrder); } @@ -40,31 +40,31 @@ public class FieldTypeRational extends F } @Override - public byte[] writeData(Object o, ByteOrder byteOrder) throws ImageWriteException { + public byte[] writeData(final Object o, final ByteOrder byteOrder) throws ImageWriteException { if (o instanceof RationalNumber) { return BinaryConversions.toBytes((RationalNumber) o, byteOrder); } else if (o instanceof RationalNumber[]) { return BinaryConversions.toBytes((RationalNumber[]) o, byteOrder); } else if (o instanceof Number) { - Number number = (Number) o; - RationalNumber rationalNumber = RationalNumberUtilities + final Number number = (Number) o; + final RationalNumber rationalNumber = RationalNumberUtilities .getRationalNumber(number.doubleValue()); return BinaryConversions.toBytes(rationalNumber, byteOrder); } else if (o instanceof Number[]) { - Number numbers[] = (Number[]) o; - RationalNumber rationalNumbers[] = new RationalNumber[numbers.length]; + final Number numbers[] = (Number[]) o; + final RationalNumber rationalNumbers[] = new RationalNumber[numbers.length]; for (int i = 0; i < numbers.length; i++) { - Number number = numbers[i]; + final Number number = numbers[i]; rationalNumbers[i] = RationalNumberUtilities .getRationalNumber(number.doubleValue()); } return BinaryConversions.toBytes(rationalNumbers, byteOrder); } else if (o instanceof double[]) { - double numbers[] = (double[]) o; - RationalNumber rationalNumbers[] = new RationalNumber[numbers.length]; + final double numbers[] = (double[]) o; + final RationalNumber rationalNumbers[] = new RationalNumber[numbers.length]; for (int i = 0; i < numbers.length; i++) { - double number = numbers[i]; + final double number = numbers[i]; rationalNumbers[i] = RationalNumberUtilities .getRationalNumber(number); } @@ -75,13 +75,13 @@ public class FieldTypeRational extends F } } - public byte[] writeData(int numerator, int denominator, ByteOrder byteOrder) + public byte[] writeData(final int numerator, final int denominator, final ByteOrder byteOrder) throws ImageWriteException { return writeData(new int[] { numerator }, new int[] { denominator }, byteOrder); } - public byte[] writeData(int numerators[], int denominators[], ByteOrder byteOrder) + public byte[] writeData(final int numerators[], final int denominators[], final ByteOrder byteOrder) throws ImageWriteException { return convertIntArrayToRationalArray(numerators, denominators, byteOrder); Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeShort.java URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeShort.java?rev=1417043&r1=1417042&r2=1417043&view=diff ============================================================================== --- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeShort.java (original) +++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeShort.java Tue Dec 4 17:23:16 2012 @@ -24,12 +24,12 @@ import org.apache.commons.imaging.format import org.apache.commons.imaging.util.Debug; public class FieldTypeShort extends FieldType { - public FieldTypeShort(int type, String name) { + public FieldTypeShort(final int type, final String name) { super(type, 2, name); } @Override - public Object getSimpleValue(TiffField entry) throws ImageReadException { + public Object getSimpleValue(final TiffField entry) throws ImageReadException { if (entry.length == 1) { return BinaryConversions.toShort(entry.valueOffsetBytes, entry.byteOrder); @@ -40,16 +40,16 @@ public class FieldTypeShort extends Fiel } @Override - public byte[] writeData(Object o, ByteOrder byteOrder) throws ImageWriteException { + public byte[] writeData(final Object o, final ByteOrder byteOrder) throws ImageWriteException { if (o instanceof Short) { return BinaryConversions.toBytes( ((Short)o).shortValue(), byteOrder); } else if (o instanceof short[]) { - short numbers[] = (short[]) o; + final short numbers[] = (short[]) o; return BinaryConversions.toBytes(numbers, byteOrder); } else if (o instanceof Short[]) { - Short numbers[] = (Short[]) o; - short values[] = new short[numbers.length]; + final Short numbers[] = (Short[]) o; + final short values[] = new short[numbers.length]; for (int i = 0; i < values.length; i++) { values[i] = numbers[i].shortValue(); } Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeUnknown.java URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeUnknown.java?rev=1417043&r1=1417042&r2=1417043&view=diff ============================================================================== --- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeUnknown.java (original) +++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeUnknown.java Tue Dec 4 17:23:16 2012 @@ -27,7 +27,7 @@ public class FieldTypeUnknown extends Fi } @Override - public Object getSimpleValue(TiffField entry) { + public Object getSimpleValue(final TiffField entry) { // Debug.debug("unknown field type. entry", entry.tagInfo.name); // Debug.debug("unknown field type. entry.type", entry.type); // Debug.debug("unknown field type. entry.length", entry.length); @@ -46,7 +46,7 @@ public class FieldTypeUnknown extends Fi } @Override - public byte[] writeData(Object o, ByteOrder byteOrder) throws ImageWriteException { + public byte[] writeData(final Object o, final ByteOrder byteOrder) throws ImageWriteException { if (o instanceof Byte) { return new byte[] { ((Byte) o).byteValue(), }; } else if (o instanceof byte[]) { Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreter.java URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreter.java?rev=1417043&r1=1417042&r2=1417043&view=diff ============================================================================== --- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreter.java (original) +++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreter.java Tue Dec 4 17:23:16 2012 @@ -28,8 +28,8 @@ public abstract class PhotometricInterpr protected final int width; protected final int height; - public PhotometricInterpreter(int fSamplesPerPixel, int fBitsPerSample[], - int Predictor, int width, int height) { + public PhotometricInterpreter(final int fSamplesPerPixel, final int fBitsPerSample[], + final int Predictor, final int width, final int height) { this.samplesPerPixel = fSamplesPerPixel; this.bitsPerSample = fBitsPerSample; this.predictor = Predictor; Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreterBiLevel.java URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreterBiLevel.java?rev=1417043&r1=1417042&r2=1417043&view=diff ============================================================================== --- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreterBiLevel.java (original) +++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreterBiLevel.java Tue Dec 4 17:23:16 2012 @@ -26,9 +26,9 @@ public class PhotometricInterpreterBiLev // private final int bitsPerPixel; - public PhotometricInterpreterBiLevel(int fBitsPerPixel, - int fSamplesPerPixel, int fBitsPerSample[], int Predictor, - int width, int height, boolean invert) { + public PhotometricInterpreterBiLevel(final int fBitsPerPixel, + final int fSamplesPerPixel, final int fBitsPerSample[], final int Predictor, + final int width, final int height, final boolean invert) { super(fSamplesPerPixel, fBitsPerSample, Predictor, width, height); this.invert = invert; @@ -36,20 +36,20 @@ public class PhotometricInterpreterBiLev } @Override - public void interpretPixel(ImageBuilder imageBuilder, int samples[], int x, - int y) throws ImageReadException, IOException { + public void interpretPixel(final ImageBuilder imageBuilder, final int samples[], final int x, + final int y) throws ImageReadException, IOException { int sample = samples[0]; if (invert) { sample = 255 - sample; } - int red = sample; - int green = sample; - int blue = sample; + final int red = sample; + final int green = sample; + final int blue = sample; - int alpha = 0xff; - int rgb = (alpha << 24) | (red << 16) | (green << 8) | (blue << 0); + final int alpha = 0xff; + final int rgb = (alpha << 24) | (red << 16) | (green << 8) | (blue << 0); imageBuilder.setRGB(x, y, rgb); } Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreterCieLab.java URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreterCieLab.java?rev=1417043&r1=1417042&r2=1417043&view=diff ============================================================================== --- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreterCieLab.java (original) +++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreterCieLab.java Tue Dec 4 17:23:16 2012 @@ -23,8 +23,8 @@ import org.apache.commons.imaging.color. import org.apache.commons.imaging.common.ImageBuilder; public class PhotometricInterpreterCieLab extends PhotometricInterpreter { - public PhotometricInterpreterCieLab(int fSamplesPerPixel, - int fBitsPerSample[], int Predictor, int width, int height) { + public PhotometricInterpreterCieLab(final int fSamplesPerPixel, + final int fBitsPerSample[], final int Predictor, final int width, final int height) { super(fSamplesPerPixel, fBitsPerSample, Predictor, width, height); } @@ -33,13 +33,13 @@ public class PhotometricInterpreterCieLa } @Override - public void interpretPixel(ImageBuilder imageBuilder, int samples[], int x, - int y) throws ImageReadException, IOException { - int cieL = samples[0]; - int cieA = (byte) samples[1]; - int cieB = (byte) samples[2]; + public void interpretPixel(final ImageBuilder imageBuilder, final int samples[], final int x, + final int y) throws ImageReadException, IOException { + final int cieL = samples[0]; + final int cieA = (byte) samples[1]; + final int cieB = (byte) samples[2]; - int rgb = ColorConversions.convertCIELabtoARGBTest(cieL, cieA, cieB); + final int rgb = ColorConversions.convertCIELabtoARGBTest(cieL, cieA, cieB); imageBuilder.setRGB(x, y, rgb); } Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreterCmyk.java URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreterCmyk.java?rev=1417043&r1=1417042&r2=1417043&view=diff ============================================================================== --- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreterCmyk.java (original) +++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreterCmyk.java Tue Dec 4 17:23:16 2012 @@ -23,21 +23,21 @@ import org.apache.commons.imaging.color. import org.apache.commons.imaging.common.ImageBuilder; public class PhotometricInterpreterCmyk extends PhotometricInterpreter { - public PhotometricInterpreterCmyk(int fSamplesPerPixel, - int fBitsPerSample[], int Predictor, int width, int height) { + public PhotometricInterpreterCmyk(final int fSamplesPerPixel, + final int fBitsPerSample[], final int Predictor, final int width, final int height) { super(fSamplesPerPixel, fBitsPerSample, Predictor, width, height); } @Override - public void interpretPixel(ImageBuilder imageBuilder, int samples[], int x, - int y) throws ImageReadException, IOException { + public void interpretPixel(final ImageBuilder imageBuilder, final int samples[], final int x, + final int y) throws ImageReadException, IOException { - int sc = samples[0]; - int sm = samples[1]; - int sy = samples[2]; - int sk = samples[3]; + final int sc = samples[0]; + final int sm = samples[1]; + final int sy = samples[2]; + final int sk = samples[3]; - int rgb = ColorConversions.convertCMYKtoRGB(sc, sm, sy, sk); + final int rgb = ColorConversions.convertCMYKtoRGB(sc, sm, sy, sk); imageBuilder.setRGB(x, y, rgb); } Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreterLogLuv.java URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreterLogLuv.java?rev=1417043&r1=1417042&r2=1417043&view=diff ============================================================================== --- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreterLogLuv.java (original) +++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreterLogLuv.java Tue Dec 4 17:23:16 2012 @@ -24,9 +24,9 @@ import org.apache.commons.imaging.common public class PhotometricInterpreterLogLuv extends PhotometricInterpreter { // private final boolean yOnly; - public PhotometricInterpreterLogLuv(int fSamplesPerPixel, - int fBitsPerSample[], int Predictor, int width, int height, - boolean yonly) { + public PhotometricInterpreterLogLuv(final int fSamplesPerPixel, + final int fBitsPerSample[], final int Predictor, final int width, final int height, + final boolean yonly) { super(fSamplesPerPixel, fBitsPerSample, Predictor, width, height); // this.yOnly = yonly; @@ -36,20 +36,20 @@ public class PhotometricInterpreterLogLu public void dumpstats() throws ImageReadException, IOException { } - private float cube(float f) { + private float cube(final float f) { return f * f * f; } // private float function_f(float value, ) @Override - public void interpretPixel(ImageBuilder imageBuilder, int samples[], int x, - int y) throws ImageReadException, IOException { + public void interpretPixel(final ImageBuilder imageBuilder, final int samples[], final int x, + final int y) throws ImageReadException, IOException { float X, Y, Z; - int cieL = samples[0]; - int cieA = (byte) samples[1]; - int cieB = (byte) samples[2]; + final int cieL = samples[0]; + final int cieA = (byte) samples[1]; + final int cieB = (byte) samples[2]; { @@ -57,9 +57,9 @@ public class PhotometricInterpreterLogLu float var_X = cieA / 500.0f + var_Y; float var_Z = var_Y - cieB / 200.0f; - float var_x_cube = cube(var_X); - float var_y_cube = cube(var_Y); - float var_z_cube = cube(var_Z); + final float var_x_cube = cube(var_X); + final float var_y_cube = cube(var_Y); + final float var_z_cube = cube(var_Z); if (var_y_cube > 0.008856f) { var_Y = var_y_cube; @@ -79,9 +79,9 @@ public class PhotometricInterpreterLogLu var_Z = (var_Z - 16 / 116.0f) / 7.787f; } - float ref_X = 95.047f; - float ref_Y = 100.000f; - float ref_Z = 108.883f; + final float ref_X = 95.047f; + final float ref_Y = 100.000f; + final float ref_Z = 108.883f; X = ref_X * var_X; // ref_X = 95.047 Observer= 2°, Illuminant= D65 Y = ref_Y * var_Y; // ref_Y = 100.000 @@ -95,9 +95,9 @@ public class PhotometricInterpreterLogLu int R, G, B; { - float var_X = X / 100f; // X = From 0 to ref_X - float var_Y = Y / 100f; // Y = From 0 to ref_Y - float var_Z = Z / 100f; // Z = From 0 to ref_Y + final float var_X = X / 100f; // X = From 0 to ref_X + final float var_Y = Y / 100f; // Y = From 0 to ref_Y + final float var_Z = Z / 100f; // Z = From 0 to ref_Y float var_R = var_X * 3.2406f + var_Y * -1.5372f + var_Z * -0.4986f; float var_G = var_X * -0.9689f + var_Y * 1.8758f + var_Z * 0.0415f; @@ -149,8 +149,8 @@ public class PhotometricInterpreterLogLu red = Math.min(255, Math.max(0, red)); green = Math.min(255, Math.max(0, green)); blue = Math.min(255, Math.max(0, blue)); - int alpha = 0xff; - int rgb = (alpha << 24) | (red << 16) | (green << 8) | (blue << 0); + final int alpha = 0xff; + final int rgb = (alpha << 24) | (red << 16) | (green << 8) | (blue << 0); imageBuilder.setRGB(x, y, rgb); } Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreterPalette.java URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreterPalette.java?rev=1417043&r1=1417042&r2=1417043&view=diff ============================================================================== --- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreterPalette.java (original) +++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreterPalette.java Tue Dec 4 17:23:16 2012 @@ -30,20 +30,20 @@ public class PhotometricInterpreterPalet */ private final int[] indexColorMap; - public PhotometricInterpreterPalette(int fSamplesPerPixel, - int fBitsPerSample[], int Predictor, int width, int height, - int[] fColorMap) { + public PhotometricInterpreterPalette(final int fSamplesPerPixel, + final int fBitsPerSample[], final int Predictor, final int width, final int height, + final int[] fColorMap) { super(fSamplesPerPixel, fBitsPerSample, Predictor, width, height); this.fColorMap = fColorMap; - int fBitsPerPixel = bitsPerSample[0]; - int colormap_scale = (1 << fBitsPerPixel); + final int fBitsPerPixel = bitsPerSample[0]; + final int colormap_scale = (1 << fBitsPerPixel); indexColorMap = new int[colormap_scale]; for (int index = 0; index < colormap_scale; index++) { - int red = (fColorMap[index] >> 8) & 0xff; - int green = (fColorMap[index + (colormap_scale)] >> 8) & 0xff; - int blue = (fColorMap[index + (2 * colormap_scale)] >> 8) & 0xff; + final int red = (fColorMap[index] >> 8) & 0xff; + final int green = (fColorMap[index + (colormap_scale)] >> 8) & 0xff; + final int blue = (fColorMap[index + (2 * colormap_scale)] >> 8) & 0xff; indexColorMap[index] = 0xff000000 | (red << 16) | (green << 8) | blue; } @@ -51,8 +51,8 @@ public class PhotometricInterpreterPalet } @Override - public void interpretPixel(ImageBuilder imageBuilder, int samples[], int x, - int y) throws ImageReadException, IOException { + public void interpretPixel(final ImageBuilder imageBuilder, final int samples[], final int x, + final int y) throws ImageReadException, IOException { imageBuilder.setRGB(x, y, indexColorMap[samples[0]]); } } Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreterRgb.java URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreterRgb.java?rev=1417043&r1=1417042&r2=1417043&view=diff ============================================================================== --- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreterRgb.java (original) +++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreterRgb.java Tue Dec 4 17:23:16 2012 @@ -22,20 +22,20 @@ import org.apache.commons.imaging.ImageR import org.apache.commons.imaging.common.ImageBuilder; public class PhotometricInterpreterRgb extends PhotometricInterpreter { - public PhotometricInterpreterRgb(int fSamplesPerPixel, - int fBitsPerSample[], int Predictor, int width, int height) { + public PhotometricInterpreterRgb(final int fSamplesPerPixel, + final int fBitsPerSample[], final int Predictor, final int width, final int height) { super(fSamplesPerPixel, fBitsPerSample, Predictor, width, height); } @Override - public void interpretPixel(ImageBuilder imageBuilder, int samples[], int x, - int y) throws ImageReadException, IOException { - int red = samples[0]; - int green = samples[1]; - int blue = samples[2]; + public void interpretPixel(final ImageBuilder imageBuilder, final int samples[], final int x, + final int y) throws ImageReadException, IOException { + final int red = samples[0]; + final int green = samples[1]; + final int blue = samples[2]; - int alpha = 0xff; - int rgb = (alpha << 24) | (red << 16) | (green << 8) | (blue << 0); + final int alpha = 0xff; + final int rgb = (alpha << 24) | (red << 16) | (green << 8) | (blue << 0); imageBuilder.setRGB(x, y, rgb); } Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreterYCbCr.java URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreterYCbCr.java?rev=1417043&r1=1417042&r2=1417043&view=diff ============================================================================== --- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreterYCbCr.java (original) +++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreterYCbCr.java Tue Dec 4 17:23:16 2012 @@ -23,14 +23,14 @@ import org.apache.commons.imaging.common public class PhotometricInterpreterYCbCr extends PhotometricInterpreter { - public PhotometricInterpreterYCbCr(double[] fYCbCrCoefficients, - int[] fYCbCrPositioning, int[] fYCbCrSubSampling, - double[] fReferenceBlackWhite, int fSamplesPerPixel, - int fBitsPerSample[], int Predictor, int width, int height) { + public PhotometricInterpreterYCbCr(final double[] fYCbCrCoefficients, + final int[] fYCbCrPositioning, final int[] fYCbCrSubSampling, + final double[] fReferenceBlackWhite, final int fSamplesPerPixel, + final int fBitsPerSample[], final int Predictor, final int width, final int height) { super(fSamplesPerPixel, fBitsPerSample, Predictor, width, height); } - public int limit(int value, int min, int max) { + public int limit(final int value, final int min, final int max) { return Math.min(max, Math.max(min, value)); } @@ -51,36 +51,36 @@ public class PhotometricInterpreterYCbCr * The Cr component set. * @return R The R component. */ - public int convertYCbCrtoRGB(int Y, int Cb, int Cr) { - double r1 = (((1.164 * (Y - 16.0))) + (1.596 * (Cr - 128.0))); - double g1 = (((1.164 * (Y - 16.0))) - (0.813 * (Cr - 128.0)) - (0.392 * (Cb - 128.0))); - double b1 = (((1.164 * (Y - 16.0))) + (2.017 * (Cb - 128.0))); - - int r = limit((int) r1, 0, 255); - int g = limit((int) g1, 0, 255); - int b = limit((int) b1, 0, 255); + public int convertYCbCrtoRGB(final int Y, final int Cb, final int Cr) { + final double r1 = (((1.164 * (Y - 16.0))) + (1.596 * (Cr - 128.0))); + final double g1 = (((1.164 * (Y - 16.0))) - (0.813 * (Cr - 128.0)) - (0.392 * (Cb - 128.0))); + final double b1 = (((1.164 * (Y - 16.0))) + (2.017 * (Cb - 128.0))); + + final int r = limit((int) r1, 0, 255); + final int g = limit((int) g1, 0, 255); + final int b = limit((int) b1, 0, 255); - int alpha = 0xff; - int rgb = (alpha << 24) | (r << 16) | (g << 8) | (b << 0); + final int alpha = 0xff; + final int rgb = (alpha << 24) | (r << 16) | (g << 8) | (b << 0); return rgb; } @Override - public void interpretPixel(ImageBuilder imageBuilder, int samples[], int x, - int y) throws ImageReadException, IOException { - int Y = samples[0]; - int Cb = samples[1]; - int Cr = samples[2]; - double R = Y + 1.402 * (Cr - 128.0); - double G = Y - 0.34414 * (Cb - 128.0) - 0.71414 * (Cr - 128.0); - double B = Y + 1.772 * (Cb - 128.0); - - int red = limit((int) R, 0, 255); - int green = limit((int) G, 0, 255); - int blue = limit((int) B, 0, 255); + public void interpretPixel(final ImageBuilder imageBuilder, final int samples[], final int x, + final int y) throws ImageReadException, IOException { + final int Y = samples[0]; + final int Cb = samples[1]; + final int Cr = samples[2]; + final double R = Y + 1.402 * (Cr - 128.0); + final double G = Y - 0.34414 * (Cb - 128.0) - 0.71414 * (Cr - 128.0); + final double B = Y + 1.772 * (Cb - 128.0); + + final int red = limit((int) R, 0, 255); + final int green = limit((int) G, 0, 255); + final int blue = limit((int) B, 0, 255); - int alpha = 0xff; - int rgb = (alpha << 24) | (red << 16) | (green << 8) | (blue << 0); + final int alpha = 0xff; + final int rgb = (alpha << 24) | (red << 16) | (green << 8) | (blue << 0); imageBuilder.setRGB(x, y, rgb); } Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfo.java URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfo.java?rev=1417043&r1=1417042&r2=1417043&view=diff ============================================================================== --- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfo.java (original) +++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfo.java Tue Dec 4 17:23:16 2012 @@ -35,23 +35,23 @@ public abstract class TagInfo implements TiffFieldTypeConstants { public static final int LENGTH_UNKNOWN = -1; - public TagInfo(String name, int tag, FieldType dataType, int length, - TiffDirectoryType exifDirectory) { + public TagInfo(final String name, final int tag, final FieldType dataType, final int length, + final TiffDirectoryType exifDirectory) { this(name, tag, Arrays.asList(dataType), length, exifDirectory); } - public TagInfo(String name, int tag, FieldType dataType, int length, - TiffDirectoryType exifDirectory, boolean isOffset) { + public TagInfo(final String name, final int tag, final FieldType dataType, final int length, + final TiffDirectoryType exifDirectory, final boolean isOffset) { this(name, tag, Arrays.asList(dataType), length, exifDirectory, isOffset); } - public TagInfo(String name, int tag, FieldType dataType, int length) { + public TagInfo(final String name, final int tag, final FieldType dataType, final int length) { this(name, tag, Arrays.asList(dataType), length, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); } - public TagInfo(String name, int tag, FieldType dataType) { + public TagInfo(final String name, final int tag, final FieldType dataType) { this(name, tag, dataType, LENGTH_UNKNOWN, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); } @@ -63,13 +63,13 @@ public abstract class TagInfo implements public final TiffDirectoryType directoryType; private final boolean isOffset; - public TagInfo(String name, int tag, List dataTypes, int length, - TiffDirectoryType exifDirectory) { + public TagInfo(final String name, final int tag, final List dataTypes, final int length, + final TiffDirectoryType exifDirectory) { this(name, tag, dataTypes, length, exifDirectory, false); } - public TagInfo(String name, int tag, List dataTypes, int length, - TiffDirectoryType exifDirectory, boolean isOffset) { + public TagInfo(final String name, final int tag, final List dataTypes, final int length, + final TiffDirectoryType exifDirectory, final boolean isOffset) { this.name = name; this.tag = tag; this.dataTypes = Collections.unmodifiableList(new ArrayList( @@ -79,12 +79,12 @@ public abstract class TagInfo implements this.isOffset = isOffset; } - public Object getValue(TiffField entry) throws ImageReadException { - Object o = entry.fieldType.getSimpleValue(entry); + public Object getValue(final TiffField entry) throws ImageReadException { + final Object o = entry.fieldType.getSimpleValue(entry); return o; } - public byte[] encodeValue(FieldType fieldType, Object value, ByteOrder byteOrder) + public byte[] encodeValue(final FieldType fieldType, final Object value, final ByteOrder byteOrder) throws ImageWriteException { return fieldType.writeData(value, byteOrder); } Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoAny.java URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoAny.java?rev=1417043&r1=1417042&r2=1417043&view=diff ============================================================================== --- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoAny.java (original) +++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoAny.java Tue Dec 4 17:23:16 2012 @@ -19,8 +19,8 @@ package org.apache.commons.imaging.forma import org.apache.commons.imaging.formats.tiff.constants.TiffDirectoryType; public class TagInfoAny extends TagInfo { - public TagInfoAny(String name, int tag, int length, - TiffDirectoryType directoryType) { + public TagInfoAny(final String name, final int tag, final int length, + final TiffDirectoryType directoryType) { super(name, tag, FIELD_TYPE_ANY, length, directoryType); } } Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoAscii.java URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoAscii.java?rev=1417043&r1=1417042&r2=1417043&view=diff ============================================================================== --- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoAscii.java (original) +++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoAscii.java Tue Dec 4 17:23:16 2012 @@ -23,19 +23,19 @@ import org.apache.commons.imaging.common import org.apache.commons.imaging.formats.tiff.constants.TiffDirectoryType; public class TagInfoAscii extends TagInfo { - public TagInfoAscii(String name, int tag, int length, - TiffDirectoryType directoryType) { + public TagInfoAscii(final String name, final int tag, final int length, + final TiffDirectoryType directoryType) { super(name, tag, FIELD_TYPE_ASCII, length, directoryType); } - public String[] getValue(ByteOrder byteOrder, byte[] bytes) { + public String[] getValue(final ByteOrder byteOrder, final byte[] bytes) { int nullCount = 1; for (int i = 0; i < bytes.length - 1; i++) { if (bytes[i] == 0) { nullCount++; } } - String[] strings = new String[nullCount + 1]; + final String[] strings = new String[nullCount + 1]; int stringsAdded = 0; strings[0] = ""; // if we have a 0 length string int nextStringPos = 0; @@ -45,10 +45,10 @@ public class TagInfoAscii extends TagInf for (int i = 0; i < bytes.length; i++) { if (bytes[i] == 0) { try { - String string = new String(bytes, nextStringPos, i + final String string = new String(bytes, nextStringPos, i - nextStringPos, "UTF-8"); strings[stringsAdded++] = string; - } catch (UnsupportedEncodingException unsupportedEncoding) { + } catch (final UnsupportedEncodingException unsupportedEncoding) { } nextStringPos = i + 1; } @@ -56,16 +56,16 @@ public class TagInfoAscii extends TagInf if (nextStringPos < bytes.length) { // Buggy file, string wasn't null terminated try { - String string = new String(bytes, nextStringPos, bytes.length + final String string = new String(bytes, nextStringPos, bytes.length - nextStringPos, "UTF-8"); strings[stringsAdded++] = string; - } catch (UnsupportedEncodingException unsupportedEncoding) { + } catch (final UnsupportedEncodingException unsupportedEncoding) { } } return strings; } - public byte[] encodeValue(ByteOrder byteOrder, String... values) + public byte[] encodeValue(final ByteOrder byteOrder, final String... values) throws ImageWriteException { return FIELD_TYPE_ASCII.writeData(values, byteOrder); } Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoAsciiOrByte.java URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoAsciiOrByte.java?rev=1417043&r1=1417042&r2=1417043&view=diff ============================================================================== --- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoAsciiOrByte.java (original) +++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoAsciiOrByte.java Tue Dec 4 17:23:16 2012 @@ -19,8 +19,8 @@ package org.apache.commons.imaging.forma import org.apache.commons.imaging.formats.tiff.constants.TiffDirectoryType; public class TagInfoAsciiOrByte extends TagInfo { - public TagInfoAsciiOrByte(String name, int tag, int length, - TiffDirectoryType directoryType) { + public TagInfoAsciiOrByte(final String name, final int tag, final int length, + final TiffDirectoryType directoryType) { super(name, tag, FIELD_TYPE_DESCRIPTION_ASCII_OR_BYTE, length, directoryType, false); } Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoAsciiOrRational.java URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoAsciiOrRational.java?rev=1417043&r1=1417042&r2=1417043&view=diff ============================================================================== --- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoAsciiOrRational.java (original) +++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoAsciiOrRational.java Tue Dec 4 17:23:16 2012 @@ -19,8 +19,8 @@ package org.apache.commons.imaging.forma import org.apache.commons.imaging.formats.tiff.constants.TiffDirectoryType; public class TagInfoAsciiOrRational extends TagInfo { - public TagInfoAsciiOrRational(String name, int tag, int length, - TiffDirectoryType directoryType) { + public TagInfoAsciiOrRational(final String name, final int tag, final int length, + final TiffDirectoryType directoryType) { super(name, tag, FIELD_TYPE_DESCRIPTION_ASCII_OR_RATIONAL, length, directoryType, false); } Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoByte.java URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoByte.java?rev=1417043&r1=1417042&r2=1417043&view=diff ============================================================================== --- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoByte.java (original) +++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoByte.java Tue Dec 4 17:23:16 2012 @@ -23,16 +23,16 @@ import org.apache.commons.imaging.format import org.apache.commons.imaging.formats.tiff.fieldtypes.FieldType; public class TagInfoByte extends TagInfo { - public TagInfoByte(String name, int tag, int length, TiffDirectoryType directoryType) { + public TagInfoByte(final String name, final int tag, final int length, final TiffDirectoryType directoryType) { super(name, tag, FIELD_TYPE_BYTE, length, directoryType); } - public TagInfoByte(String name, int tag, List fieldTypes, - int length, TiffDirectoryType directoryType) { + public TagInfoByte(final String name, final int tag, final List fieldTypes, + final int length, final TiffDirectoryType directoryType) { super(name, tag, fieldTypes, length, directoryType); } - public byte[] encodeValue(ByteOrder byteOrder, byte... values) { + public byte[] encodeValue(final ByteOrder byteOrder, final byte... values) { return values; } } Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoByteOrShort.java URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoByteOrShort.java?rev=1417043&r1=1417042&r2=1417043&view=diff ============================================================================== --- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoByteOrShort.java (original) +++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoByteOrShort.java Tue Dec 4 17:23:16 2012 @@ -21,15 +21,15 @@ import org.apache.commons.imaging.common import org.apache.commons.imaging.formats.tiff.constants.TiffDirectoryType; public class TagInfoByteOrShort extends TagInfo { - public TagInfoByteOrShort(String name, int tag, int length, TiffDirectoryType directoryType) { + public TagInfoByteOrShort(final String name, final int tag, final int length, final TiffDirectoryType directoryType) { super(name, tag, FIELD_TYPE_DESCRIPTION_BYTE_OR_SHORT, length, directoryType); } - public byte[] encodeValue(ByteOrder byteOrder, byte... values) { + public byte[] encodeValue(final ByteOrder byteOrder, final byte... values) { return values; } - public byte[] encodeValue(ByteOrder byteOrder, short... values) { + public byte[] encodeValue(final ByteOrder byteOrder, final short... values) { return BinaryConversions.toBytes(values, byteOrder); } } Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoDouble.java URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoDouble.java?rev=1417043&r1=1417042&r2=1417043&view=diff ============================================================================== --- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoDouble.java (original) +++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoDouble.java Tue Dec 4 17:23:16 2012 @@ -22,15 +22,15 @@ import org.apache.commons.imaging.common import org.apache.commons.imaging.formats.tiff.constants.TiffDirectoryType; public class TagInfoDouble extends TagInfo { - public TagInfoDouble(String name, int tag, int length, TiffDirectoryType directoryType) { + public TagInfoDouble(final String name, final int tag, final int length, final TiffDirectoryType directoryType) { super(name, tag, FIELD_TYPE_DOUBLE, length, directoryType); } - public double[] getValue(ByteOrder byteOrder, byte[] bytes) { + public double[] getValue(final ByteOrder byteOrder, final byte[] bytes) { return BinaryConversions.toDoubles(bytes, byteOrder); } - public byte[] encodeValue(ByteOrder byteOrder, double... values) throws ImageWriteException { + public byte[] encodeValue(final ByteOrder byteOrder, final double... values) throws ImageWriteException { return BinaryConversions.toBytes(values, byteOrder); } } Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoFloat.java URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoFloat.java?rev=1417043&r1=1417042&r2=1417043&view=diff ============================================================================== --- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoFloat.java (original) +++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoFloat.java Tue Dec 4 17:23:16 2012 @@ -22,15 +22,15 @@ import org.apache.commons.imaging.common import org.apache.commons.imaging.formats.tiff.constants.TiffDirectoryType; public class TagInfoFloat extends TagInfo { - public TagInfoFloat(String name, int tag, int length, TiffDirectoryType directoryType) { + public TagInfoFloat(final String name, final int tag, final int length, final TiffDirectoryType directoryType) { super(name, tag, FIELD_TYPE_FLOAT, length, directoryType); } - public float[] getValue(ByteOrder byteOrder, byte[] bytes) { + public float[] getValue(final ByteOrder byteOrder, final byte[] bytes) { return BinaryConversions.toFloats(bytes, byteOrder); } - public byte[] encodeValue(ByteOrder byteOrder, float... values) throws ImageWriteException { + public byte[] encodeValue(final ByteOrder byteOrder, final float... values) throws ImageWriteException { return BinaryConversions.toBytes(values, byteOrder); } } Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoGpsText.java URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoGpsText.java?rev=1417043&r1=1417042&r2=1417043&view=diff ============================================================================== --- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoGpsText.java (original) +++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoGpsText.java Tue Dec 4 17:23:16 2012 @@ -28,8 +28,8 @@ import org.apache.commons.imaging.format import org.apache.commons.imaging.util.Debug; public final class TagInfoGpsText extends TagInfo { - public TagInfoGpsText(String name, int tag, FieldType dataType, int length, - TiffDirectoryType exifDirectory) { + public TagInfoGpsText(final String name, final int tag, final FieldType dataType, final int length, + final TiffDirectoryType exifDirectory) { super(name, tag, dataType, length, exifDirectory); } @@ -50,7 +50,7 @@ public final class TagInfoGpsText extend this.encodingNameBE = encodingNameBE; } - public String getEncodingName(ByteOrder byteOrder) { + public String getEncodingName(final ByteOrder byteOrder) { if (byteOrder == ByteOrder.BIG_ENDIAN) { return encodingNameBE; } else { @@ -81,23 +81,23 @@ public final class TagInfoGpsText extend }; @Override - public byte[] encodeValue(FieldType fieldType, Object value, ByteOrder byteOrder) + public byte[] encodeValue(final FieldType fieldType, final Object value, final ByteOrder byteOrder) throws ImageWriteException { if (!(value instanceof String)) { throw new ImageWriteException("GPS text value not String: " + value + " (" + Debug.getType(value) + ")"); } - String s = (String) value; + final String s = (String) value; try { // try ASCII, with NO prefix. - byte asciiBytes[] = s.getBytes(TEXT_ENCODING_ASCII + final byte asciiBytes[] = s.getBytes(TEXT_ENCODING_ASCII .getEncodingName(byteOrder)); - String decodedAscii = new String(asciiBytes, + final String decodedAscii = new String(asciiBytes, TEXT_ENCODING_ASCII.getEncodingName(byteOrder)); if (decodedAscii.equals(s)) { // no unicode/non-ascii values. - byte result[] = new byte[asciiBytes.length + final byte result[] = new byte[asciiBytes.length + TEXT_ENCODING_ASCII.prefix.length]; System.arraycopy(TEXT_ENCODING_ASCII.prefix, 0, result, 0, TEXT_ENCODING_ASCII.prefix.length); @@ -106,9 +106,9 @@ public final class TagInfoGpsText extend return result; } else { // use unicode - byte unicodeBytes[] = s.getBytes(TEXT_ENCODING_UNICODE + final byte unicodeBytes[] = s.getBytes(TEXT_ENCODING_UNICODE .getEncodingName(byteOrder)); - byte result[] = new byte[unicodeBytes.length + final byte result[] = new byte[unicodeBytes.length + TEXT_ENCODING_UNICODE.prefix.length]; System.arraycopy(TEXT_ENCODING_UNICODE.prefix, 0, result, 0, TEXT_ENCODING_UNICODE.prefix.length); @@ -117,15 +117,15 @@ public final class TagInfoGpsText extend unicodeBytes.length); return result; } - } catch (UnsupportedEncodingException e) { + } catch (final UnsupportedEncodingException e) { throw new ImageWriteException(e.getMessage(), e); } } @Override - public String getValue(TiffField entry) throws ImageReadException { + public String getValue(final TiffField entry) throws ImageReadException { if (entry.type == FIELD_TYPE_ASCII.type) { - Object object = FIELD_TYPE_ASCII.getSimpleValue(entry); + final Object object = FIELD_TYPE_ASCII.getSimpleValue(entry); if (object instanceof String) { return (String) object; } else if (object instanceof String[]) { @@ -150,25 +150,25 @@ public final class TagInfoGpsText extend throw new ImageReadException("GPS text field not encoded as bytes."); } - byte bytes[] = entry.fieldType.getRawBytes(entry); + final byte bytes[] = entry.fieldType.getRawBytes(entry); if (bytes.length < 8) { try { // try ASCII, with NO prefix. return new String(bytes, "US-ASCII"); - } catch (UnsupportedEncodingException e) { + } catch (final UnsupportedEncodingException e) { throw new ImageReadException( "GPS text field missing encoding prefix."); } } - for (TextEncoding encoding : TEXT_ENCODINGS) { + for (final TextEncoding encoding : TEXT_ENCODINGS) { if (BinaryFileFunctions.compareBytes(bytes, 0, encoding.prefix, 0, encoding.prefix.length)) { try { return new String(bytes, encoding.prefix.length, bytes.length - encoding.prefix.length, encoding.getEncodingName(entry.byteOrder)); - } catch (UnsupportedEncodingException e) { + } catch (final UnsupportedEncodingException e) { throw new ImageReadException(e.getMessage(), e); } } @@ -177,7 +177,7 @@ public final class TagInfoGpsText extend try { // try ASCII, with NO prefix. return new String(bytes, "US-ASCII"); - } catch (UnsupportedEncodingException e) { + } catch (final UnsupportedEncodingException e) { throw new ImageReadException("Unknown GPS text encoding prefix."); } Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoLong.java URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoLong.java?rev=1417043&r1=1417042&r2=1417043&view=diff ============================================================================== --- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoLong.java (original) +++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoLong.java Tue Dec 4 17:23:16 2012 @@ -22,19 +22,19 @@ import org.apache.commons.imaging.format public class TagInfoLong extends TagInfo { - public TagInfoLong(String name, int tag, int length, TiffDirectoryType directoryType) { + public TagInfoLong(final String name, final int tag, final int length, final TiffDirectoryType directoryType) { super(name, tag, FIELD_TYPE_LONG, length, directoryType); } - public TagInfoLong(String name, int tag, int length, TiffDirectoryType directoryType, boolean isOffset) { + public TagInfoLong(final String name, final int tag, final int length, final TiffDirectoryType directoryType, final boolean isOffset) { super(name, tag, FIELD_TYPE_LONG, length, directoryType, isOffset); } - public int[] getValue(ByteOrder byteOrder, byte[] bytes) { + public int[] getValue(final ByteOrder byteOrder, final byte[] bytes) { return BinaryConversions.toInts(bytes, byteOrder); } - public byte[] encodeValue(ByteOrder byteOrder, int... values) { + public byte[] encodeValue(final ByteOrder byteOrder, final int... values) { return BinaryConversions.toBytes(values, byteOrder); } } Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoRational.java URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoRational.java?rev=1417043&r1=1417042&r2=1417043&view=diff ============================================================================== --- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoRational.java (original) +++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoRational.java Tue Dec 4 17:23:16 2012 @@ -22,15 +22,15 @@ import org.apache.commons.imaging.common import org.apache.commons.imaging.formats.tiff.constants.TiffDirectoryType; public class TagInfoRational extends TagInfo { - public TagInfoRational(String name, int tag, int length, TiffDirectoryType directoryType) { + public TagInfoRational(final String name, final int tag, final int length, final TiffDirectoryType directoryType) { super(name, tag, FIELD_TYPE_RATIONAL, length, directoryType); } - public RationalNumber[] getValue(ByteOrder byteOrder, byte[] bytes) { + public RationalNumber[] getValue(final ByteOrder byteOrder, final byte[] bytes) { return BinaryConversions.toRationals(bytes, byteOrder); } - public byte[] encodeValue(ByteOrder byteOrder, RationalNumber... values) { + public byte[] encodeValue(final ByteOrder byteOrder, final RationalNumber... values) { return BinaryConversions.toBytes(values, byteOrder); } } Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoSByte.java URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoSByte.java?rev=1417043&r1=1417042&r2=1417043&view=diff ============================================================================== --- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoSByte.java (original) +++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoSByte.java Tue Dec 4 17:23:16 2012 @@ -20,11 +20,11 @@ import org.apache.commons.imaging.common import org.apache.commons.imaging.formats.tiff.constants.TiffDirectoryType; public class TagInfoSByte extends TagInfo { - public TagInfoSByte(String name, int tag, int length, TiffDirectoryType directoryType) { + public TagInfoSByte(final String name, final int tag, final int length, final TiffDirectoryType directoryType) { super(name, tag, FIELD_TYPE_SBYTE, length, directoryType); } - public byte[] encodeValue(ByteOrder byteOrder, byte... values) { + public byte[] encodeValue(final ByteOrder byteOrder, final byte... values) { return values; } } Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoSLong.java URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoSLong.java?rev=1417043&r1=1417042&r2=1417043&view=diff ============================================================================== --- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoSLong.java (original) +++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoSLong.java Tue Dec 4 17:23:16 2012 @@ -22,15 +22,15 @@ import org.apache.commons.imaging.common import org.apache.commons.imaging.formats.tiff.constants.TiffDirectoryType; public class TagInfoSLong extends TagInfo { - public TagInfoSLong(String name, int tag, int length, TiffDirectoryType directoryType) { + public TagInfoSLong(final String name, final int tag, final int length, final TiffDirectoryType directoryType) { super(name, tag, FIELD_TYPE_SLONG, length, directoryType); } - public int[] getValue(ByteOrder byteOrder, byte[] bytes) { + public int[] getValue(final ByteOrder byteOrder, final byte[] bytes) { return BinaryConversions.toInts(bytes, byteOrder); } - public byte[] encodeValue(ByteOrder byteOrder, int... values) throws ImageWriteException { + public byte[] encodeValue(final ByteOrder byteOrder, final int... values) throws ImageWriteException { return BinaryConversions.toBytes(values, byteOrder); } }