xmlgraphics-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sstei...@apache.org
Subject svn commit: r1681108 [2/3] - in /xmlgraphics/commons/trunk: ./ src/java/org/apache/xmlgraphics/fonts/ src/java/org/apache/xmlgraphics/image/codec/png/ src/java/org/apache/xmlgraphics/image/codec/tiff/ src/java/org/apache/xmlgraphics/image/codec/util/ s...
Date Fri, 22 May 2015 13:26:13 GMT
Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/tiff/TIFFImageEncoder.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/tiff/TIFFImageEncoder.java?rev=1681108&r1=1681107&r2=1681108&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/tiff/TIFFImageEncoder.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/tiff/TIFFImageEncoder.java Fri May 22 13:26:12 2015
@@ -35,6 +35,7 @@ import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.OutputStream;
 import java.io.RandomAccessFile;
+import java.io.UnsupportedEncodingException;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
@@ -162,7 +163,7 @@ public class TIFFImageEncoder extends Im
         c.ifdOffset = encode(c.nextImage, encodeParam, c.ifdOffset, true);
     }
 
-    private class Context {
+    private static class Context {
         //TODO This approach causes always two images to be present at the same time.
         //The encoder has to be changed a little to avoid that.
         private RenderedImage nextImage;
@@ -380,22 +381,20 @@ public class TIFFImageEncoder extends Im
 
         // Add extra fields specified via the encoding parameters.
         TIFFField[] extraFields = encodeParam.getExtraFields();
-        if (extraFields != null) {
-            List extantTags = new ArrayList(fields.size());
-            Iterator fieldIter = fields.iterator();
-            while (fieldIter.hasNext()) {
-                TIFFField fld = (TIFFField)fieldIter.next();
-                extantTags.add(new Integer(fld.getTag()));
-            }
+        List extantTags = new ArrayList(fields.size());
+        Iterator fieldIter = fields.iterator();
+        while (fieldIter.hasNext()) {
+            TIFFField fld = (TIFFField)fieldIter.next();
+            extantTags.add(fld.getTag());
+        }
 
-            int numExtraFields = extraFields.length;
-            for (int i = 0; i < numExtraFields; i++) {
-                TIFFField fld = extraFields[i];
-                Integer tagValue = new Integer(fld.getTag());
-                if (!extantTags.contains(tagValue)) {
-                    fields.add(fld);
-                    extantTags.add(tagValue);
-                }
+        int numExtraFields = extraFields.length;
+        for (int i = 0; i < numExtraFields; i++) {
+            TIFFField fld = extraFields[i];
+            Integer tagValue = fld.getTag();
+            if (!extantTags.contains(tagValue)) {
+                fields.add(fld);
+                extantTags.add(tagValue);
             }
         }
 
@@ -488,7 +487,7 @@ public class TIFFImageEncoder extends Im
                     output = new SeekableOutputStream(raFile);
 
                     // this method is exited!
-                } catch (Exception e) {
+                } catch (IOException e) {
                     // Allocate memory for the entire image data (!).
                     output = new ByteArrayOutputStream((int)totalBytesOfData);
                 }
@@ -836,7 +835,8 @@ public class TIFFImageEncoder extends Im
                         output.write(compressBuf, 0, numCompressedBytes);
                     }
                     break;
-
+                default:
+                    break;
                 }
             }
         }
@@ -888,31 +888,33 @@ public class TIFFImageEncoder extends Im
 
                 // Open a FileInputStream from which to copy the data.
                 FileInputStream fileStream = new FileInputStream(tempFile);
