commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dam...@apache.org
Subject svn commit: r1544840 [2/3] - in /commons/proper/imaging/trunk: ./ src/main/java/org/apache/commons/imaging/ src/main/java/org/apache/commons/imaging/color/ src/main/java/org/apache/commons/imaging/common/ src/main/java/org/apache/commons/imaging/common...
Date Sat, 23 Nov 2013 17:19:38 GMT
Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/dcx/DcxImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/dcx/DcxImageParser.java?rev=1544840&r1=1544839&r2=1544840&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/dcx/DcxImageParser.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/dcx/DcxImageParser.java Sat Nov 23 17:19:36 2013
@@ -46,6 +46,8 @@ import org.apache.commons.imaging.util.I
 
 public class DcxImageParser extends ImageParser {
     // See http://www.fileformat.info/format/pcx/egff.htm for documentation
+    private static final String DEFAULT_EXTENSION = ".dcx";
+    private static final String ACCEPTED_EXTENSIONS[] = { ".dcx", };
 
     public DcxImageParser() {
         super.setByteOrder(ByteOrder.INTEL);
@@ -61,9 +63,6 @@ public class DcxImageParser extends Imag
         return DEFAULT_EXTENSION;
     }
 
-    private static final String DEFAULT_EXTENSION = ".dcx";
-    private static final String ACCEPTED_EXTENSIONS[] = { ".dcx", };
-
     @Override
     protected String[] getAcceptedExtensions() {
         return ACCEPTED_EXTENSIONS;
@@ -236,7 +235,7 @@ public class DcxImageParser extends Imag
         }
 
 
-        if (params.size() > 0) {
+        if (!params.isEmpty()) {
             final Object firstKey = params.keySet().iterator().next();
             throw new ImageWriteException("Unknown parameter: " + firstKey);
         }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/gif/GifImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/gif/GifImageParser.java?rev=1544840&r1=1544839&r2=1544840&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/gif/GifImageParser.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/gif/GifImageParser.java Sat Nov 23 17:19:36 2013
@@ -50,6 +50,35 @@ import org.apache.commons.imaging.util.I
 import org.apache.commons.imaging.util.ParamMap;
 
 public class GifImageParser extends ImageParser {
+    private static final String DEFAULT_EXTENSION = ".gif";
+    private static final String ACCEPTED_EXTENSIONS[] = { DEFAULT_EXTENSION, };
+    private static final byte GIF_HEADER_SIGNATURE[] = { 71, 73, 70 };
+    private final static int EXTENSION_CODE = 0x21;
+    private final static int IMAGE_SEPARATOR = 0x2C;
+    private final static int GRAPHIC_CONTROL_EXTENSION = (EXTENSION_CODE << 8) | 0xf9;
+    private final static int COMMENT_EXTENSION = 0xfe;
+    private final static int PLAIN_TEXT_EXTENSION = 0x01;
+    private final static int XMP_EXTENSION = 0xff;
+    private final static int TERMINATOR_BYTE = 0x3b;
+    private final static int APPLICATION_EXTENSION_LABEL = 0xff;
+    private final static int XMP_COMPLETE_CODE = (EXTENSION_CODE << 8)
+            | XMP_EXTENSION;
+    private static final int LOCAL_COLOR_TABLE_FLAG_MASK = 1 << 7;
+    private static final int INTERLACE_FLAG_MASK = 1 << 6;
+    private static final int SORT_FLAG_MASK = 1 << 5;
+    private static final byte XMP_APPLICATION_ID_AND_AUTH_CODE[] = {
+        0x58, // X
+        0x4D, // M
+        0x50, // P
+        0x20, //
+        0x44, // D
+        0x61, // a
+        0x74, // t
+        0x61, // a
+        0x58, // X
+        0x4D, // M
+        0x50, // P
+    };
 
     public GifImageParser() {
         super.setByteOrder(ByteOrder.LITTLE_ENDIAN);
@@ -65,10 +94,6 @@ public class GifImageParser extends Imag
         return DEFAULT_EXTENSION;
     }
 
-    private static final String DEFAULT_EXTENSION = ".gif";
-
-    private static final String ACCEPTED_EXTENSIONS[] = { DEFAULT_EXTENSION, };
-
     @Override
     protected String[] getAcceptedExtensions() {
         return ACCEPTED_EXTENSIONS;
@@ -80,8 +105,6 @@ public class GifImageParser extends Imag
         };
     }
 
-    private static final byte GIF_HEADER_SIGNATURE[] = { 71, 73, 70 };
-
     private GifHeaderInfo readHeader(final InputStream is,
             final FormatCompliance formatCompliance) throws ImageReadException,
             IOException {
@@ -217,17 +240,6 @@ public class GifImageParser extends Imag
         return new GenericGifBlock(code, subblocks);
     }
 
-    private final static int EXTENSION_CODE = 0x21;
-    private final static int IMAGE_SEPARATOR = 0x2C;
-    private final static int GRAPHIC_CONTROL_EXTENSION = (EXTENSION_CODE << 8) | 0xf9;
-    private final static int COMMENT_EXTENSION = 0xfe;
-    private final static int PLAIN_TEXT_EXTENSION = 0x01;
-    private final static int XMP_EXTENSION = 0xff;
-    private final static int TERMINATOR_BYTE = 0x3b;
-    private final static int APPLICATION_EXTENSION_LABEL = 0xff;
-    private final static int XMP_COMPLETE_CODE = (EXTENSION_CODE << 8)
-            | XMP_EXTENSION;
-
     private List<GifBlock> readBlocks(final GifHeaderInfo ghi, final InputStream is,
             final boolean stopBeforeImageData, final FormatCompliance formatCompliance)
             throws ImageReadException, IOException {
@@ -776,10 +788,6 @@ public class GifImageParser extends Imag
         os.write(0); // last block
     }
 
-    private static final int LOCAL_COLOR_TABLE_FLAG_MASK = 1 << 7;
-    private static final int INTERLACE_FLAG_MASK = 1 << 6;
-    private static final int SORT_FLAG_MASK = 1 << 5;
-
     @Override
     public void writeImage(final BufferedImage src, final OutputStream os, Map<String,Object> params)
             throws ImageWriteException, IOException {
@@ -803,7 +811,7 @@ public class GifImageParser extends Imag
             params.remove(PARAM_KEY_XMP_XML);
         }
 
-        if (params.size() > 0) {
+        if (!params.isEmpty()) {
             final Object firstKey = params.keySet().iterator().next();
             throw new ImageWriteException("Unknown parameter: " + firstKey);
         }
@@ -1023,19 +1031,6 @@ public class GifImageParser extends Imag
         os.close();
     }
 
-    private static final byte XMP_APPLICATION_ID_AND_AUTH_CODE[] = { 0x58, // X
-            0x4D, // M
-            0x50, // P
-            0x20, //
-            0x44, // D
-            0x61, // a
-            0x74, // t
-            0x61, // a
-            0x58, // X
-            0x4D, // M
-            0x50, // P
-    };
-
     /**
      * Extracts embedded XML metadata as XML string.
      * <p>

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/icns/IcnsDecoder.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/icns/IcnsDecoder.java?rev=1544840&r1=1544839&r2=1544840&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/icns/IcnsDecoder.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/icns/IcnsDecoder.java Sat Nov 23 17:19:36 2013
@@ -24,7 +24,7 @@ import org.apache.commons.imaging.ImageR
 import org.apache.commons.imaging.common.ImageBuilder;
 import org.apache.commons.imaging.formats.icns.IcnsImageParser.IcnsElement;
 
-public class IcnsDecoder {
+public final class IcnsDecoder {
     private static final int[] palette_4bpp = { 0xffffffff, 0xfffcf305,
             0xffff6402, 0xffdd0806, 0xfff20884, 0xff4600a5, 0xff0000d4,
             0xff02abea, 0xff1fb714, 0xff006411, 0xff562c05, 0xff90713a,
@@ -83,6 +83,9 @@ public class IcnsDecoder {
             0xFFBBBBBB, 0xFFAAAAAA, 0xFF888888, 0xFF777777, 0xFF555555,
             0xFF444444, 0xFF222222, 0xFF111111, 0xFF000000 };
 
+    private IcnsDecoder() {
+    }
+
     private static void decode1BPPImage(final IcnsType imageType, final byte[] imageData,
             final ImageBuilder image) {
         int position = 0;

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/icns/IcnsImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/icns/IcnsImageParser.java?rev=1544840&r1=1544839&r2=1544840&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/icns/IcnsImageParser.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/icns/IcnsImageParser.java Sat Nov 23 17:19:36 2013
@@ -43,6 +43,8 @@ import org.apache.commons.imaging.util.P
 
 public class IcnsImageParser extends ImageParser {
     public static final int ICNS_MAGIC = IcnsType.typeAsInt("icns");
+    private static final String DEFAULT_EXTENSION = ".icns";
+    private static final String ACCEPTED_EXTENSIONS[] = { ".icns", };
 
     public IcnsImageParser() {
         super.setByteOrder(ByteOrder.BIG_ENDIAN);
@@ -58,10 +60,6 @@ public class IcnsImageParser extends Ima
         return DEFAULT_EXTENSION;
     }
 
-    private static final String DEFAULT_EXTENSION = ".icns";
-
-    private static final String ACCEPTED_EXTENSIONS[] = { ".icns", };
-
     @Override
     protected String[] getAcceptedExtensions() {
         return ACCEPTED_EXTENSIONS;
@@ -95,7 +93,7 @@ public class IcnsImageParser extends Ima
             params.remove(PARAM_KEY_VERBOSE);
         }
 
-        if (params.size() > 0) {
+        if (!params.isEmpty()) {
             final Object firstKey = params.keySet().iterator().next();
             throw new ImageReadException("Unknown parameter: " + firstKey);
         }
@@ -127,7 +125,7 @@ public class IcnsImageParser extends Ima
             params.remove(PARAM_KEY_VERBOSE);
         }
 
-        if (params.size() > 0) {
+        if (!params.isEmpty()) {
             final Object firstKey = params.keySet().iterator().next();
             throw new ImageReadException("Unknown parameter: " + firstKey);
         }
@@ -282,7 +280,7 @@ public class IcnsImageParser extends Ima
         final IcnsContents icnsContents = readImage(byteSource);
         final List<BufferedImage> result = IcnsDecoder
                 .decodeAllImages(icnsContents.icnsElements);
-        if (result.size() > 0) {
+        if (!result.isEmpty()) {
             return result.get(0);
         }
         throw new ImageReadException("No icons in ICNS file");
@@ -306,7 +304,7 @@ public class IcnsImageParser extends Ima
             params.remove(PARAM_KEY_FORMAT);
         }
 
-        if (params.size() > 0) {
+        if (!params.isEmpty()) {
             final Object firstKey = params.keySet().iterator().next();
             throw new ImageWriteException("Unknown parameter: " + firstKey);
         }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/icns/IcnsType.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/icns/IcnsType.java?rev=1544840&r1=1544839&r2=1544840&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/icns/IcnsType.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/icns/IcnsType.java Sat Nov 23 17:19:36 2013
@@ -18,7 +18,7 @@ package org.apache.commons.imaging.forma
 
 import java.io.UnsupportedEncodingException;
 
-public class IcnsType {
+public final class IcnsType {
     private final int type;
     private final int width;
     private final int height;
@@ -178,8 +178,8 @@ public class IcnsType {
         byte[] bytes = null;
         try {
             bytes = type.getBytes("US-ASCII");
-        } catch (final UnsupportedEncodingException cannotHappen) {
-            throw new IllegalArgumentException("Your Java doesn't support US-ASCII");
+        } catch (final UnsupportedEncodingException unsupportedEncodingException) {
+            throw new IllegalArgumentException("Your Java doesn't support US-ASCII", unsupportedEncodingException);
         }
         if (bytes.length != 4) {
             throw new IllegalArgumentException("Invalid ICNS type");
@@ -196,8 +196,8 @@ public class IcnsType {
         bytes[3] = (byte) (0xff & type);
         try {
             return new String(bytes, "US-ASCII");
-        } catch (final UnsupportedEncodingException cannotHappen) {
+        } catch (final UnsupportedEncodingException unsupportedEncodingException) {
+            throw new IllegalArgumentException("Your Java doesn't support US-ASCII", unsupportedEncodingException);
         }
-        return null;
     }
 }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/icns/Rle24Compression.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/icns/Rle24Compression.java?rev=1544840&r1=1544839&r2=1544840&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/icns/Rle24Compression.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/icns/Rle24Compression.java Sat Nov 23 17:19:36 2013
@@ -16,7 +16,10 @@
  */
 package org.apache.commons.imaging.formats.icns;
 
-class Rle24Compression {
+final class Rle24Compression {
+    private Rle24Compression() {
+    }
+    
     public static byte[] decompress(final int width, final int height, final byte[] data) {
         final int pixelCount = width * height;
         final byte[] result = new byte[4 * pixelCount];

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/ico/IcoImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/ico/IcoImageParser.java?rev=1544840&r1=1544839&r2=1544840&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/ico/IcoImageParser.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/ico/IcoImageParser.java Sat Nov 23 17:19:36 2013
@@ -48,6 +48,8 @@ import org.apache.commons.imaging.palett
 import org.apache.commons.imaging.util.IoUtils;
 
 public class IcoImageParser extends ImageParser {
+    private static final String DEFAULT_EXTENSION = ".ico";
+    private static final String ACCEPTED_EXTENSIONS[] = { ".ico", ".cur", };
 
     public IcoImageParser() {
         super.setByteOrder(ByteOrder.LITTLE_ENDIAN);
@@ -63,10 +65,6 @@ public class IcoImageParser extends Imag
         return DEFAULT_EXTENSION;
     }
 
-    private static final String DEFAULT_EXTENSION = ".ico";
-
-    private static final String ACCEPTED_EXTENSIONS[] = { ".ico", ".cur", };
-
     @Override
     protected String[] getAcceptedExtensions() {
         return ACCEPTED_EXTENSIONS;
@@ -661,7 +659,7 @@ public class IcoImageParser extends Imag
         
         final PixelDensity pixelDensity = (PixelDensity) params.remove(PARAM_KEY_PIXEL_DENSITY);
 
-        if (params.size() > 0) {
+        if (!params.isEmpty()) {
             final Object firstKey = params.keySet().iterator().next();
             throw new ImageWriteException("Unknown parameter: " + firstKey);
         }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegConstants.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegConstants.java?rev=1544840&r1=1544839&r2=1544840&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegConstants.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegConstants.java Sat Nov 23 17:19:36 2013
@@ -23,7 +23,7 @@ import java.util.List;
 import org.apache.commons.imaging.common.BinaryConstant;
 import org.apache.commons.imaging.common.BinaryFunctions;
 
-public class JpegConstants {
+public final class JpegConstants {
     public static final int MAX_SEGMENT_SIZE = 0xffff;
 
     public static final BinaryConstant JFIF0_SIGNATURE = new BinaryConstant(
@@ -147,4 +147,7 @@ public class JpegConstants {
                     0x30, // 0
                     0, });
     public static final int CONST_8BIM = BinaryFunctions.charsToQuad('8', 'B', 'I', 'M');
+    
+    private JpegConstants() {
+    }
 }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegImageMetadata.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegImageMetadata.java?rev=1544840&r1=1544839&r2=1544840&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegImageMetadata.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegImageMetadata.java Sat Nov 23 17:19:36 2013
@@ -39,6 +39,7 @@ import org.apache.commons.imaging.util.D
 public class JpegImageMetadata implements IImageMetadata {
     private final JpegPhotoshopMetadata photoshop;
     private final TiffImageMetadata exif;
+    private static final String newline = System.getProperty("line.separator");
 
     public JpegImageMetadata(final JpegPhotoshopMetadata photoshop,
             final TiffImageMetadata exif) {
@@ -149,7 +150,9 @@ public class JpegImageMetadata implement
                     image = Imaging.getBufferedImage(jpegImageData.data);
                     imageSucceeded = true;
                 } catch (final ImagingException imagingException) {
+                    // NOPMD
                 } catch (final IOException ioException) {
+                    // NOPMD
                 } finally {
                     // our JPEG reading is still a bit buggy -
                     // fall back to ImageIO on error
@@ -200,8 +203,6 @@ public class JpegImageMetadata implement
         return result;
     }
 
-    private static final String newline = System.getProperty("line.separator");
-
     @Override
     public String toString() {
         return toString(null);

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegImageParser.java?rev=1544840&r1=1544839&r2=1544840&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegImageParser.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegImageParser.java Sat Nov 23 17:19:36 2013
@@ -59,6 +59,10 @@ import org.apache.commons.imaging.format
 import org.apache.commons.imaging.util.Debug;
 
 public class JpegImageParser extends ImageParser {
+    private static final String DEFAULT_EXTENSION = ".jpg";
+    private static final String ACCEPTED_EXTENSIONS[] = { ".jpg", ".jpeg", };
+    public static final boolean permissive = true;
+    
     public JpegImageParser() {
         setByteOrder(ByteOrder.BIG_ENDIAN);
         // setDebug(true);
@@ -80,9 +84,6 @@ public class JpegImageParser extends Ima
         return DEFAULT_EXTENSION;
     }
 
-    private static final String DEFAULT_EXTENSION = ".jpg";
-
-    private static final String ACCEPTED_EXTENSIONS[] = { ".jpg", ".jpeg", };
 
     @Override
     protected String[] getAcceptedExtensions() {
@@ -140,6 +141,7 @@ public class JpegImageParser extends Ima
 
             public void visitSOS(final int marker, final byte markerBytes[],
                     final byte imageData[]) {
+                // don't need image data
             }
 
             // return false to exit traversal.
@@ -193,8 +195,6 @@ public class JpegImageParser extends Ima
         return result;
     }
 
-    public static final boolean permissive = true;
-
     private byte[] assembleSegments(final List<App2Segment> v)
             throws ImageReadException {
         try {
@@ -206,7 +206,7 @@ public class JpegImageParser extends Ima
 
     private byte[] assembleSegments(final List<App2Segment> v, final boolean start_with_zero)
             throws ImageReadException {
-        if (v.size() < 1) {
+        if (v.isEmpty()) {
             throw new ImageReadException("No App2 Segments Found.");
         }
 
@@ -296,7 +296,7 @@ public class JpegImageParser extends Ima
             }
         }
 
-        if (filtered.size() < 1) {
+        if (filtered.isEmpty()) {
             return null;
         }
 
@@ -370,7 +370,7 @@ public class JpegImageParser extends Ima
         final List<Segment> segments = readSegments(byteSource,
                 new int[] { JpegConstants.JPEG_APP1_Marker, }, false);
 
-        if ((segments == null) || (segments.size() < 1)) {
+        if ((segments == null) || (segments.isEmpty())) {
             return null;
         }
 
@@ -384,7 +384,7 @@ public class JpegImageParser extends Ima
         // Debug.debug("exifSegments", exifSegments);
 
         // TODO: concatenate if multiple segments, need example.
-        if (exifSegments.size() < 1) {
+        if (exifSegments.isEmpty()) {
             return null;
         }
         if (exifSegments.size() > 1) {
@@ -415,6 +415,7 @@ public class JpegImageParser extends Ima
 
             public void visitSOS(final int marker, final byte markerBytes[],
                     final byte imageData[]) {
+                // don't need image data
             }
 
             // return false to exit traversal.
@@ -453,6 +454,7 @@ public class JpegImageParser extends Ima
 
             public void visitSOS(final int marker, final byte markerBytes[],
                     final byte imageData[]) {
+                // don't need image data
             }
 
             // return false to exit traversal.
@@ -491,6 +493,7 @@ public class JpegImageParser extends Ima
 
             public void visitSOS(final int marker, final byte markerBytes[],
                     final byte imageData[]) {
+                // don't need image data
             }
 
             // return false to exit traversal.
@@ -540,6 +543,7 @@ public class JpegImageParser extends Ima
 
             public void visitSOS(final int marker, final byte markerBytes[],
                     final byte imageData[]) {
+                // don't need image data
             }
 
             // return false to exit traversal.
@@ -563,7 +567,7 @@ public class JpegImageParser extends Ima
         };
         new JpegUtils().traverseJFIF(byteSource, visitor);
 
-        if (result.size() < 1) {
+        if (result.isEmpty()) {
             return null;
         }
         if (result.size() > 1) {
@@ -578,7 +582,7 @@ public class JpegImageParser extends Ima
         final List<Segment> segments = readSegments(byteSource,
                 new int[] { JpegConstants.JPEG_APP13_Marker, }, false);
 
-        if ((segments == null) || (segments.size() < 1)) {
+        if ((segments == null) || (segments.isEmpty())) {
             return null;
         }
 
@@ -623,7 +627,7 @@ public class JpegImageParser extends Ima
 
         }, true);
 
-        if ((segments == null) || (segments.size() < 1)) {
+        if ((segments == null) || (segments.isEmpty())) {
             throw new ImageReadException("No JFIF Data Found.");
         }
 
@@ -693,7 +697,7 @@ public class JpegImageParser extends Ima
 
         JfifSegment jfifSegment = null;
 
-        if ((jfifSegments != null) && (jfifSegments.size() > 0)) {
+        if ((jfifSegments != null) && (!jfifSegments.isEmpty())) {
             jfifSegment = (JfifSegment) jfifSegments.get(0);
         }
 
@@ -802,7 +806,7 @@ public class JpegImageParser extends Ima
             String comment = "";
             try {
                 comment = new String(comSegment.getComment(), "UTF-8");
-            } catch (final UnsupportedEncodingException cannotHappen) {
+            } catch (final UnsupportedEncodingException cannotHappen) { // NOPMD - can't happen
             }
             Comments.add(comment);
         }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegUtils.java?rev=1544840&r1=1544839&r2=1544840&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegUtils.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegUtils.java Sat Nov 23 17:19:36 2013
@@ -31,14 +31,14 @@ public class JpegUtils extends BinaryFil
         setByteOrder(ByteOrder.NETWORK);
     }
 
-    public static interface Visitor {
+    public interface Visitor {
         // return false to exit before reading image data.
-        public boolean beginSOS();
+        boolean beginSOS();
 
-        public void visitSOS(int marker, byte markerBytes[], byte imageData[]);
+        void visitSOS(int marker, byte markerBytes[], byte imageData[]);
 
         // return false to exit traversal.
-        public boolean visitSegment(int marker, byte markerBytes[],
+        boolean visitSegment(int marker, byte markerBytes[],
                 int segmentLength, byte segmentLengthBytes[],
                 byte segmentData[]) throws ImageReadException,
                 IOException;
@@ -93,7 +93,7 @@ public class JpegUtils extends BinaryFil
                 }
             }
             
-            Debug.debug("" + markerCount + " markers");
+            Debug.debug(Integer.toString(markerCount) + " markers");
             canThrow = true;
         } finally {
             IoUtils.closeQuietly(canThrow, is);

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/ZigZag.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/ZigZag.java?rev=1544840&r1=1544839&r2=1544840&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/ZigZag.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/ZigZag.java Sat Nov 23 17:19:36 2013
@@ -15,7 +15,7 @@
 
 package org.apache.commons.imaging.formats.jpeg;
 
-public class ZigZag {
+public final class ZigZag {
     private static final int zigZag[] = {
          0,  1,  5,  6, 14, 15, 27, 28,
          2,  4,  7, 13, 16, 26, 29, 42,
@@ -27,6 +27,9 @@ public class ZigZag {
         35, 36, 48, 49, 57, 58, 62, 63
     };
 
+    private ZigZag() {
+    }
+    
     public static void zigZagToBlock(final int[] zz, final int[] block) {
         for (int i = 0; i < 64; i++) {
             block[i] = zz[zigZag[i]];

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/decoder/Dct.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/decoder/Dct.java?rev=1544840&r1=1544839&r2=1544840&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/decoder/Dct.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/decoder/Dct.java Sat Nov 23 17:19:36 2013
@@ -15,7 +15,7 @@
 
 package org.apache.commons.imaging.formats.jpeg.decoder;
 
-public class Dct {
+public final class Dct {
     /*
      * The book "JPEG still image data compression standard", by Pennebaker and
      * Mitchell, Chapter 4, discusses a number of approaches to the fast DCT.
@@ -91,6 +91,9 @@ public class Dct {
     private static final float Q = C2 - C6;
     private static final float R = C2 + C6;
 
+    private Dct() {
+    }
+    
     public static void scaleQuantizationVector(final float[] vector) {
         for (int x = 0; x < 8; x++) {
             vector[x] *= dctScalingFactors[x];

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/decoder/JpegDecoder.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/decoder/JpegDecoder.java?rev=1544840&r1=1544839&r2=1544840&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/decoder/JpegDecoder.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/decoder/JpegDecoder.java Sat Nov 23 17:19:36 2013
@@ -56,6 +56,9 @@ public class JpegDecoder extends BinaryF
     private BufferedImage image = null;
     private ImageReadException imageReadException = null;
     private IOException ioException = null;
+    private final int[] zz = new int[64];
+    private final int[] blockInt = new int[64];
+    private final float[] block = new float[64];
 
     public boolean beginSOS() {
         return true;
@@ -295,10 +298,6 @@ public class JpegDecoder extends BinaryF
         return mcu;
     }
 
-    private final int[] zz = new int[64];
-    private final int[] blockInt = new int[64];
-    private final float[] block = new float[64];
-
     private void readMCU(final JpegInputStream is, final int[] preds, final Block[] mcu)
             throws IOException, ImageReadException {
         for (int i = 0; i < sosSegment.numberOfComponents; i++) {

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/decoder/YCbCrConverter.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/decoder/YCbCrConverter.java?rev=1544840&r1=1544839&r2=1544840&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/decoder/YCbCrConverter.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/decoder/YCbCrConverter.java Sat Nov 23 17:19:36 2013
@@ -15,7 +15,7 @@
 
 package org.apache.commons.imaging.formats.jpeg.decoder;
 
-public class YCbCrConverter {
+public final class YCbCrConverter {
     private static final int[] reds = new int[256 * 256];
     private static final int[] blues = new int[256 * 256];
     private static final int[] greens1 = new int[256 * 256];
@@ -98,6 +98,9 @@ public class YCbCrConverter {
             }
         }
     }
+    
+    private YCbCrConverter() {
+    }
 
     private static int fastRound(final float x) {
         // Math.round() is very slow

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/iptc/IptcConstants.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/iptc/IptcConstants.java?rev=1544840&r1=1544839&r2=1544840&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/iptc/IptcConstants.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/iptc/IptcConstants.java Sat Nov 23 17:19:36 2013
@@ -17,7 +17,7 @@
 package org.apache.commons.imaging.formats.jpeg.iptc;
 
 
-public class IptcConstants {
+public final class IptcConstants {
     public static final int IPTC_NON_EXTENDED_RECORD_MAXIMUM_SIZE = 32767;
 
     public static final int IMAGE_RESOURCE_BLOCK_PHOTOSHOP2_INFO = 0x03e8;
@@ -88,4 +88,7 @@ public class IptcConstants {
     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;
+    
+    private IptcConstants() {
+    }
 }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/iptc/IptcRecord.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/iptc/IptcRecord.java?rev=1544840&r1=1544839&r2=1544840&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/iptc/IptcRecord.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/iptc/IptcRecord.java Sat Nov 23 17:19:36 2013
@@ -26,6 +26,11 @@ public class IptcRecord {
     public final IptcType iptcType;
     private final byte[] bytes;
     public final String value;
+    public static final Comparator<IptcRecord> COMPARATOR = new Comparator<IptcRecord>() {
+        public int compare(final IptcRecord e1, final IptcRecord e2) {
+            return e1.iptcType.getType() - e2.iptcType.getType();
+        }
+    };
 
     public IptcRecord(final IptcType iptcType, final byte[] bytes, final String value) {
         this.iptcType = iptcType;
@@ -56,11 +61,4 @@ public class IptcRecord {
     public String getIptcTypeName() {
         return iptcType.getName();
     }
-
-    public static final Comparator<IptcRecord> COMPARATOR = new Comparator<IptcRecord>() {
-        public int compare(final IptcRecord e1, final IptcRecord e2) {
-            return e1.iptcType.getType() - e2.iptcType.getType();
-        }
-    };
-
 }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/iptc/IptcType.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/iptc/IptcType.java?rev=1544840&r1=1544839&r2=1544840&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/iptc/IptcType.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/iptc/IptcType.java Sat Nov 23 17:19:36 2013
@@ -17,9 +17,9 @@
 package org.apache.commons.imaging.formats.jpeg.iptc;
 
 public interface IptcType {
-    public int getType();
+    int getType();
 
-    public String getName();
+    String getName();
 
-    public String toString();
+    String toString();
 }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/iptc/IptcTypeLookup.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/iptc/IptcTypeLookup.java?rev=1544840&r1=1544839&r2=1544840&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/iptc/IptcTypeLookup.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/iptc/IptcTypeLookup.java Sat Nov 23 17:19:36 2013
@@ -19,7 +19,7 @@ package org.apache.commons.imaging.forma
 import java.util.HashMap;
 import java.util.Map;
 
-public abstract class IptcTypeLookup {
+public final class IptcTypeLookup {
 
     private static final Map<Integer, IptcType> IPTC_TYPE_MAP = new HashMap<Integer, IptcType>();
     static {
@@ -28,7 +28,10 @@ public abstract class IptcTypeLookup {
         }
     }
 
-    public static final IptcType getIptcType(final int type) {
+    private IptcTypeLookup() {
+    }
+    
+    public static IptcType getIptcType(final int type) {
         if (!IPTC_TYPE_MAP.containsKey(type)) {
             return IptcTypes.getUnknown(type);
         }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/App14Segment.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/App14Segment.java?rev=1544840&r1=1544839&r2=1544840&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/App14Segment.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/App14Segment.java Sat Nov 23 17:19:36 2013
@@ -36,7 +36,7 @@ public class App14Segment extends AppnSe
         byte[] adobe = null;
         try {
             adobe = "Adobe".getBytes("US-ASCII");
-        } catch (final UnsupportedEncodingException cannotHappen) {
+        } catch (final UnsupportedEncodingException cannotHappen) { // NOPMD - can't happen
         }
         adobePrefix = adobe;
     }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/ComSegment.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/ComSegment.java?rev=1544840&r1=1544839&r2=1544840&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/ComSegment.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/ComSegment.java Sat Nov 23 17:19:36 2013
@@ -44,6 +44,7 @@ public class ComSegment extends GenericS
         try {
             commentString = new String(segmentData, "UTF-8");
         } catch (final UnsupportedEncodingException cannotHappen) {
+            // NOPMD
         }
         return "COM (" + commentString + ")";
     }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/Segment.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/Segment.java?rev=1544840&r1=1544839&r2=1544840&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/Segment.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/Segment.java Sat Nov 23 17:19:36 2013
@@ -32,6 +32,7 @@ public abstract class Segment extends Bi
     }
 
     public void dump(final PrintWriter pw) {
+        // empty
     }
 
     public abstract String getDescription();

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/xmp/JpegRewriter.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/xmp/JpegRewriter.java?rev=1544840&r1=1544839&r2=1544840&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/xmp/JpegRewriter.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/xmp/JpegRewriter.java Sat Nov 23 17:19:36 2013
@@ -37,6 +37,21 @@ import org.apache.commons.imaging.util.I
  */
 public class JpegRewriter extends BinaryFileParser {
     private static final ByteOrder JPEG_BYTE_ORDER = ByteOrder.NETWORK;
+    private static final SegmentFilter EXIF_SEGMENT_FILTER = new SegmentFilter() {
+        public boolean filter(final JFIFPieceSegment segment) {
+            return segment.isExifSegment();
+        }
+    };
+    private static final SegmentFilter XMP_SEGMENT_FILTER = new SegmentFilter() {
+        public boolean filter(final JFIFPieceSegment segment) {
+            return segment.isXmpSegment();
+        }
+    };
+    private static final SegmentFilter PHOTOSHOP_APP13_SEGMENT_FILTER = new SegmentFilter() {
+        public boolean filter(final JFIFPieceSegment segment) {
+            return segment.isPhotoshopApp13Segment();
+        }
+    };
 
     /**
      * Constructor. to guess whether a file contains an image based on its file
@@ -195,28 +210,10 @@ public class JpegRewriter extends Binary
         return new JFIFPieces(pieces, segmentPieces);
     }
 
-    private static interface SegmentFilter {
-        public boolean filter(JFIFPieceSegment segment);
+    private interface SegmentFilter {
+        boolean filter(JFIFPieceSegment segment);
     }
 
-    private static final SegmentFilter EXIF_SEGMENT_FILTER = new SegmentFilter() {
-        public boolean filter(final JFIFPieceSegment segment) {
-            return segment.isExifSegment();
-        }
-    };
-
-    private static final SegmentFilter XMP_SEGMENT_FILTER = new SegmentFilter() {
-        public boolean filter(final JFIFPieceSegment segment) {
-            return segment.isXmpSegment();
-        }
-    };
-
-    private static final SegmentFilter PHOTOSHOP_APP13_SEGMENT_FILTER = new SegmentFilter() {
-        public boolean filter(final JFIFPieceSegment segment) {
-            return segment.isPhotoshopApp13Segment();
-        }
-    };
-
     protected <T extends JFIFPiece> List<T> removeXmpSegments(final List<T> segments) {
         return filterSegments(segments, XMP_SEGMENT_FILTER);
     }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/xmp/JpegXmpParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/xmp/JpegXmpParser.java?rev=1544840&r1=1544839&r2=1544840&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/xmp/JpegXmpParser.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/jpeg/xmp/JpegXmpParser.java Sat Nov 23 17:19:36 2013
@@ -47,7 +47,7 @@ public class JpegXmpParser extends Binar
                     - index, "utf-8");
             return xml;
         } catch (final UnsupportedEncodingException e) {
-            throw new ImageReadException("Invalid JPEG XMP Segment.");
+            throw new ImageReadException("Invalid JPEG XMP Segment.", e);
         }
     }
 

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pcx/PcxConstants.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pcx/PcxConstants.java?rev=1544840&r1=1544839&r2=1544840&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pcx/PcxConstants.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pcx/PcxConstants.java Sat Nov 23 17:19:36 2013
@@ -15,10 +15,13 @@
 package org.apache.commons.imaging.formats.pcx;
 
 
-public class PcxConstants {
+public final class PcxConstants {
     public static final String PARAM_KEY_PCX_COMPRESSION = "PCX_COMPRESSION";
     public static final int PCX_COMPRESSION_UNCOMPRESSED = 0;
     public static final int PCX_COMPRESSION_RLE = 1;
 
     public static final String PARAM_KEY_PCX_BIT_DEPTH = "PCX_BIT_DEPTH";
+    
+    private PcxConstants() {
+    }
 }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pcx/PcxImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pcx/PcxImageParser.java?rev=1544840&r1=1544839&r2=1544840&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pcx/PcxImageParser.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pcx/PcxImageParser.java Sat Nov 23 17:19:36 2013
@@ -62,6 +62,9 @@ public class PcxImageParser extends Imag
     // don't support uncompressed PCX, and/or don't handle black and white
     // images properly.
 
+    private static final String DEFAULT_EXTENSION = ".pcx";
+    private static final String ACCEPTED_EXTENSIONS[] = { ".pcx", ".pcc", };
+
     public PcxImageParser() {
         super.setByteOrder(ByteOrder.LITTLE_ENDIAN);
     }
@@ -76,9 +79,6 @@ public class PcxImageParser extends Imag
         return DEFAULT_EXTENSION;
     }
 
-    private static final String DEFAULT_EXTENSION = ".pcx";
-    private static final String ACCEPTED_EXTENSIONS[] = { ".pcx", ".pcc", };
-
     @Override
     protected String[] getAcceptedExtensions() {
         return ACCEPTED_EXTENSIONS;

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pcx/PcxWriter.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pcx/PcxWriter.java?rev=1544840&r1=1544839&r2=1544840&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pcx/PcxWriter.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pcx/PcxWriter.java Sat Nov 23 17:19:36 2013
@@ -87,7 +87,7 @@ public class PcxWriter {
             pixelDensity = PixelDensity.createFromPixelsPerInch(72, 72);
         }
 
-        if (params.size() > 0) {
+        if (!params.isEmpty()) {
             final Object firstKey = params.keySet().iterator().next();
             throw new ImageWriteException("Unknown parameter: " + firstKey);
         }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngConstants.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngConstants.java?rev=1544840&r1=1544839&r2=1544840&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngConstants.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngConstants.java Sat Nov 23 17:19:36 2013
@@ -19,7 +19,7 @@ package org.apache.commons.imaging.forma
 import org.apache.commons.imaging.common.BinaryConstant;
 import org.apache.commons.imaging.common.BinaryFunctions;
 
-public class PngConstants {
+public final class PngConstants {
 
     public static final int COMPRESSION_DEFLATE_INFLATE = 0;
 
@@ -146,4 +146,6 @@ public class PngConstants {
      */
     public static final String PARAM_KEY_PNG_TEXT_CHUNKS = "PNG_TEXT_CHUNKS";
 
+    private PngConstants() {
+    }
 }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngImageParser.java?rev=1544840&r1=1544839&r2=1544840&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngImageParser.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngImageParser.java Sat Nov 23 17:19:36 2013
@@ -64,6 +64,8 @@ import org.apache.commons.imaging.util.I
 import org.apache.commons.imaging.util.ParamMap;
 
 public class PngImageParser extends ImageParser {
+    private static final String DEFAULT_EXTENSION = ".png";
+    private static final String ACCEPTED_EXTENSIONS[] = { DEFAULT_EXTENSION, };
 
     public PngImageParser() {
         // setDebug(true);
@@ -79,10 +81,6 @@ public class PngImageParser extends Imag
         return DEFAULT_EXTENSION;
     }
 
-    private static final String DEFAULT_EXTENSION = ".png";
-
-    private static final String ACCEPTED_EXTENSIONS[] = { DEFAULT_EXTENSION, };
-
     @Override
     protected String[] getAcceptedExtensions() {
         return ACCEPTED_EXTENSIONS;
@@ -127,9 +125,9 @@ public class PngImageParser extends Imag
             is = byteSource.getInputStream();
 
             readSignature(is);
-            List<PngChunk> chunks = readChunks(is, new int[] { chunkType, }, true);
+            final List<PngChunk> chunks = readChunks(is, new int[] { chunkType, }, true);
             canThrow = true;
-            return chunks.size() > 0;
+            return !chunks.isEmpty();
         } finally {
             IoUtils.closeQuietly(canThrow, is);
         }
@@ -251,7 +249,7 @@ public class PngImageParser extends Imag
         final List<PngChunk> chunks = readChunks(byteSource, new int[] { PngConstants.iCCP, },
                 true);
 
-        if ((chunks == null) || (chunks.size() < 1)) {
+        if ((chunks == null) || (chunks.isEmpty())) {
             // throw new ImageReadException("Png: No chunks");
             return null;
         }
@@ -273,7 +271,7 @@ public class PngImageParser extends Imag
         final List<PngChunk> chunks = readChunks(byteSource, new int[] { PngConstants.IHDR, },
                 true);
 
-        if ((chunks == null) || (chunks.size() < 1)) {
+        if ((chunks == null) || (chunks.isEmpty())) {
             throw new ImageReadException("Png: No chunks");
         }
 
@@ -301,7 +299,7 @@ public class PngImageParser extends Imag
         final List<PngChunk> chunks = readChunks(byteSource,
                 new int[] { PngConstants.tEXt, PngConstants.zTXt, }, true);
 
-        if ((chunks == null) || (chunks.size() < 1)) {
+        if ((chunks == null) || (chunks.isEmpty())) {
             return null;
         }
 
@@ -507,7 +505,7 @@ public class PngImageParser extends Imag
         // if(chunks!=null)
         // System.out.println("chunks: " + chunks.size());
 
-        if ((chunks == null) || (chunks.size() < 1)) {
+        if ((chunks == null) || (chunks.isEmpty())) {
             throw new ImageReadException("PNG: no chunks");
         }
 
@@ -521,7 +519,7 @@ public class PngImageParser extends Imag
         boolean isTransparent = false;
 
         final List<PngChunk> tRNSs = filterChunks(chunks, PngConstants.tRNS);
-        if (tRNSs.size() > 0) {
+        if (!tRNSs.isEmpty()) {
             isTransparent = true;
         } else {
             // CE - Fix Alpha.
@@ -663,7 +661,7 @@ public class PngImageParser extends Imag
                 PngConstants.sRGB,
             }, false);
 
-        if ((chunks == null) || (chunks.size() < 1)) {
+        if ((chunks == null) || (chunks.isEmpty())) {
             throw new ImageReadException("PNG: no chunks");
         }
 
@@ -687,7 +685,7 @@ public class PngImageParser extends Imag
         // -----
 
         final List<PngChunk> IDATs = filterChunks(chunks, PngConstants.IDAT);
-        if (IDATs.size() < 1) {
+        if (IDATs.isEmpty()) {
             throw new ImageReadException("PNG missing image data");
         }
 
@@ -706,7 +704,7 @@ public class PngImageParser extends Imag
         TransparencyFilter transparencyFilter = null;
 
         final List<PngChunk> tRNSs = filterChunks(chunks, PngConstants.tRNS);
-        if (tRNSs.size() > 0) {
+        if (!tRNSs.isEmpty()) {
             final PngChunk pngChunktRNS = tRNSs.get(0);
             transparencyFilter = getTransparencyFilter(pngChunkIHDR.colorType,
                     pngChunktRNS);
@@ -857,7 +855,7 @@ public class PngImageParser extends Imag
 
         pw.println("chunks: " + chunks.size());
 
-        if ((chunks.size() < 1)) {
+        if ((chunks.isEmpty())) {
             return false;
         }
 
@@ -896,7 +894,7 @@ public class PngImageParser extends Imag
         final List<PngChunk> chunks = readChunks(byteSource, new int[] { PngConstants.iTXt, },
                 false);
 
-        if ((chunks == null) || (chunks.size() < 1)) {
+        if ((chunks == null) || (chunks.isEmpty())) {
             return null;
         }
 
@@ -909,7 +907,7 @@ public class PngImageParser extends Imag
             xmpChunks.add(chunk);
         }
 
-        if (xmpChunks.size() < 1) {
+        if (xmpChunks.isEmpty()) {
             return null;
         }
         if (xmpChunks.size() > 1) {

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngText.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngText.java?rev=1544840&r1=1544839&r2=1544840&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngText.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngText.java Sat Nov 23 17:19:36 2013
@@ -17,13 +17,13 @@
 package org.apache.commons.imaging.formats.png;
 
 public abstract class PngText {
+    public final String keyword, text;
+    
     public PngText(final String keyword, final String text) {
         this.keyword = keyword;
         this.text = text;
     }
 
-    public final String keyword, text;
-
     public static class Text extends PngText {
         public Text(final String keyword, final String text) {
             super(keyword, text);

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngWriter.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngWriter.java?rev=1544840&r1=1544839&r2=1544840&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngWriter.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngWriter.java Sat Nov 23 17:19:36 2013
@@ -436,7 +436,7 @@ public class PngWriter {
             params.remove(PngConstants.PARAM_KEY_PNG_TEXT_CHUNKS);
         }
         params.remove(ImagingConstants.PARAM_KEY_PIXEL_DENSITY);
-        if (params.size() > 0) {
+        if (!params.isEmpty()) {
             final Object firstKey = params.keySet().iterator().next();
             throw new ImageWriteException("Unknown parameter: " + firstKey);
         }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/ScanExpediterInterlaced.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/ScanExpediterInterlaced.java?rev=1544840&r1=1544839&r2=1544840&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/ScanExpediterInterlaced.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/ScanExpediterInterlaced.java Sat Nov 23 17:19:36 2013
@@ -25,6 +25,13 @@ import org.apache.commons.imaging.format
 import org.apache.commons.imaging.formats.png.transparencyfilters.TransparencyFilter;
 
 public class ScanExpediterInterlaced extends ScanExpediter {
+    private static final int Starting_Row[] = { 0, 0, 4, 0, 2, 0, 1 };
+    private static final int Starting_Col[] = { 0, 4, 0, 2, 0, 1, 0 };
+    private static final int Row_Increment[] = { 8, 8, 8, 4, 4, 2, 2 };
+    private static final int Col_Increment[] = { 8, 8, 4, 4, 2, 2, 1 };
+//    private static final int Block_Height[] = { 8, 8, 4, 4, 2, 2, 1 };
+//    private static final int Block_Width[] = { 8, 4, 4, 2, 2, 1, 1 };
+
     public ScanExpediterInterlaced(final int width, final int height, final InputStream is,
             final BufferedImage bi, final int color_type, final int BitDepth, final int bits_per_pixel,
             final PngChunkPlte fPNGChunkPLTE, final GammaCorrection fGammaCorrection,
@@ -52,13 +59,6 @@ public class ScanExpediterInterlaced ext
 
     }
 
-    private static final int Starting_Row[] = { 0, 0, 4, 0, 2, 0, 1 };
-    private static final int Starting_Col[] = { 0, 4, 0, 2, 0, 1, 0 };
-    private static final int Row_Increment[] = { 8, 8, 8, 4, 4, 2, 2 };
-    private static final int Col_Increment[] = { 8, 8, 4, 4, 2, 2, 1 };
-//    private static final int Block_Height[] = { 8, 8, 4, 4, 2, 2, 1 };
-//    private static final int Block_Width[] = { 8, 4, 4, 2, 2, 1, 1 };
-
     @Override
     public void drive() throws ImageReadException, IOException {
 

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkIccp.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkIccp.java?rev=1544840&r1=1544839&r2=1544840&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkIccp.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkIccp.java Sat Nov 23 17:19:36 2013
@@ -64,8 +64,7 @@ public class PngChunkIccp extends PngChu
 
         if (getDebug()) {
             System.out.println("UncompressedProfile: "
-                    + ((UncompressedProfile == null) ? "null" : ""
-                            + bytes.length));
+                    + ((UncompressedProfile == null) ? "null" : Integer.toString(bytes.length)));
         }
     }
 

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/scanlinefilters/ScanlineFilterNone.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/scanlinefilters/ScanlineFilterNone.java?rev=1544840&r1=1544839&r2=1544840&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/scanlinefilters/ScanlineFilterNone.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/scanlinefilters/ScanlineFilterNone.java Sat Nov 23 17:19:36 2013
@@ -24,8 +24,6 @@ public class ScanlineFilterNone extends 
     @Override
     public void unfilter(final byte src[], final byte dst[], final byte up[])
             throws ImageReadException, IOException {
-        for (int i = 0; i < src.length; i++) {
-            dst[i] = src[i];
-        }
+        System.arraycopy(src, 0, dst, 0, src.length);
     }
 }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PamFileInfo.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PamFileInfo.java?rev=1544840&r1=1544839&r2=1544840&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PamFileInfo.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PamFileInfo.java Sat Nov 23 17:19:36 2013
@@ -52,11 +52,11 @@ public class PamFileInfo extends FileInf
         }
 
         hasAlpha = tupleType.endsWith("_ALPHA");
-        if (tupleType.equals("BLACKANDWHITE") || tupleType.equals("BLACKANDWHITE_ALPHA")) {
+        if ("BLACKANDWHITE".equals(tupleType) || "BLACKANDWHITE_ALPHA".equals(tupleType)) {
             tupleReader = new GrayscaleTupleReader(ImageInfo.COLOR_TYPE_BW);
-        } else if (tupleType.equals("GRAYSCALE") || tupleType.equals("GRAYSCALE_ALPHA")) {
+        } else if ("GRAYSCALE".equals(tupleType) || "GRAYSCALE_ALPHA".equals(tupleType)) {
             tupleReader = new GrayscaleTupleReader(ImageInfo.COLOR_TYPE_GRAYSCALE);
-        } else if (tupleType.equals("RGB") || tupleType.equals("RGB_ALPHA")) {
+        } else if ("RGB".equals(tupleType) || "RGB_ALPHA".equals(tupleType)) {
             tupleReader = new ColorTupleReader();
         } else {
             throw new ImageReadException("Unknown PAM tupletype '" + tupleType + "'");

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PbmFileInfo.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PbmFileInfo.java?rev=1544840&r1=1544839&r2=1544840&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PbmFileInfo.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PbmFileInfo.java Sat Nov 23 17:19:36 2013
@@ -24,6 +24,9 @@ import org.apache.commons.imaging.ImageF
 import org.apache.commons.imaging.ImageInfo;
 
 public class PbmFileInfo extends FileInfo {
+    private int bitcache = 0;
+    private int bits_in_cache = 0;
+
     public PbmFileInfo(final int width, final int height, final boolean RAWBITS) {
         super(width, height, RAWBITS);
     }
@@ -69,9 +72,6 @@ public class PbmFileInfo extends FileInf
         bits_in_cache = 0;
     }
 
-    private int bitcache = 0;
-    private int bits_in_cache = 0;
-
     @Override
     public int getRGB(final InputStream is) throws IOException {
         if (bits_in_cache < 1) {

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PbmWriter.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PbmWriter.java?rev=1544840&r1=1544839&r2=1544840&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PbmWriter.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PbmWriter.java Sat Nov 23 17:19:36 2013
@@ -38,10 +38,10 @@ public class PbmWriter extends PnmWriter
         final int width = src.getWidth();
         final int height = src.getHeight();
 
-        os.write(("" + width).getBytes("US-ASCII"));
+        os.write(Integer.toString(width).getBytes("US-ASCII"));
         os.write(PnmConstants.PNM_SEPARATOR);
 
-        os.write(("" + height).getBytes("US-ASCII"));
+        os.write(Integer.toString(height).getBytes("US-ASCII"));
         os.write(PnmConstants.PNM_NEWLINE);
 
         int bitcache = 0;
@@ -70,7 +70,7 @@ public class PbmWriter extends PnmWriter
                         bits_in_cache = 0;
                     }
                 } else {
-                    os.write(("" + sample).getBytes("US-ASCII")); // max
+                    os.write(Integer.toString(sample).getBytes("US-ASCII")); // max
                                                                   // component
                                                                   // value
                     os.write(PnmConstants.PNM_SEPARATOR);

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PgmWriter.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PgmWriter.java?rev=1544840&r1=1544839&r2=1544840&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PgmWriter.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PgmWriter.java Sat Nov 23 17:19:36 2013
@@ -40,13 +40,13 @@ public class PgmWriter extends PnmWriter
         final int width = src.getWidth();
         final int height = src.getHeight();
 
-        os.write(("" + width).getBytes("US-ASCII"));
+        os.write(Integer.toString(width).getBytes("US-ASCII"));
         os.write(PnmConstants.PNM_SEPARATOR);
 
-        os.write(("" + height).getBytes("US-ASCII"));
+        os.write(Integer.toString(height).getBytes("US-ASCII"));
         os.write(PnmConstants.PNM_SEPARATOR);
 
-        os.write(("" + 255).getBytes("US-ASCII")); // max component value
+        os.write(Integer.toString(255).getBytes("US-ASCII")); // max component value
         os.write(PnmConstants.PNM_NEWLINE);
 
         for (int y = 0; y < height; y++) {
@@ -60,9 +60,7 @@ public class PgmWriter extends PnmWriter
                 if (RAWBITS) {
                     os.write((byte) sample);
                 } else {
-                    os.write(("" + sample).getBytes("US-ASCII")); // max
-                                                                  // component
-                                                                  // value
+                    os.write(Integer.toString(sample).getBytes("US-ASCII")); // max component value
                     os.write(PnmConstants.PNM_SEPARATOR);
                 }
             }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PnmImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PnmImageParser.java?rev=1544840&r1=1544839&r2=1544840&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PnmImageParser.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PnmImageParser.java Sat Nov 23 17:19:36 2013
@@ -43,6 +43,12 @@ import org.apache.commons.imaging.palett
 import org.apache.commons.imaging.util.IoUtils;
 
 public class PnmImageParser extends ImageParser {
+    private static final String DEFAULT_EXTENSION = ".pnm";
+    private static final String ACCEPTED_EXTENSIONS[] = { ".pbm", ".pgm",
+            ".ppm", ".pnm", ".pam" };
+    public static final String PARAM_KEY_PNM_RAWBITS = "PNM_RAWBITS";
+    public static final String PARAM_VALUE_PNM_RAWBITS_YES = "YES";
+    public static final String PARAM_VALUE_PNM_RAWBITS_NO = "NO";
 
     public PnmImageParser() {
         super.setByteOrder(ByteOrder.LITTLE_ENDIAN);
@@ -59,11 +65,6 @@ public class PnmImageParser extends Imag
         return DEFAULT_EXTENSION;
     }
 
-    private static final String DEFAULT_EXTENSION = ".pnm";
-
-    private static final String ACCEPTED_EXTENSIONS[] = { ".pbm", ".pgm",
-            ".ppm", ".pnm", ".pam" };
-
     @Override
     protected String[] getAcceptedExtensions() {
         return ACCEPTED_EXTENSIONS;
@@ -137,27 +138,27 @@ public class PnmImageParser extends Imag
             String line;
             while ((line = wsr.readLine()) != null) {
                 line = line.trim();
-                if (line.startsWith("#")) {
+                if (line.charAt(0) == '#') {
                     continue;
                 }
                 final StringTokenizer tokenizer = new StringTokenizer(line, " ", false);
                 final String type = tokenizer.nextToken();
-                if (type.equals("WIDTH")) {
+                if ("WIDTH".equals(type)) {
                     seenWidth = true;
                     width = Integer.parseInt(tokenizer.nextToken());
-                } else if (type.equals("HEIGHT")) {
+                } else if ("HEIGHT".equals(type)) {
                     seenHeight = true;
                     height = Integer.parseInt(tokenizer.nextToken());
-                } else if (type.equals("DEPTH")) {
+                } else if ("DEPTH".equals(type)) {
                     seenDepth = true;
                     depth = Integer.parseInt(tokenizer.nextToken());
-                } else if (type.equals("MAXVAL")) {
+                } else if ("MAXVAL".equals(type)) {
                     seenMaxVal = true;
                     maxVal = Integer.parseInt(tokenizer.nextToken());
-                } else if (type.equals("TUPLTYPE")) {
+                } else if ("TUPLTYPE".equals(type)) {
                     seenTupleType = true;
                     tupleType += tokenizer.nextToken();
-                } else if (type.equals("ENDHDR")) {
+                } else if ("ENDHDR".equals(type)) {
                     break;
                 } else {
                     throw new ImageReadException("Invalid PAM file header type " + type);
@@ -315,10 +316,6 @@ public class PnmImageParser extends Imag
         }
     }
 
-    public static final String PARAM_KEY_PNM_RAWBITS = "PNM_RAWBITS";
-    public static final String PARAM_VALUE_PNM_RAWBITS_YES = "YES";
-    public static final String PARAM_VALUE_PNM_RAWBITS_NO = "NO";
-
     @Override
     public void writeImage(final BufferedImage src, final OutputStream os, Map<String,Object> params)
             throws ImageWriteException, IOException {
@@ -368,7 +365,7 @@ public class PnmImageParser extends Imag
             params.remove(PARAM_KEY_FORMAT);
         }
         
-        if (params.size() > 0) {
+        if (!params.isEmpty()) {
             final Object firstKey = params.keySet().iterator().next();
             throw new ImageWriteException("Unknown parameter: " + firstKey);
         }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PpmWriter.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PpmWriter.java?rev=1544840&r1=1544839&r2=1544840&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PpmWriter.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PpmWriter.java Sat Nov 23 17:19:36 2013
@@ -40,13 +40,13 @@ public class PpmWriter extends PnmWriter
         final int width = src.getWidth();
         final int height = src.getHeight();
 
-        os.write(("" + width).getBytes("US-ASCII"));
+        os.write(Integer.toString(width).getBytes("US-ASCII"));
         os.write(PnmConstants.PNM_SEPARATOR);
 
-        os.write(("" + height).getBytes("US-ASCII"));
+        os.write(Integer.toString(height).getBytes("US-ASCII"));
         os.write(PnmConstants.PNM_SEPARATOR);
 
-        os.write(("" + 255).getBytes("US-ASCII")); // max component value
+        os.write(Integer.toString(255).getBytes("US-ASCII")); // max component value
         os.write(PnmConstants.PNM_NEWLINE);
 
         for (int y = 0; y < height; y++) {
@@ -61,14 +61,14 @@ public class PpmWriter extends PnmWriter
                     os.write((byte) green);
                     os.write((byte) blue);
                 } else {
-                    os.write(("" + red).getBytes("US-ASCII")); // max component
+                    os.write(Integer.toString(red).getBytes("US-ASCII")); // max component
                                                                // value
                     os.write(PnmConstants.PNM_SEPARATOR);
-                    os.write(("" + green).getBytes("US-ASCII")); // max
+                    os.write(Integer.toString(green).getBytes("US-ASCII")); // max
                                                                  // component
                                                                  // value
                     os.write(PnmConstants.PNM_SEPARATOR);
-                    os.write(("" + blue).getBytes("US-ASCII")); // max component
+                    os.write(Integer.toString(blue).getBytes("US-ASCII")); // max component
                                                                 // value
                     os.write(PnmConstants.PNM_SEPARATOR);
                 }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/PsdImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/PsdImageParser.java?rev=1544840&r1=1544839&r2=1544840&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/PsdImageParser.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/PsdImageParser.java Sat Nov 23 17:19:36 2013
@@ -49,6 +49,18 @@ import org.apache.commons.imaging.format
 import org.apache.commons.imaging.util.IoUtils;
 
 public class PsdImageParser extends ImageParser {
+    private static final String DEFAULT_EXTENSION = ".psd";
+    private static final String ACCEPTED_EXTENSIONS[] = { DEFAULT_EXTENSION, };
+    private static final int PSD_SECTION_HEADER = 0;
+    private static final int PSD_SECTION_COLOR_MODE = 1;
+    private static final int PSD_SECTION_IMAGE_RESOURCES = 2;
+    private static final int PSD_SECTION_LAYER_AND_MASK_DATA = 3;
+    private static final int PSD_SECTION_IMAGE_DATA = 4;
+    private static final int PSD_HEADER_LENGTH = 26;
+    private static final int COLOR_MODE_INDEXED = 2;
+    public final static int IMAGE_RESOURCE_ID_ICC_PROFILE = 0x040F;
+    public final static int IMAGE_RESOURCE_ID_XMP = 0x0424;
+    public final static String BLOCK_NAME_XMP = "XMP";
 
     public PsdImageParser() {
         super.setByteOrder(ByteOrder.MOTOROLA);
@@ -65,10 +77,6 @@ public class PsdImageParser extends Imag
         return DEFAULT_EXTENSION;
     }
 
-    private static final String DEFAULT_EXTENSION = ".psd";
-
-    private static final String ACCEPTED_EXTENSIONS[] = { DEFAULT_EXTENSION, };
-
     @Override
     protected String[] getAcceptedExtensions() {
         return ACCEPTED_EXTENSIONS;
@@ -265,14 +273,6 @@ public class PsdImageParser extends Imag
         }
     }
 
-    private static final int PSD_SECTION_HEADER = 0;
-    private static final int PSD_SECTION_COLOR_MODE = 1;
-    private static final int PSD_SECTION_IMAGE_RESOURCES = 2;
-    private static final int PSD_SECTION_LAYER_AND_MASK_DATA = 3;
-    private static final int PSD_SECTION_IMAGE_DATA = 4;
-
-    private static final int PSD_HEADER_LENGTH = 26;
-
     private InputStream getInputStream(final ByteSource byteSource, final int section)
             throws ImageReadException, IOException {
         InputStream is = null;
@@ -425,8 +425,6 @@ public class PsdImageParser extends Imag
 
     }
 
-    public final static int IMAGE_RESOURCE_ID_ICC_PROFILE = 0x040F;
-
     @Override
     public byte[] getICCProfileBytes(final ByteSource byteSource, final Map<String,Object> params)
             throws ImageReadException, IOException {
@@ -623,8 +621,6 @@ public class PsdImageParser extends Imag
         return true;
     }
 
-    private static final int COLOR_MODE_INDEXED = 2;
-
     @Override
     public BufferedImage getBufferedImage(final ByteSource byteSource, final Map<String,Object> params)
             throws ImageReadException, IOException {
@@ -740,10 +736,6 @@ public class PsdImageParser extends Imag
 
     }
 
-    public final static int IMAGE_RESOURCE_ID_XMP = 0x0424;
-
-    public final static String BLOCK_NAME_XMP = "XMP";
-
     /**
      * Extracts embedded XML metadata as XML string.
      * <p>

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/rgbe/RgbeImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/rgbe/RgbeImageParser.java?rev=1544840&r1=1544839&r2=1544840&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/rgbe/RgbeImageParser.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/rgbe/RgbeImageParser.java Sat Nov 23 17:19:36 2013
@@ -78,7 +78,7 @@ public class RgbeImageParser extends Ima
         final RgbeInfo info = new RgbeInfo(byteSource);
         boolean canThrow = false;
         try {
-            IImageMetadata ret = info.getMetadata();
+            final IImageMetadata ret = info.getMetadata();
             canThrow = true;
             return ret;
         } finally {

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/rgbe/RgbeInfo.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/rgbe/RgbeInfo.java?rev=1544840&r1=1544839&r2=1544840&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/rgbe/RgbeInfo.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/rgbe/RgbeInfo.java Sat Nov 23 17:19:36 2013
@@ -23,7 +23,6 @@ import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
 import org.apache.commons.imaging.ImageReadException;
-import org.apache.commons.imaging.common.BinaryFunctions;
 import org.apache.commons.imaging.common.BinaryInputStream;
 import org.apache.commons.imaging.common.ByteConversions;
 import org.apache.commons.imaging.common.ByteOrder;
@@ -31,7 +30,7 @@ import org.apache.commons.imaging.common
 import org.apache.commons.imaging.common.ImageMetadata;
 import org.apache.commons.imaging.common.bytesource.ByteSource;
 
-class RgbeInfo extends BinaryFunctions implements Closeable {
+class RgbeInfo implements Closeable {
     // #?RADIANCE
     private static byte[] HEADER = new byte[] {
         0x23, 0x3F, 0x52, 0x41, 0x44, 0x49, 0x41, 0x4E, 0x43, 0x45

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffDirectory.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffDirectory.java?rev=1544840&r1=1544839&r2=1544840&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffDirectory.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffDirectory.java Sat Nov 23 17:19:36 2013
@@ -51,7 +51,9 @@ public class TiffDirectory extends TiffE
     public final int type;
     public final List<TiffField> entries;
     public final long nextDirectoryOffset;
-
+    private TiffImageData tiffImageData = null;
+    private JpegImageData jpegImageData = null;
+    
     public TiffDirectory(final int type, final List<TiffField> entries, final long offset,
             final long nextDirectoryOffset) {
         super(offset, TiffConstants.TIFF_DIRECTORY_HEADER_LENGTH +
@@ -701,8 +703,6 @@ public class TiffDirectory extends TiffE
         }
     }
 
-    private TiffImageData tiffImageData = null;
-
     public void setTiffImageData(final TiffImageData rawImageData) {
         this.tiffImageData = rawImageData;
     }
@@ -711,8 +711,6 @@ public class TiffDirectory extends TiffE
         return tiffImageData;
     }
 
-    private JpegImageData jpegImageData = null;
-
     public void setJpegImageData(final JpegImageData value) {
         this.jpegImageData = value;
     }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffElement.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffElement.java?rev=1544840&r1=1544839&r2=1544840&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffElement.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffElement.java Sat Nov 23 17:19:36 2013
@@ -21,18 +21,6 @@ import java.util.Comparator;
 public abstract class TiffElement {
     public final long offset;
     public final int length;
-
-    public TiffElement(final long offset, final int length) {
-        this.offset = offset;
-        this.length = length;
-    }
-
-    public String getElementDescription() {
-        return getElementDescription(false);
-    }
-
-    public abstract String getElementDescription(boolean verbose);
-
     public static final Comparator<TiffElement> COMPARATOR = new Comparator<TiffElement>() {
         public int compare(final TiffElement e1, final TiffElement e2) {
             if (e1.offset < e2.offset) {
@@ -45,6 +33,17 @@ public abstract class TiffElement {
         }
     };
 
+    public TiffElement(final long offset, final int length) {
+        this.offset = offset;
+        this.length = length;
+    }
+
+    public String getElementDescription() {
+        return getElementDescription(false);
+    }
+
+    public abstract String getElementDescription(boolean verbose);
+
     public static abstract class DataElement extends TiffElement {
         public final byte data[];
 
@@ -68,7 +67,7 @@ public abstract class TiffElement {
         @Override
         public String getElementDescription(final boolean verbose) {
             return "Element, offset: " + offset + ", length: " + length
-                    + ", last: " + (offset + length) + "";
+                    + ", last: " + (offset + length);
         }
 
     }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffField.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffField.java?rev=1544840&r1=1544839&r2=1544840&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffField.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffField.java Sat Nov 23 17:19:36 2013
@@ -25,6 +25,7 @@ import java.util.ArrayList;
 import java.util.Date;
 import java.util.Hashtable;
 import java.util.List;
+import java.util.Locale;
 import java.util.Map;
 
 import org.apache.commons.imaging.ImageReadException;
@@ -50,6 +51,9 @@ public class TiffField {
     private final byte[] value;
     private final ByteOrder byteOrder;
     private final int sortHint;
+    public static final String Attribute_Tag = "Tag";
+    private static final Map<Object, List<TagInfo>> ALL_TAG_MAP = makeTagMap(
+            AllTagConstants.ALL_TAGS, true, "All");
 
     public TiffField(final int tag, final int directoryType, final FieldType fieldType,
             final long count, final long offset, final byte[] value,
@@ -327,7 +331,7 @@ public class TiffField {
         } else if (o instanceof String) {
             return "'" + o.toString().trim() + "'";
         } else if (o instanceof Date) {
-            final DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
+            final DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ", Locale.ENGLISH);
             return df.format((Date) o);
         } else if (o instanceof Object[]) {
             final Object objects[] = (Object[]) o;
@@ -343,7 +347,7 @@ public class TiffField {
                 if (i > 0) {
                     result.append(", ");
                 }
-                result.append("" + object);
+                result.append(object.toString());
             }
             return result.toString();
         // } else if (o instanceof Number[])
@@ -375,7 +379,7 @@ public class TiffField {
                 if (i > 0) {
                     result.append(", ");
                 }
-                result.append("" + sval);
+                result.append(Short.toString(sval));
             }
             return result.toString();
         } else if (o instanceof int[]) {
@@ -392,7 +396,7 @@ public class TiffField {
                 if (i > 0) {
                     result.append(", ");
                 }
-                result.append("" + iVal);
+                result.append(Integer.toString(iVal));
             }
             return result.toString();
         } else if (o instanceof long[]) {
@@ -409,7 +413,7 @@ public class TiffField {
                 if (i > 0) {
                     result.append(", ");
                 }
-                result.append("" + lVal);
+                result.append(Long.toString(lVal));
             }
             return result.toString();
         } else if (o instanceof double[]) {
@@ -426,7 +430,7 @@ public class TiffField {
                 if (i > 0) {
                     result.append(", ");
                 }
-                result.append("" + dVal);
+                result.append(Double.toString(dVal));
             }
             return result.toString();
         } else if (o instanceof byte[]) {
@@ -443,7 +447,7 @@ public class TiffField {
                 if (i > 0) {
                     result.append(", ");
                 }
-                result.append("" + bVal);
+                result.append(Byte.toString(bVal));
             }
             return result.toString();
         } else if (o instanceof char[]) {
@@ -460,7 +464,7 @@ public class TiffField {
                 if (i > 0) {
                     result.append(", ");
                 }
-                result.append("" + cVal);
+                result.append(Character.toString(cVal));
             }
             return result.toString();
         } else if (o instanceof float[]) {
@@ -477,7 +481,7 @@ public class TiffField {
                 if (i > 0) {
                     result.append(", ");
                 }
-                result.append("" + fVal);
+                result.append(Float.toString(fVal));
             }
             return result.toString();
         }
@@ -547,8 +551,6 @@ public class TiffField {
         return getFieldType().getName();
     }
 
-    public static final String Attribute_Tag = "Tag";
-
     public Object getValue() throws ImageReadException {
         // System.out.print("getValue");
         return getTagInfo().getValue(this);
@@ -585,9 +587,6 @@ public class TiffField {
         return map;
     }
 
-    private static final Map<Object, List<TagInfo>> ALL_TAG_MAP = makeTagMap(
-            AllTagConstants.ALL_TAGS, true, "All");
-
     public int[] getIntArrayValue() throws ImageReadException {
         final Object o = getValue();
         // if (o == null)
@@ -612,9 +611,7 @@ public class TiffField {
         } else if (o instanceof int[]) {
             final int numbers[] = (int[]) o;
             final int result[] = new int[numbers.length];
-            for (int i = 0; i < numbers.length; i++) {
-                result[i] = numbers[i];
-            }
+            System.arraycopy(numbers, 0, result, 0, numbers.length);
             return result;
         }
 
@@ -661,9 +658,7 @@ public class TiffField {
         } else if (o instanceof double[]) {
             final double numbers[] = (double[]) o;
             final double result[] = new double[numbers.length];
-            for (int i = 0; i < numbers.length; i++) {
-                result[i] = numbers[i];
-            }
+            System.arraycopy(numbers, 0, result, 0, numbers.length);
             return result;
         }
 

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffImageParser.java?rev=1544840&r1=1544839&r2=1544840&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffImageParser.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffImageParser.java Sat Nov 23 17:19:36 2013
@@ -55,6 +55,9 @@ import org.apache.commons.imaging.format
 import org.apache.commons.imaging.formats.tiff.write.TiffImageWriterLossy;
 
 public class TiffImageParser extends ImageParser implements TiffConstants {
+    private static final String DEFAULT_EXTENSION = ".tif";
+    private static final String ACCEPTED_EXTENSIONS[] = { ".tif", ".tiff", };
+
     public TiffImageParser() {
         // setDebug(true);
     }
@@ -69,10 +72,6 @@ public class TiffImageParser extends Ima
         return DEFAULT_EXTENSION;
     }
 
-    private static final String DEFAULT_EXTENSION = ".tif";
-
-    private static final String ACCEPTED_EXTENSIONS[] = { ".tif", ".tiff", };
-
     @Override
     protected String[] getAcceptedExtensions() {
         return ACCEPTED_EXTENSIONS;
@@ -387,7 +386,7 @@ public class TiffImageParser extends Ima
                     for (int i = 0; i < entries.size(); i++) {
                         final TiffField field = entries.get(i);
 
-                        field.dump(pw, d + "");
+                        field.dump(pw, Integer.toString(d));
                     }
                 }
 



Mime
View raw message