+                try {
+                    // Close the original SeekableOutputStream.
+                    output.close();
 
-                // Close the original SeekableOutputStream.
-                output.close();
+                    // Reset variable to the original OutputStream.
+                    output = outCache;
 
-                // Reset variable to the original OutputStream.
-                output = outCache;
+                    // Write the IFD.
+                    writeDirectory(ifdOffset, fields, nextIFDOffset);
 
-                // Write the IFD.
-                writeDirectory(ifdOffset, fields, nextIFDOffset);
-
-                // Write the image data.
-                byte[] copyBuffer = new byte[8192];
-                int bytesCopied = 0;
-                while (bytesCopied < totalBytes) {
-                    int bytesRead = fileStream.read(copyBuffer);
-                    if (bytesRead == -1) {
-                        break;
+                    // Write the image data.
+                    byte[] copyBuffer = new byte[8192];
+                    int bytesCopied = 0;
+                    while (bytesCopied < totalBytes) {
+                        int bytesRead = fileStream.read(copyBuffer);
+                        if (bytesRead == -1) {
+                            break;
+                        }
+                        output.write(copyBuffer, 0, bytesRead);
+                        bytesCopied += bytesRead;
                     }
-                    output.write(copyBuffer, 0, bytesRead);
-                    bytesCopied += bytesRead;
+                } finally {
+                    // Delete the temporary file.
+                    fileStream.close();
                 }
-
-                // Delete the temporary file.
-                fileStream.close();
-                tempFile.delete();
+                boolean isDeleted = tempFile.delete();
+                assert isDeleted;
 
                 // Write an extra byte for IFD word alignment if needed.
                 if (skipByte) {
@@ -1093,13 +1095,13 @@ public class TIFFImageEncoder extends Im
     /**
      * Determine the number of bytes in the value portion of the field.
      */
-    private static int getValueSize(TIFFField field) {
+    private static int getValueSize(TIFFField field) throws UnsupportedEncodingException {
         int type = field.getType();
         int count = field.getCount();
         int valueSize = 0;
         if (type == TIFFField.TIFF_ASCII) {
             for (int i = 0; i < count; i++) {
-                byte[] stringBytes = field.getAsString(i).getBytes();   // note: default encoding @work here!
+                byte[] stringBytes = field.getAsString(i).getBytes("UTF-8");   // note: default encoding @work here!
                 valueSize += stringBytes.length;
                 if (stringBytes[stringBytes.length - 1] != 0) {
                     valueSize++;
@@ -1244,7 +1246,7 @@ public class TIFFImageEncoder extends Im
 
         case TIFFField.TIFF_ASCII:
             for (int i = 0; i < count; i++) {
-                byte[] stringBytes = field.getAsString(i).getBytes();
+                byte[] stringBytes = field.getAsString(i).getBytes("UTF-8");
                 output.write(stringBytes);
                 if (stringBytes[stringBytes.length - 1] != (byte)0) {
                     output.write((byte)0);
@@ -1278,20 +1280,20 @@ public class TIFFImageEncoder extends Im
         output.write((int) (l & 0x000000ff));
     }
 
-    /**
-     * Returns the current offset in the supplied OutputStream.
-     * This method should only be used if compressing data.
-     */
-    private long getOffset(OutputStream out) throws IOException {
-        if (out instanceof ByteArrayOutputStream) {
-            return ((ByteArrayOutputStream)out).size();
-        } else if (out instanceof SeekableOutputStream) {
-            return ((SeekableOutputStream)out).getFilePointer();
-        } else {
-            // Shouldn't happen.
-            throw new IllegalStateException(PropertyUtil.getString("TIFFImageEncoder13"));
-        }
-    }
+//    /**
+//     * Returns the current offset in the supplied OutputStream.
+//     * This method should only be used if compressing data.
+//     */
+//    private long getOffset(OutputStream out) throws IOException {
+//        if (out instanceof ByteArrayOutputStream) {
+//            return ((ByteArrayOutputStream)out).size();
+//        } else if (out instanceof SeekableOutputStream) {
+//            return ((SeekableOutputStream)out).getFilePointer();
+//        } else {
+//            // Shouldn't happen.
+//            throw new IllegalStateException(PropertyUtil.getString("TIFFImageEncoder13"));
+//        }
+//    }
 
     /**
      * Performs PackBits compression on a tile of data.

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/tiff/TIFFLZWDecoder.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/tiff/TIFFLZWDecoder.java?rev=1681108&r1=1681107&r2=1681108&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/tiff/TIFFLZWDecoder.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/tiff/TIFFLZWDecoder.java Fri May 22 13:26:12 2015
@@ -38,10 +38,9 @@ public class TIFFLZWDecoder {
     int tableIndex;
     int bitsToGet = 9;
     int bytePointer;
-    int bitPointer;
+//    int bitPointer;
     int dstIndex;
     int w;
-    int h;
     int predictor;
     int samplesPerPixel;
     int nextData;
@@ -75,13 +74,13 @@ public class TIFFLZWDecoder {
 
         initializeStringTable();
 
-        this.data = data;
-        this.h = h;
-        this.uncompData = uncompData;
+        this.data = data.clone();
+//        this.h = h;
+        this.uncompData = uncompData.clone();
 
         // Initialize pointers
         bytePointer = 0;
-        bitPointer = 0;
+//        bitPointer = 0;
         dstIndex = 0;
 
 

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/util/MemoryCacheSeekableStream.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/util/MemoryCacheSeekableStream.java?rev=1681108&r1=1681107&r2=1681108&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/util/MemoryCacheSeekableStream.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/util/MemoryCacheSeekableStream.java Fri May 22 13:26:12 2015
@@ -58,7 +58,7 @@ public final class MemoryCacheSeekableSt
     private List data = new ArrayList();
 
     /** Number of sectors stored. */
-    int sectors;
+//    int sectors = 0;
 
     /** Number of bytes read. */
     int length;

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/util/PropertyUtil.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/util/PropertyUtil.java?rev=1681108&r1=1681107&r2=1681108&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/util/PropertyUtil.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/util/PropertyUtil.java Fri May 22 13:26:12 2015
@@ -28,17 +28,17 @@ public final class PropertyUtil {
     private PropertyUtil() {
     }
 
-    protected static final String RESOURCES =
+    private static final String RESOURCES =
         "org.apache.xmlgraphics.image.codec.Messages";
 
 
-    protected static LocalizableSupport localizableSupport =
+    private static final LocalizableSupport LOCALIZABLESUPPORT =
         new LocalizableSupport(
         RESOURCES, PropertyUtil.class.getClassLoader());
 
     public static String getString(String key) {
         try {
-            return localizableSupport.formatMessage(key, null);
+            return LOCALIZABLESUPPORT.formatMessage(key, null);
         } catch (MissingResourceException e) {
             return key;
         }

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/util/SimpleRenderedImage.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/util/SimpleRenderedImage.java?rev=1681108&r1=1681107&r2=1681108&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/util/SimpleRenderedImage.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/util/SimpleRenderedImage.java Fri May 22 13:26:12 2015
@@ -30,6 +30,7 @@ import java.awt.image.WritableRaster;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
+import java.util.Locale;
 import java.util.Map;
 import java.util.Vector;
 
@@ -80,7 +81,7 @@ public abstract class SimpleRenderedImag
     protected ColorModel colorModel;
 
     /** The image's sources, stored in a Vector. */
-    protected List sources = new ArrayList();
+//    protected List sources = new ArrayList();
 
     /** A Hashtable containing the image properties. */
     protected Map properties = new HashMap();
@@ -233,7 +234,7 @@ public abstract class SimpleRenderedImag
      * <code>Object</code>, or the value <code>null</code>
      */
     public Object getProperty(String name) {
-        name = name.toLowerCase();
+        name = name.toLowerCase(Locale.getDefault());
         return properties.get(name);
     }
 
@@ -265,11 +266,11 @@ public abstract class SimpleRenderedImag
      */
     public String[] getPropertyNames(String prefix) {
         String[] propertyNames = getPropertyNames();
-        if (propertyNames == null) {
-            return null;
-        }
+//        if (propertyNames == null) {
+//            return null;
+//        }
 
-        prefix = prefix.toLowerCase();
+        prefix = prefix.toLowerCase(Locale.getDefault());
 
         List names = new ArrayList();
         for (int i = 0; i < propertyNames.length; i++) {

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/ImageManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/ImageManager.java?rev=1681108&r1=1681107&r2=1681108&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/ImageManager.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/ImageManager.java Fri May 22 13:26:12 2015
@@ -43,7 +43,7 @@ import org.apache.xmlgraphics.io.XmlSour
 public class ImageManager {
 
     /** logger */
-    protected static Log log = LogFactory.getLog(ImageManager.class);
+    protected static final Log log = LogFactory.getLog(ImageManager.class);
 
     /** Holds all registered interface implementations for the image package */
     private ImageImplRegistry registry;

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/MimeEnabledImageFlavor.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/MimeEnabledImageFlavor.java?rev=1681108&r1=1681107&r2=1681108&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/MimeEnabledImageFlavor.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/MimeEnabledImageFlavor.java Fri May 22 13:26:12 2015
@@ -41,4 +41,23 @@ public class MimeEnabledImageFlavor exte
         return this.mime;
     }
 
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) { return true; }
+        if (o == null || getClass() != o.getClass()) { return false; }
+        if (!super.equals(o)) { return false; }
+
+        MimeEnabledImageFlavor that = (MimeEnabledImageFlavor) o;
+
+        if (mime != null ? !mime.equals(that.mime) : that.mime != null) { return false; }
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = super.hashCode();
+        result = 31 * result + (mime != null ? mime.hashCode() : 0);
+        return result;
+    }
 }

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/XMLNamespaceEnabledImageFlavor.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/XMLNamespaceEnabledImageFlavor.java?rev=1681108&r1=1681107&r2=1681108&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/XMLNamespaceEnabledImageFlavor.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/XMLNamespaceEnabledImageFlavor.java Fri May 22 13:26:12 2015
@@ -45,4 +45,23 @@ public class XMLNamespaceEnabledImageFla
         return this.namespace;
     }
 
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) { return true; }
+        if (o == null || getClass() != o.getClass()) { return false; }
+        if (!super.equals(o)) { return false; }
+
+        XMLNamespaceEnabledImageFlavor that = (XMLNamespaceEnabledImageFlavor) o;
+
+        if (namespace != null ? !namespace.equals(that.namespace) : that.namespace != null) { return false; }
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        int result = super.hashCode();
+        result = 31 * result + (namespace != null ? namespace.hashCode() : 0);
+        return result;
+    }
 }

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/cache/DefaultExpirationPolicy.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/cache/DefaultExpirationPolicy.java?rev=1681108&r1=1681107&r2=1681108&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/cache/DefaultExpirationPolicy.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/cache/DefaultExpirationPolicy.java Fri May 22 13:26:12 2015
@@ -54,7 +54,7 @@ public class DefaultExpirationPolicy imp
             return false;
         } else {
             long now = provider.getTimeStamp();
-            return now >= (timestamp + (this.expirationAfter * 1000));
+            return now >= (timestamp + (this.expirationAfter * 1000L));
         }
     }
 

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/cache/ImageCache.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/cache/ImageCache.java?rev=1681108&r1=1681107&r2=1681108&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/cache/ImageCache.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/cache/ImageCache.java Fri May 22 13:26:12 2015
@@ -56,7 +56,7 @@ import org.apache.xmlgraphics.image.load
 public class ImageCache {
 
     /** logger */
-    protected static Log log = LogFactory.getLog(ImageCache.class);
+    protected static final Log log = LogFactory.getLog(ImageCache.class);
 
     //Handling of invalid URIs
     private Map invalidURIs = Collections.synchronizedMap(new java.util.HashMap());
@@ -161,7 +161,7 @@ public class ImageCache {
         Long timestamp = (Long) invalidURIs.get(uri);
         boolean expired = (timestamp == null)
                 || this.invalidURIExpirationPolicy.isExpired(
-                        this.timeStampProvider, timestamp.longValue());
+                        this.timeStampProvider, timestamp);
         if (expired) {
             this.invalidURIs.remove(uri);
         }
@@ -203,7 +203,7 @@ public class ImageCache {
      * @param uri the URI of the invalid image
      */
     void registerInvalidURI(String uri) {
-        invalidURIs.put(uri, new Long(timeStampProvider.getTimeStamp()));
+        invalidURIs.put(uri, timeStampProvider.getTimeStamp());
 
         considerHouseKeeping();
     }

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/cache/ImageCacheStatistics.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/cache/ImageCacheStatistics.java?rev=1681108&r1=1681107&r2=1681108&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/cache/ImageCacheStatistics.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/cache/ImageCacheStatistics.java Fri May 22 13:26:12 2015
@@ -73,9 +73,9 @@ public class ImageCacheStatistics implem
     private void increaseEntry(Map map, Object key) {
         Integer v = (Integer)map.get(key);
         if (v == null) {
-            v = new Integer(1);
+            v = 1;
         } else {
-            v = new Integer(v.intValue() + 1);
+            v++;
         }
         map.put(key, v);
     }

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/AbstractImageLoader.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/AbstractImageLoader.java?rev=1681108&r1=1681107&r2=1681108&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/AbstractImageLoader.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/AbstractImageLoader.java Fri May 22 13:26:12 2015
@@ -56,7 +56,7 @@ public abstract class AbstractImageLoade
             return false;
         }
         Boolean b = (Boolean)hints.get(ImageProcessingHints.IGNORE_COLOR_PROFILE);
-        return (b != null) && b.booleanValue();
+        return (b != null) && b;
     }
 
 }

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/AbstractImageSessionContext.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/AbstractImageSessionContext.java?rev=1681108&r1=1681107&r2=1681108&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/AbstractImageSessionContext.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/AbstractImageSessionContext.java Fri May 22 13:26:12 2015
@@ -53,7 +53,7 @@ import org.apache.xmlgraphics.io.XmlSour
 public abstract class AbstractImageSessionContext implements ImageSessionContext {
 
     /** logger */
-    private static Log log = LogFactory.getLog(AbstractImageSessionContext.class);
+    private static final Log log = LogFactory.getLog(AbstractImageSessionContext.class);
 
     private static boolean noSourceReuse;
 
@@ -302,19 +302,17 @@ public abstract class AbstractImageSessi
                         return null;
                     }
                 }
-                if (in != null) {
-                    in = ImageUtil.decorateMarkSupported(in);
-                    try {
-                        if (ImageUtil.isGZIPCompressed(in)) {
-                            //GZIPped stream are not seekable, so buffer/cache like other URLs
-                            directFileAccess = false;
-                        }
-                    } catch (IOException ioe) {
-                        log.error("Error while checking the InputStream for GZIP compression."
-                                + " Could not load image from system identifier '"
-                                + source.getSystemId() + "' (" + ioe.getMessage() + ")");
-                        return null;
+                in = ImageUtil.decorateMarkSupported(in);
+                try {
+                    if (ImageUtil.isGZIPCompressed(in)) {
+                        //GZIPped stream are not seekable, so buffer/cache like other URLs
+                        directFileAccess = false;
                     }
+                } catch (IOException ioe) {
+                    log.error("Error while checking the InputStream for GZIP compression."
+                            + " Could not load image from system identifier '"
+                            + source.getSystemId() + "' (" + ioe.getMessage() + ")");
+                    return null;
                 }
 
                 if (directFileAccess) {

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/CompositeImageLoader.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/CompositeImageLoader.java?rev=1681108&r1=1681107&r2=1681108&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/CompositeImageLoader.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/CompositeImageLoader.java Fri May 22 13:26:12 2015
@@ -39,7 +39,7 @@ import org.apache.xmlgraphics.image.load
 public class CompositeImageLoader extends AbstractImageLoader {
 
     /** logger */
-    protected static Log log = LogFactory.getLog(CompositeImageLoader.class);
+    protected static final Log log = LogFactory.getLog(CompositeImageLoader.class);
 
     private ImageLoader[] loaders;
 
@@ -57,7 +57,7 @@ public class CompositeImageLoader extend
                         "All ImageLoaders must produce the same target flavor");
             }
         }
-        this.loaders = loaders;
+        this.loaders = loaders.clone();
     }
 
     /** {@inheritDoc} */

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/ImageConverterBitmap2G2D.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/ImageConverterBitmap2G2D.java?rev=1681108&r1=1681107&r2=1681108&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/ImageConverterBitmap2G2D.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/ImageConverterBitmap2G2D.java Fri May 22 13:26:12 2015
@@ -38,36 +38,39 @@ public class ImageConverterBitmap2G2D ex
     /** {@inheritDoc} */
     public Image convert(Image src, Map hints) {
         checkSourceFlavor(src);
+        assert src instanceof ImageRendered;
         final ImageRendered rendImage = (ImageRendered)src;
 
-        Graphics2DImagePainter painter = new Graphics2DImagePainter() {
-
-            public Dimension getImageSize() {
-                return rendImage.getSize().getDimensionMpt();
-            }
-
-            public void paint(Graphics2D g2d, Rectangle2D area) {
-                RenderedImage ri = rendImage.getRenderedImage();
-                double w = area.getWidth();
-                double h = area.getHeight();
-
-                AffineTransform at = new AffineTransform();
-                at.translate(area.getX(), area.getY());
-                //Scale image to fit
-                double sx = w / ri.getWidth();
-                double sy = h / ri.getHeight();
-                if (sx != 1.0 || sy != 1.0) {
-                    at.scale(sx, sy);
-                }
-                g2d.drawRenderedImage(ri, at);
-            }
-
-        };
-
+        Graphics2DImagePainterImpl painter = new Graphics2DImagePainterImpl(rendImage);
         ImageGraphics2D g2dImage = new ImageGraphics2D(src.getInfo(), painter);
         return g2dImage;
     }
 
+    static class Graphics2DImagePainterImpl implements Graphics2DImagePainter {
+        ImageRendered rendImage;
+        public Graphics2DImagePainterImpl(ImageRendered rendImage) {
+            this.rendImage = rendImage;
+        }
+        public Dimension getImageSize() {
+            return rendImage.getSize().getDimensionMpt();
+        }
+        public void paint(Graphics2D g2d, Rectangle2D area) {
+            RenderedImage ri = rendImage.getRenderedImage();
+            double w = area.getWidth();
+            double h = area.getHeight();
+
+            AffineTransform at = new AffineTransform();
+            at.translate(area.getX(), area.getY());
+            //Scale image to fit
+            double sx = w / ri.getWidth();
+            double sy = h / ri.getHeight();
+            if (sx != 1.0 || sy != 1.0) {
+                at.scale(sx, sy);
+            }
+            g2d.drawRenderedImage(ri, at);
+        }
+    }
+
     /** {@inheritDoc} */
     public ImageFlavor getSourceFlavor() {
         return ImageFlavor.RENDERED_IMAGE;

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/ImageConverterBuffered2Rendered.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/ImageConverterBuffered2Rendered.java?rev=1681108&r1=1681107&r2=1681108&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/ImageConverterBuffered2Rendered.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/ImageConverterBuffered2Rendered.java Fri May 22 13:26:12 2015
@@ -33,6 +33,7 @@ public class ImageConverterBuffered2Rend
     /** {@inheritDoc} */
     public Image convert(Image src, Map hints) {
         checkSourceFlavor(src);
+        assert src instanceof ImageBuffered;
         ImageBuffered buffered = (ImageBuffered)src;
         return new ImageRendered(buffered.getInfo(), buffered
                 .getRenderedImage(), buffered.getTransparentColor());

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/ImageConverterG2D2Bitmap.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/ImageConverterG2D2Bitmap.java?rev=1681108&r1=1681107&r2=1681108&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/ImageConverterG2D2Bitmap.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/ImageConverterG2D2Bitmap.java Fri May 22 13:26:12 2015
@@ -49,6 +49,7 @@ public class ImageConverterG2D2Bitmap ex
     /** {@inheritDoc} */
     public Image convert(Image src, Map hints) {
         checkSourceFlavor(src);
+        assert src instanceof ImageGraphics2D;
         ImageGraphics2D g2dImage = (ImageGraphics2D)src;
 
         Object formatIntent = hints.get(ImageProcessingHints.BITMAP_TYPE_INTENT);

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/ImageConverterRendered2PNG.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/ImageConverterRendered2PNG.java?rev=1681108&r1=1681107&r2=1681108&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/ImageConverterRendered2PNG.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/ImageConverterRendered2PNG.java Fri May 22 13:26:12 2015
@@ -40,6 +40,7 @@ public class ImageConverterRendered2PNG
     /** {@inheritDoc} */
     public Image convert(Image src, Map hints) throws ImageException, IOException {
         checkSourceFlavor(src);
+        assert src instanceof ImageRendered;
         ImageRendered rendered = (ImageRendered)src;
         ImageWriter writer = ImageWriterRegistry.getInstance().getWriterFor(MimeConstants.MIME_PNG);
         if (writer == null) {

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/ImageLoaderFactoryEPS.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/ImageLoaderFactoryEPS.java?rev=1681108&r1=1681107&r2=1681108&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/ImageLoaderFactoryEPS.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/ImageLoaderFactoryEPS.java Fri May 22 13:26:12 2015
@@ -37,13 +37,13 @@ public class ImageLoaderFactoryEPS exten
 
     /** {@inheritDoc} */
     public String[] getSupportedMIMETypes() {
-        return MIMES;
+        return MIMES.clone();
     }
 
     /** {@inheritDoc} */
     public ImageFlavor[] getSupportedFlavors(String mime) {
         if (MimeConstants.MIME_EPS.equals(mime)) {
-            return FLAVORS;
+            return FLAVORS.clone();
         }
         throw new IllegalArgumentException("Unsupported MIME type: " + mime);
     }

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/ImageLoaderFactoryInternalTIFF.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/ImageLoaderFactoryInternalTIFF.java?rev=1681108&r1=1681107&r2=1681108&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/ImageLoaderFactoryInternalTIFF.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/ImageLoaderFactoryInternalTIFF.java Fri May 22 13:26:12 2015
@@ -37,13 +37,13 @@ public class ImageLoaderFactoryInternalT
 
     /** {@inheritDoc} */
     public String[] getSupportedMIMETypes() {
-        return MIMES;
+        return MIMES.clone();
     }
 
     /** {@inheritDoc} */
     public ImageFlavor[] getSupportedFlavors(String mime) {
         if (MimeConstants.MIME_TIFF.equals(mime)) {
-            return FLAVORS;
+            return FLAVORS.clone();
         }
         throw new IllegalArgumentException("Unsupported MIME type: " + mime);
     }

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/ImageLoaderFactoryPNG.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/ImageLoaderFactoryPNG.java?rev=1681108&r1=1681107&r2=1681108&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/ImageLoaderFactoryPNG.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/ImageLoaderFactoryPNG.java Fri May 22 13:26:12 2015
@@ -35,13 +35,13 @@ public class ImageLoaderFactoryPNG exten
 
     /** {@inheritDoc} */
     public String[] getSupportedMIMETypes() {
-        return MIMES;
+        return MIMES.clone();
     }
 
     /** {@inheritDoc} */
     public ImageFlavor[] getSupportedFlavors(String mime) {
         if (MimeConstants.MIME_PNG.equals(mime)) {
-            return FLAVORS;
+            return FLAVORS.clone();
         }
         throw new IllegalArgumentException("Unsupported MIME type: " + mime);
     }

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/ImageLoaderFactoryRaw.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/ImageLoaderFactoryRaw.java?rev=1681108&r1=1681107&r2=1681108&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/ImageLoaderFactoryRaw.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/ImageLoaderFactoryRaw.java Fri May 22 13:26:12 2015
@@ -64,14 +64,14 @@ public class ImageLoaderFactoryRaw exten
 
     /** {@inheritDoc} */
     public String[] getSupportedMIMETypes() {
-        return MIMES;
+        return MIMES.clone();
     }
 
     /** {@inheritDoc} */
     public ImageFlavor[] getSupportedFlavors(String mime) {
         for (int i = 0, c = MIMES.length; i < c; i++) {
             if (MIMES[i].equals(mime)) {
-                return FLAVORS[i];
+                return FLAVORS[i].clone();
             }
         }
         throw new IllegalArgumentException("Unsupported MIME type: " + mime);

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/ImageLoaderFactoryRawCCITTFax.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/ImageLoaderFactoryRawCCITTFax.java?rev=1681108&r1=1681107&r2=1681108&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/ImageLoaderFactoryRawCCITTFax.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/ImageLoaderFactoryRawCCITTFax.java Fri May 22 13:26:12 2015
@@ -63,14 +63,14 @@ public class ImageLoaderFactoryRawCCITTF
 
     /** {@inheritDoc} */
     public String[] getSupportedMIMETypes() {
-        return MIMES;
+        return MIMES.clone();
     }
 
     /** {@inheritDoc} */
     public ImageFlavor[] getSupportedFlavors(String mime) {
         for (int i = 0, c = MIMES.length; i < c; i++) {
             if (MIMES[i].equals(mime)) {
-                return FLAVORS[i];
+                return FLAVORS[i].clone();
             }
         }
         throw new IllegalArgumentException("Unsupported MIME type: " + mime);
@@ -102,12 +102,12 @@ public class ImageLoaderFactoryRawCCITTF
         if (compression == null) {
             return false;
         }
-        switch (compression.intValue()) {
+        switch (compression) {
         case TIFFImage.COMP_FAX_G3_1D:
         case TIFFImage.COMP_FAX_G3_2D:
         case TIFFImage.COMP_FAX_G4_2D:
             Integer stripCount = (Integer)imageInfo.getCustomObjects().get("TIFF_STRIP_COUNT");
-            boolean supported = (stripCount != null && stripCount.intValue() == 1);
+            boolean supported = (stripCount != null && stripCount == 1);
             if (!supported) {
                 log.trace("Raw CCITT loading not supported for multi-strip TIFF image");
             }

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/ImageLoaderInternalTIFF.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/ImageLoaderInternalTIFF.java?rev=1681108&r1=1681107&r2=1681108&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/ImageLoaderInternalTIFF.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/ImageLoaderInternalTIFF.java Fri May 22 13:26:12 2015
@@ -43,7 +43,7 @@ import org.apache.xmlgraphics.image.load
 public class ImageLoaderInternalTIFF extends AbstractImageLoader {
 
     /** logger */
-    protected static Log log = LogFactory.getLog(ImageLoaderInternalTIFF.class);
+    protected static final Log log = LogFactory.getLog(ImageLoaderInternalTIFF.class);
 
     /**
      * Main constructor.

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/ImageLoaderRawCCITTFax.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/ImageLoaderRawCCITTFax.java?rev=1681108&r1=1681107&r2=1681108&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/ImageLoaderRawCCITTFax.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/ImageLoaderRawCCITTFax.java Fri May 22 13:26:12 2015
@@ -57,7 +57,7 @@ public class ImageLoaderRawCCITTFax exte
     private static final int COMPRESSION_FAX_GROUP4 = 4;
 
     /** logger */
-    protected static Log log = LogFactory.getLog(ImageLoaderRawCCITTFax.class);
+    protected static final Log log = LogFactory.getLog(ImageLoaderRawCCITTFax.class);
 
     /**
      * Main constructor.

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/ImageLoaderRawJPEG.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/ImageLoaderRawJPEG.java?rev=1681108&r1=1681107&r2=1681108&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/ImageLoaderRawJPEG.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/ImageLoaderRawJPEG.java Fri May 22 13:26:12 2015
@@ -51,7 +51,7 @@ import org.apache.xmlgraphics.util.MimeC
 public class ImageLoaderRawJPEG extends AbstractImageLoader implements JPEGConstants {
 
     /** logger */
-    protected static Log log = LogFactory.getLog(ImageLoaderRawJPEG.class);
+    protected static final Log log = LogFactory.getLog(ImageLoaderRawJPEG.class);
 
     /**
      * Main constructor.

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/ImageLoaderRawPNG.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/ImageLoaderRawPNG.java?rev=1681108&r1=1681107&r2=1681108&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/ImageLoaderRawPNG.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/ImageLoaderRawPNG.java Fri May 22 13:26:12 2015
@@ -44,7 +44,7 @@ import org.apache.xmlgraphics.util.MimeC
 public class ImageLoaderRawPNG extends AbstractImageLoader {
 
     /** logger */
-    protected static Log log = LogFactory.getLog(ImageLoaderRawPNG.class);
+    protected static final Log log = LogFactory.getLog(ImageLoaderRawPNG.class);
 
     /**
      * Main constructor.

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/ImageRawStream.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/ImageRawStream.java?rev=1681108&r1=1681107&r2=1681108&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/ImageRawStream.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/ImageRawStream.java Fri May 22 13:26:12 2015
@@ -193,7 +193,7 @@ public class ImageRawStream extends Abst
          * @param data the byte array
          */
         public ByteArrayStreamFactory(byte[] data) {
-            this.data = data;
+            this.data = data.clone();
         }
 
         /** {@inheritDoc} */

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/JPEGFile.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/JPEGFile.java?rev=1681108&r1=1681107&r2=1681108&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/JPEGFile.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/JPEGFile.java Fri May 22 13:26:12 2015
@@ -34,7 +34,7 @@ import org.apache.commons.logging.LogFac
 public class JPEGFile implements JPEGConstants {
 
     /** logger */
-    protected static Log log = LogFactory.getLog(JPEGFile.class);
+    protected static final Log log = LogFactory.getLog(JPEGFile.class);
 
     private DataInput in;
 

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/PNGFile.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/PNGFile.java?rev=1681108&r1=1681107&r2=1681108&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/PNGFile.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/PNGFile.java Fri May 22 13:26:12 2015
@@ -196,8 +196,8 @@ class PNGFile implements PNGConstants {
     }
 
     private void parse_IHDR_chunk(PNGChunk chunk) {
-        int width = chunk.getInt4(0);
-        int height = chunk.getInt4(4);
+        chunk.getInt4(0);
+        chunk.getInt4(4);
         bitDepth = chunk.getInt1(8);
         if (bitDepth != 8) {
             // this is a limitation of the current implementation
@@ -268,13 +268,11 @@ class PNGFile implements PNGConstants {
 
     private void parse_iCCP_chunk(PNGChunk chunk) {
         int length = chunk.getLength();
-        String name = ""; // todo simplify this
-        byte b;
         int textIndex = 0;
-        while ((b = chunk.getByte(textIndex++)) != 0) {
-            name += (char) b;
+        while (chunk.getByte(textIndex++) != 0) {
+            //NOP
         }
-        byte compression = chunk.getByte(textIndex++);
+        chunk.getByte(textIndex++);
         byte[] profile = new byte[length - textIndex];
         System.arraycopy(chunk.getData(), textIndex, profile, 0, length - textIndex);
         ByteArrayInputStream bais = new ByteArrayInputStream(profile);

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/PreloaderJPEG.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/PreloaderJPEG.java?rev=1681108&r1=1681107&r2=1681108&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/PreloaderJPEG.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/PreloaderJPEG.java Fri May 22 13:26:12 2015
@@ -115,7 +115,7 @@ public class PreloaderJPEG extends Abstr
                     int bytesToEnd = reclen - 2;
                     // read Exif Header: 0x.45.78.69.66.00.00
                     int exif = in.readInt(); // 0x.45.78.69.66
-                    int tail = in.readUnsignedShort(); // 0x.00.00
+                    in.readUnsignedShort(); // 0x.00.00
                     // in.skipBytes(6);
                     bytesToEnd -= 6;
                     if (exif != EXIF) {
@@ -184,7 +184,7 @@ public class PreloaderJPEG extends Abstr
                         bytesToEnd -= 12;
                         currentTIFFOffset += 12;
                     }
-                    int nextIFDOffset = in.readInt(); // not needed, but has thumbnail info
+                    in.readInt(); // not needed, but has thumbnail info
                     bytesToEnd -= 4;
                     currentTIFFOffset += 4;
                     if (resolutionOffset != 0) {

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/PreloaderTIFF.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/PreloaderTIFF.java?rev=1681108&r1=1681107&r2=1681108&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/PreloaderTIFF.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/PreloaderTIFF.java Fri May 22 13:26:12 2015
@@ -104,7 +104,7 @@ public class PreloaderTIFF extends Abstr
                 dir = new TIFFDirectory(seekable, pageIndex);
             } catch (IllegalArgumentException iae) {
                 String errorMessage = MessageFormat.format(
-                        "Subimage {0} does not exist.", new Object[] {new Integer(pageIndex)});
+                        "Subimage {0} does not exist.", new Object[] {pageIndex});
                 throw new SubImageNotFoundException(errorMessage);
             }
             int width = (int)dir.getFieldAsLong(TIFFImageDecoder.TIFF_IMAGE_WIDTH);
@@ -157,7 +157,7 @@ public class PreloaderTIFF extends Abstr
                 if (log.isTraceEnabled()) {
                     log.trace("TIFF compression: " + compression);
                 }
-                info.getCustomObjects().put("TIFF_COMPRESSION", new Integer(compression));
+                info.getCustomObjects().put("TIFF_COMPRESSION", compression);
             }
 
             fld = dir.getField(TIFFImageDecoder.TIFF_TILE_WIDTH);
@@ -178,7 +178,7 @@ public class PreloaderTIFF extends Abstr
             if (log.isTraceEnabled()) {
                 log.trace("TIFF has " + stripCount + " strips.");
             }
-            info.getCustomObjects().put("TIFF_STRIP_COUNT", new Integer(stripCount));
+            info.getCustomObjects().put("TIFF_STRIP_COUNT", stripCount);
 
             try {
                 //Check if there is a next page

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/imageio/ImageIOUtil.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/imageio/ImageIOUtil.java?rev=1681108&r1=1681107&r2=1681108&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/imageio/ImageIOUtil.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/imageio/ImageIOUtil.java Fri May 22 13:26:12 2015
@@ -25,6 +25,8 @@ import javax.xml.transform.OutputKeys;
 import javax.xml.transform.Result;
 import javax.xml.transform.Source;
 import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
 import javax.xml.transform.TransformerFactory;
 import javax.xml.transform.dom.DOMSource;
 import javax.xml.transform.stream.StreamResult;
@@ -113,14 +115,17 @@ public final class ImageIOUtil {
      * @param node a W3C DOM node
      */
     private static void dumpNodeToSystemOut(Node node) {
+        Transformer trans = null;
         try {
-            Transformer trans = TransformerFactory.newInstance().newTransformer();
+            trans = TransformerFactory.newInstance().newTransformer();
             trans.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
             trans.setOutputProperty(OutputKeys.INDENT, "yes");
             Source src = new DOMSource(node);
             Result res = new StreamResult(System.out);
             trans.transform(src, res);
-        } catch (Exception e) {
+        } catch (TransformerConfigurationException e) {
+            e.printStackTrace();
+        } catch (TransformerException e) {
             e.printStackTrace();
         }
     }

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/imageio/ImageLoaderFactoryImageIO.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/imageio/ImageLoaderFactoryImageIO.java?rev=1681108&r1=1681107&r2=1681108&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/imageio/ImageLoaderFactoryImageIO.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/imageio/ImageLoaderFactoryImageIO.java Fri May 22 13:26:12 2015
@@ -41,7 +41,7 @@ public class ImageLoaderFactoryImageIO e
 
     /** {@inheritDoc} */
     public ImageFlavor[] getSupportedFlavors(String mime) {
-        return FLAVORS;
+        return FLAVORS.clone();
     }
 
     /** {@inheritDoc} */

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/imageio/ImageLoaderImageIO.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/imageio/ImageLoaderImageIO.java?rev=1681108&r1=1681107&r2=1681108&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/imageio/ImageLoaderImageIO.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/impl/imageio/ImageLoaderImageIO.java Fri May 22 13:26:12 2015
@@ -74,7 +74,7 @@ import org.apache.xmlgraphics.java2d.col
 public class ImageLoaderImageIO extends AbstractImageLoader {
 
     /** logger */
-    protected static Log log = LogFactory.getLog(ImageLoaderImageIO.class);
+    protected static final Log log = LogFactory.getLog(ImageLoaderImageIO.class);
 
     private ImageFlavor targetFlavor;
 
@@ -124,15 +124,15 @@ public class ImageLoaderImageIO extends
                     reader.setInput(imgStream, false, ignoreMetadata);
                     final int pageIndex = ImageUtil.needPageIndexFromURI(info.getOriginalURI());
                     try {
-                        if (ImageFlavor.BUFFERED_IMAGE.equals(this.targetFlavor)) {
-                            imageData = reader.read(pageIndex, param);
-                        } else {
+//                        if (ImageFlavor.BUFFERED_IMAGE.equals(this.targetFlavor)) {
                             imageData = reader.read(pageIndex, param);
+//                        } else {
+//                            imageData = reader.read(pageIndex, param);
                             //imageData = reader.readAsRenderedImage(pageIndex, param);
                             //TODO Reenable the above when proper listeners are implemented
                             //to react to late pixel population (so the stream can be closed
                             //properly).
-                        }
+//                        }
                         if (iiometa == null) {
                             iiometa = reader.getImageMetadata(pageIndex);
                         }
@@ -228,7 +228,7 @@ public class ImageLoaderImageIO extends
                     child = ImageIOUtil.getChild(dim, "TransparentColor");
                     if (child != null) {
                         String value = child.getAttribute("value");
-                        if (value == null || value.length() == 0) {
+                        if (value.length() == 0) {
                             //ignore
                         } else if (cm.getNumColorComponents() == 1) {
                             int gray = Integer.parseInt(value);

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/pipeline/ImageProviderPipeline.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/pipeline/ImageProviderPipeline.java?rev=1681108&r1=1681107&r2=1681108&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/pipeline/ImageProviderPipeline.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/pipeline/ImageProviderPipeline.java Fri May 22 13:26:12 2015
@@ -50,7 +50,7 @@ import org.apache.xmlgraphics.image.load
 public class ImageProviderPipeline {
 
     /** logger */
-    protected static Log log = LogFactory.getLog(ImageProviderPipeline.class);
+    protected static final Log log = LogFactory.getLog(ImageProviderPipeline.class);
 
     private ImageCache cache;
     private ImageLoader loader;

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/pipeline/ImageRepresentation.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/pipeline/ImageRepresentation.java?rev=1681108&r1=1681107&r2=1681108&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/pipeline/ImageRepresentation.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/pipeline/ImageRepresentation.java Fri May 22 13:26:12 2015
@@ -52,7 +52,8 @@ public class ImageRepresentation impleme
 
     /** {@inheritDoc} */
     public boolean equals(Object obj) {
-        return toString().equals(((ImageRepresentation)obj).toString());
+        assert obj != null;
+        return toString().equals(obj.toString());
     }
 
     /** {@inheritDoc} */

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/pipeline/PipelineFactory.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/pipeline/PipelineFactory.java?rev=1681108&r1=1681107&r2=1681108&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/pipeline/PipelineFactory.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/pipeline/PipelineFactory.java Fri May 22 13:26:12 2015
@@ -19,6 +19,7 @@
 
 package org.apache.xmlgraphics.image.loader.pipeline;
 
+import java.io.Serializable;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Comparator;
@@ -49,7 +50,7 @@ import org.apache.xmlgraphics.util.dijks
 public class PipelineFactory {
 
     /** logger */
-    protected static Log log = LogFactory.getLog(PipelineFactory.class);
+    protected static final Log log = LogFactory.getLog(PipelineFactory.class);
 
     private ImageManager manager;
 
@@ -195,7 +196,9 @@ public class PipelineFactory {
     }
 
     /** Compares two pipelines based on their conversion penalty. */
-    private static class PipelineComparator implements Comparator {
+    private static class PipelineComparator implements Comparator, Serializable {
+
+        private static final long serialVersionUID = 1161513617996198090L;
 
         public int compare(Object o1, Object o2) {
             ImageProviderPipeline p1 = (ImageProviderPipeline)o1;

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/spi/ImageImplRegistry.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/spi/ImageImplRegistry.java?rev=1681108&r1=1681107&r2=1681108&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/spi/ImageImplRegistry.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/spi/ImageImplRegistry.java Fri May 22 13:26:12 2015
@@ -42,7 +42,7 @@ import org.apache.xmlgraphics.util.Servi
 public class ImageImplRegistry {
 
     /** logger */
-    protected static Log log = LogFactory.getLog(ImageImplRegistry.class);
+    protected static final Log log = LogFactory.getLog(ImageImplRegistry.class);
 
     /** Infinite penalty value which shall force any implementation to become ineligible. */
     public static final int INFINITE_PENALTY = Integer.MAX_VALUE;
@@ -68,7 +68,7 @@ public class ImageImplRegistry {
     //Note: String as key chosen to avoid possible class-unloading leaks
 
     /** Singleton instance */
-    private static ImageImplRegistry defaultInstance;
+    private static ImageImplRegistry defaultInstance = new ImageImplRegistry();
 
     /**
      * Main constructor. This constructor allows to disable plug-in discovery for testing purposes.
@@ -92,9 +92,6 @@ public class ImageImplRegistry {
      * @return the default instance
      */
     public static ImageImplRegistry getDefaultInstance() {
-        if (defaultInstance == null) {
-            defaultInstance = new ImageImplRegistry();
-        }
         return defaultInstance;
     }
 
@@ -257,26 +254,30 @@ public class ImageImplRegistry {
         sortPreloaders();
         final Iterator iter = this.preloaders.iterator();
         //Unpack the holders
-        return new Iterator() {
-
-            public boolean hasNext() {
-                return iter.hasNext();
-            }
-
-            public Object next() {
-                Object obj = iter.next();
-                if (obj != null) {
-                    return ((PreloaderHolder)obj).preloader;
-                } else {
-                    return null;
-                }
+        MyIterator i = new MyIterator();
+        i.iter = iter;
+        return i;
+    }
+
+    static class MyIterator implements Iterator {
+        Iterator iter;
+        public boolean hasNext() {
+            return iter.hasNext();
+        }
+
+        public Object next() {
+            Object obj = iter.next();
+            if (obj != null) {
+                return ((PreloaderHolder)obj).preloader;
+            } else {
+                return null;
             }
+        }
 
-            public void remove() {
-                iter.remove();
-            }
+        public void remove() {
+            iter.remove();
+        }
 
-        };
     }
 
     /**
@@ -323,13 +324,13 @@ public class ImageImplRegistry {
     public ImageLoaderFactory[] getImageLoaderFactories(ImageInfo imageInfo, ImageFlavor flavor) {
         String mime = imageInfo.getMimeType();
         Collection matches = new java.util.TreeSet(new ImageLoaderFactoryComparator(flavor));
-        Map flavorMap = (Map)loaders.get(mime);
+        Map flavorMap = (Map) loaders.get(mime);
         if (flavorMap != null) {
-            Iterator flavorIter = flavorMap.keySet().iterator();
-            while (flavorIter.hasNext()) {
-                ImageFlavor checkFlavor = (ImageFlavor)flavorIter.next();
+            for (Object i : flavorMap.entrySet()) {
+                Map.Entry e = (Map.Entry) i;
+                ImageFlavor checkFlavor = (ImageFlavor) e.getKey();
                 if (checkFlavor.isCompatible(flavor)) {
-                    List factoryList = (List)flavorMap.get(checkFlavor);
+                    List factoryList = (List)e.getValue();
                     if (factoryList != null && factoryList.size() > 0) {
                         Iterator factoryIter = factoryList.iterator();
                         while (factoryIter.hasNext()) {
@@ -366,8 +367,8 @@ public class ImageImplRegistry {
 
             ImageLoaderFactory f2 = (ImageLoaderFactory)o2;
             ImageLoader l2 = f2.newImageLoader(targetFlavor);
-            long p2 = l2.getUsagePenalty();
-            p2 = getAdditionalPenalty(l2.getClass().getName()).getValue();
+//            long p2 = l2.getUsagePenalty();
+            long p2 = getAdditionalPenalty(l2.getClass().getName()).getValue();
 
             //Lowest penalty first
             return Penalty.truncate(p1 - p2);
@@ -397,7 +398,7 @@ public class ImageImplRegistry {
                         new ImageLoaderFactory[factoryCount]);
             }
         }
-        return null;
+        return new ImageLoaderFactory[0];
     }
 
     /**

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/util/ImageUtil.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/util/ImageUtil.java?rev=1681108&r1=1681107&r2=1681108&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/util/ImageUtil.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/loader/util/ImageUtil.java Fri May 22 13:26:12 2015
@@ -240,9 +240,9 @@ public final class ImageUtil {
     public static Map getDefaultHints(ImageSessionContext session) {
         java.util.Map hints = new java.util.HashMap();
         hints.put(ImageProcessingHints.SOURCE_RESOLUTION,
-                new Float(session.getParentContext().getSourceResolution()));
+                session.getParentContext().getSourceResolution());
         hints.put(ImageProcessingHints.TARGET_RESOLUTION,
-                new Float(session.getTargetResolution()));
+                session.getTargetResolution());
         hints.put(ImageProcessingHints.IMAGE_SESSION_CONTEXT, session);
         return hints;
     }
@@ -287,7 +287,7 @@ public final class ImageUtil {
                     if (sb.length() > 0) {
                         int pageIndex = Integer.parseInt(sb.toString()) - 1;
                         pageIndex = Math.max(0, pageIndex);
-                        return new Integer(pageIndex);
+                        return pageIndex;
                     }
                 }
             }
@@ -314,7 +314,7 @@ public final class ImageUtil {
     public static int needPageIndexFromURI(String uri) {
         Integer res = getPageIndexFromURI(uri);
         if (res != null) {
-            return res.intValue();
+            return res;
         } else {
             return 0;
         }

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/rendered/AbstractRed.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/rendered/AbstractRed.java?rev=1681108&r1=1681107&r2=1681108&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/rendered/AbstractRed.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/rendered/AbstractRed.java Fri May 22 13:26:12 2015
@@ -319,18 +319,17 @@ public abstract class AbstractRed implem
         this.srcs = new Vector();
         if (srcs != null) {
             this.srcs.addAll(srcs);
-        }
-
-        if (srcs.size() != 0) {
-            CachableRed src = (CachableRed)srcs.get(0);
-            if (bounds == null) {
-                bounds = src.getBounds();
-            }
-            if (cm     == null) {
-                cm     = src.getColorModel();
-            }
-            if (sm     == null) {
-                sm     = src.getSampleModel();
+            if (srcs.size() != 0) {
+                CachableRed src = (CachableRed)srcs.get(0);
+                if (bounds == null) {
+                    bounds = src.getBounds();
+                }
+                if (cm     == null) {
+                    cm     = src.getColorModel();
+                }
+                if (sm     == null) {
+                    sm     = src.getSampleModel();
+                }
             }
         }
 

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/rendered/Any2sRGBRed.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/rendered/Any2sRGBRed.java?rev=1681108&r1=1681107&r2=1681108&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/rendered/Any2sRGBRed.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/rendered/Any2sRGBRed.java Fri May 22 13:26:12 2015
@@ -286,6 +286,7 @@ public class Any2sRGBRed extends Abstrac
         }
 
         Raster srcRas = src.getData(wr.getBounds());
+        assert srcRas instanceof WritableRaster;
         WritableRaster srcWr  = (WritableRaster)srcRas;
 
         // Divide out alpha if we have it.  We need to do this since

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/writer/ImageWriterParams.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/writer/ImageWriterParams.java?rev=1681108&r1=1681107&r2=1681108&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/writer/ImageWriterParams.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/writer/ImageWriterParams.java Fri May 22 13:26:12 2015
@@ -100,7 +100,7 @@ public class ImageWriterParams {
      * @param forceBaseline force baseline quantization table
      */
     public void setJPEGQuality(float quality, boolean forceBaseline) {
-        this.jpegQuality = new Float(quality);
+        this.jpegQuality = quality;
         this.jpegForceBaseline = forceBaseline ? Boolean.TRUE : Boolean.FALSE;
     }
 
@@ -177,7 +177,7 @@ public class ImageWriterParams {
      * @param resolution the resolution value
      */
     public void setXResolution(int resolution) {
-        xResolution = Integer.valueOf(resolution);
+        xResolution = resolution;
     }
 
     /**
@@ -192,7 +192,7 @@ public class ImageWriterParams {
      * @param resolution the resolution value
      */
     public void setYResolution(int resolution) {
-        yResolution = Integer.valueOf(resolution);
+        yResolution = resolution;
     }
 
     /**

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/writer/ImageWriterRegistry.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/writer/ImageWriterRegistry.java?rev=1681108&r1=1681107&r2=1681108&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/writer/ImageWriterRegistry.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/writer/ImageWriterRegistry.java Fri May 22 13:26:12 2015
@@ -32,7 +32,7 @@ import org.apache.xmlgraphics.util.Servi
 /**
  * Registry for {@link ImageWriter} implementations.
  */
-public class ImageWriterRegistry {
+public final class ImageWriterRegistry {
 
     private static volatile ImageWriterRegistry instance;
 
@@ -112,7 +112,7 @@ public class ImageWriterRegistry {
             key = key.substring(0, pos);
             value = preferredOrder.get(key);
         }
-        return (value != null) ? value.intValue() : 0;
+        return (value != null) ? value : 0;
     }
 
     /**

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/writer/internal/TIFFImageWriter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/writer/internal/TIFFImageWriter.java?rev=1681108&r1=1681107&r2=1681108&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/writer/internal/TIFFImageWriter.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/writer/internal/TIFFImageWriter.java Fri May 22 13:26:12 2015
@@ -68,8 +68,8 @@ public class TIFFImageWriter extends Abs
                 int denom;
 
                 if (ResolutionUnit.INCH == params.getResolutionUnit()) {
-                    numPixX = params.getXResolution().intValue();
-                    numPixY = params.getYResolution().intValue();
+                    numPixX = params.getXResolution();
+                    numPixY = params.getYResolution();
                     denom = 1;
                 } else {
                     // Set target resolution

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/java2d/TransformStackElement.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/java2d/TransformStackElement.java?rev=1681108&r1=1681107&r2=1681108&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/java2d/TransformStackElement.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/java2d/TransformStackElement.java Fri May 22 13:26:12 2015
@@ -149,7 +149,7 @@ public abstract class TransformStackElem
      * @return array of values containing this transform element's parameters
      */
     public double[] getTransformParameters() {
-        return transformParameters;
+        return transformParameters.clone();
     }
 
     /**

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/java2d/color/profile/NamedColorProfile.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/java2d/color/profile/NamedColorProfile.java?rev=1681108&r1=1681107&r2=1681108&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/java2d/color/profile/NamedColorProfile.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/java2d/color/profile/NamedColorProfile.java Fri May 22 13:26:12 2015
@@ -43,7 +43,7 @@ public class NamedColorProfile {
             RenderingIntent intent) {
         this.profileName = profileName;
         this.copyright = copyright;
-        this.namedColors = namedColors;
+        this.namedColors = namedColors.clone();
         this.renderingIntent = intent;
     }
 

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/java2d/color/profile/NamedColorProfileParser.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/java2d/color/profile/NamedColorProfileParser.java?rev=1681108&r1=1681107&r2=1681108&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/java2d/color/profile/NamedColorProfileParser.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/java2d/color/profile/NamedColorProfileParser.java Fri May 22 13:26:12 2015
@@ -142,7 +142,7 @@ public class NamedColorProfileParser {
 
     private int[] readUInt16Array(DataInput din, int count) throws IOException {
         if (count == 0) {
-            return null;
+            return new int[0];
         }
         int[] result = new int[count];
         for (int i = 0; i < count; i++) {

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/java2d/ps/AbstractPSDocumentGraphics2D.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/java2d/ps/AbstractPSDocumentGraphics2D.java?rev=1681108&r1=1681107&r2=1681108&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/java2d/ps/AbstractPSDocumentGraphics2D.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/java2d/ps/AbstractPSDocumentGraphics2D.java Fri May 22 13:26:12 2015
@@ -41,7 +41,7 @@ import org.apache.xmlgraphics.ps.PSProcS
  */
 public abstract class AbstractPSDocumentGraphics2D extends PSGraphics2D {
 
-    protected static final Integer ZERO = new Integer(0);
+    protected static final Integer ZERO = 0;
 
     protected int width;
     protected int height;
@@ -274,7 +274,7 @@ public abstract class AbstractPSDocument
 
         //Finish document
         gen.writeDSCComment(DSCConstants.TRAILER);
-        gen.writeDSCComment(DSCConstants.PAGES, new Integer(this.pagecount));
+        gen.writeDSCComment(DSCConstants.PAGES, this.pagecount);
         gen.writeDSCComment(DSCConstants.EOF);
         gen.flush();
     }

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/java2d/ps/EPSDocumentGraphics2D.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/java2d/ps/EPSDocumentGraphics2D.java?rev=1681108&r1=1681107&r2=1681108&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/java2d/ps/EPSDocumentGraphics2D.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/java2d/ps/EPSDocumentGraphics2D.java Fri May 22 13:26:12 2015
@@ -50,8 +50,8 @@ public class EPSDocumentGraphics2D exten
 
     /** {@inheritDoc} */
     protected void writeFileHeader() throws IOException {
-        final Long pagewidth = new Long(this.width);
-        final Long pageheight = new Long(this.height);
+        final Long pagewidth = (long) this.width;
+        final Long pageheight = (long) this.height;
 
         //PostScript Header
         gen.writeln(DSCConstants.PS_ADOBE_30 + " " + DSCConstants.EPSF_30);
@@ -63,7 +63,7 @@ public class EPSDocumentGraphics2D exten
         gen.writeDSCComment(DSCConstants.PAGES, DSCConstants.ATEND);
         gen.writeDSCComment(DSCConstants.BBOX, new Object[]
                 {ZERO, ZERO, pagewidth, pageheight});
-        gen.writeDSCComment(DSCConstants.LANGUAGE_LEVEL, new Integer(gen.getPSLevel()));
+        gen.writeDSCComment(DSCConstants.LANGUAGE_LEVEL, gen.getPSLevel());
         gen.writeDSCComment(DSCConstants.END_COMMENTS);
 
         //Prolog
@@ -77,11 +77,11 @@ public class EPSDocumentGraphics2D exten
 
     /** {@inheritDoc} */
     protected void writePageHeader() throws IOException {
-        Integer pageNumber = new Integer(this.pagecount);
+        Integer pageNumber = this.pagecount;
         gen.writeDSCComment(DSCConstants.PAGE, new Object[]
                 {pageNumber.toString(), pageNumber});
         gen.writeDSCComment(DSCConstants.PAGE_BBOX, new Object[]
-                {ZERO, ZERO, new Integer(width), new Integer(height)});
+                {ZERO, ZERO, width, height});
         gen.writeDSCComment(DSCConstants.BEGIN_PAGE_SETUP);
         if (customTextHandler instanceof PSTextHandler) {
             ((PSTextHandler)customTextHandler).writePageSetup();

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/java2d/ps/PSDocumentGraphics2D.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/java2d/ps/PSDocumentGraphics2D.java?rev=1681108&r1=1681107&r2=1681108&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/java2d/ps/PSDocumentGraphics2D.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/java2d/ps/PSDocumentGraphics2D.java Fri May 22 13:26:12 2015
@@ -78,8 +78,8 @@ public class PSDocumentGraphics2D extend
 
     /** {@inheritDoc} */
     protected void writeFileHeader() throws IOException {
-        final Long pagewidth = new Long(this.width);
-        final Long pageheight = new Long(this.height);
+        final Long pagewidth = (long) this.width;
+        final Long pageheight = (long) this.height;
 
         //PostScript Header
         gen.writeln(DSCConstants.PS_ADOBE_30);
@@ -91,7 +91,7 @@ public class PSDocumentGraphics2D extend
         gen.writeDSCComment(DSCConstants.PAGES, DSCConstants.ATEND);
         gen.writeDSCComment(DSCConstants.BBOX, new Object[]
                 {ZERO, ZERO, pagewidth, pageheight});
-        gen.writeDSCComment(DSCConstants.LANGUAGE_LEVEL, new Integer(gen.getPSLevel()));
+        gen.writeDSCComment(DSCConstants.LANGUAGE_LEVEL, gen.getPSLevel());
         gen.writeDSCComment(DSCConstants.END_COMMENTS);
 
         //Defaults
@@ -113,11 +113,11 @@ public class PSDocumentGraphics2D extend
 
     /** {@inheritDoc} */
     protected void writePageHeader() throws IOException {
-        Integer pageNumber = new Integer(this.pagecount);
+        Integer pageNumber = this.pagecount;
         gen.writeDSCComment(DSCConstants.PAGE, new Object[]
                 {pageNumber.toString(), pageNumber});
         gen.writeDSCComment(DSCConstants.PAGE_BBOX, new Object[]
-                {ZERO, ZERO, new Integer(width), new Integer(height)});
+                {ZERO, ZERO, width, height});
         gen.writeDSCComment(DSCConstants.BEGIN_PAGE_SETUP);
         gen.writeln("<<");
         gen.writeln("/PageSize [" + width + " " + height + "]");

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/java2d/ps/PSTilingPattern.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/java2d/ps/PSTilingPattern.java?rev=1681108&r1=1681107&r2=1681108&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/java2d/ps/PSTilingPattern.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/java2d/ps/PSTilingPattern.java Fri May 22 13:26:12 2015
@@ -437,8 +437,8 @@ public class PSTilingPattern {
             ^ ((xUID != null) ? xUID.hashCode() : 0)
             ^ ((paintProc != null) ? paintProc.hashCode() : 0)
             ^ ((bBox != null) ? bBox.hashCode() : 0)
-            ^ new Double(xStep).hashCode()
-            ^ new Double(yStep).hashCode()
+            ^ Double.valueOf(xStep).hashCode()
+            ^ Double.valueOf(yStep).hashCode()
             ^ paintType
             ^ tilingType
             ^ ((texture != null) ? texture.hashCode() : 0);

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/ps/PSDictionary.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/ps/PSDictionary.java?rev=1681108&r1=1681107&r2=1681108&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/ps/PSDictionary.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/ps/PSDictionary.java Fri May 22 13:26:12 2015
@@ -21,6 +21,7 @@ package org.apache.xmlgraphics.ps;
 
 import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
 import java.util.StringTokenizer;
 
 // CSOFF: InnerAssignment
@@ -40,7 +41,7 @@ public class PSDictionary extends java.u
         /**
          * Simple token holding class
          */
-        private class Token {
+        private static class Token {
             /**
              * start index in string
              */
@@ -259,12 +260,13 @@ public class PSDictionary extends java.u
         if (dictionaryObj.size() != size()) {
             return false;
         }
-        for (Iterator it = keySet().iterator(); it.hasNext();) {
-            String key = (String) it.next();
+        for (Object e : entrySet()) {
+            Map.Entry entry = (Map.Entry) e;
+            String key = (String) entry.getKey();
             if (!dictionaryObj.containsKey(key)) {
                 return false;
             }
-            if (!dictionaryObj.get(key).equals(get(key))) {
+            if (!dictionaryObj.get(key).equals(entry.getValue())) {
                 return false;
             }
         }
@@ -293,14 +295,14 @@ public class PSDictionary extends java.u
             Object obj = super.get(key);
             if (obj instanceof java.util.ArrayList) {
                 List array = (List)obj;
-                String str = "[";
+                StringBuilder str = new StringBuilder("[");
                 for (int i = 0; i < array.size(); i++) {
                     Object element = array.get(i);
-                    str += element + " ";
+                    str.append(element + " ");
                 }
-                str = str.trim();
-                str += "]";
-                sb.append(str + "\n");
+                String str2 = str.toString().trim();
+                str2 += "]";
+                sb.append(str2 + "\n");
             } else {
                 sb.append(obj.toString() + "\n");
             }

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/ps/PSGenerator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/ps/PSGenerator.java?rev=1681108&r1=1681107&r2=1681108&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/ps/PSGenerator.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/ps/PSGenerator.java Fri May 22 13:26:12 2015
@@ -440,7 +440,7 @@ public class PSGenerator implements PSCo
                 } else if (params[i] == DSCConstants.ATEND) {
                     tempBuffer.append(DSCConstants.ATEND);
                 } else if (params[i] instanceof Double) {
-                    tempBuffer.append(formatDouble(((Double)params[i]).doubleValue()));
+                    tempBuffer.append(formatDouble((Double) params[i]));
                 } else if (params[i] instanceof Number) {
                     tempBuffer.append(params[i].toString());
                 } else if (params[i] instanceof Date) {

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/ps/PSState.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/ps/PSState.java?rev=1681108&r1=1681107&r2=1681108&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/ps/PSState.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/ps/PSState.java Fri May 22 13:26:12 2015
@@ -38,6 +38,7 @@ public class PSState implements Serializ
     public static final String DEFAULT_DASH = "[] 0";
     /** Default color in PostScript */
     public static final Color DEFAULT_RGB_COLOR = Color.black;
+    private static final long serialVersionUID = -3862731539801753248L;
 
     private AffineTransform transform = new AffineTransform();
     private List transformConcatList = new java.util.ArrayList();

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/ps/dsc/DSCParser.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/ps/dsc/DSCParser.java?rev=1681108&r1=1681107&r2=1681108&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/ps/dsc/DSCParser.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/ps/dsc/DSCParser.java Fri May 22 13:26:12 2015
@@ -132,7 +132,7 @@ public class DSCParser implements DSCPar
     private DSCComment parseDSCLine(String line) throws IOException, DSCException {
         int colon = line.indexOf(':');
         String name;
-        String value = "";
+        StringBuilder value = new StringBuilder();
         if (colon > 0) {
             name = line.substring(2, colon);
             int startOfValue = colon + 1;
@@ -140,8 +140,8 @@ public class DSCParser implements DSCPar
                 if (isWhitespace(line.charAt(startOfValue))) {
                     startOfValue++;
                 }
-                value = line.substring(startOfValue).trim();
-                if (value.equals(DSCConstants.ATEND.toString())) {
+                value = new StringBuilder(line.substring(startOfValue).trim());
+                if (value.toString().equals(DSCConstants.ATEND.toString())) {
                     return new DSCAtend(name);
                 }
             }
@@ -154,14 +154,14 @@ public class DSCParser implements DSCPar
                 } else if (!nextLine.startsWith("%%+")) {
                     break;
                 }
-                value = value + nextLine.substring(3);
+                value.append(nextLine.substring(3));
             }
             this.reader.reset();
         } else {
             name = line.substring(2);
-            value = null;
+            return parseDSCComment(name, null);
         }
-        return parseDSCComment(name, value);
+        return parseDSCComment(name, value.toString());
     }
 
     private DSCComment parseDSCComment(String name, String value) {
@@ -458,12 +458,17 @@ public class DSCParser implements DSCPar
         if (handler == null) {
             removeListener(this.nestedDocumentHandler);
         } else {
-            addListener(new DSCListener() {
-                public void processEvent(DSCEvent event, DSCParser parser) throws IOException,
-                        DSCException {
-                    handler.handle(event, parser);
-                }
-            });
+            MyDSCListener l = new MyDSCListener();
+            l.handler = handler;
+            addListener(l);
+        }
+    }
+
+    static class MyDSCListener implements DSCListener {
+        private NestedDocumentHandler handler;
+        public void processEvent(DSCEvent event, DSCParser parser) throws IOException,
+                DSCException {
+            handler.handle(event, parser);
         }
     }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: commits-help@xmlgraphics.apache.org


Mime
View raw message