xmlgraphics-fop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jerem...@apache.org
Subject svn commit: r234273 - in /xmlgraphics/fop/trunk/src: java-1.4/org/apache/fop/image/ java/org/apache/fop/image/ java/org/apache/fop/image/analyser/
Date Sun, 21 Aug 2005 17:09:49 GMT
Author: jeremias
Date: Sun Aug 21 10:09:37 2005
New Revision: 234273

URL: http://svn.apache.org/viewcvs?rev=234273&view=rev
Log:
Code simplification.

Modified:
    xmlgraphics/fop/trunk/src/java-1.4/org/apache/fop/image/ImageIOImage.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/image/BatikImage.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/image/BmpImage.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/image/GifImage.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/image/JAIImage.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/image/JimiImage.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/image/JpegImage.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/image/TIFFImage.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/image/analyser/EPSReader.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/image/analyser/SVGReader.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/image/analyser/XMLReader.java

Modified: xmlgraphics/fop/trunk/src/java-1.4/org/apache/fop/image/ImageIOImage.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java-1.4/org/apache/fop/image/ImageIOImage.java?rev=234273&r1=234272&r2=234273&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java-1.4/org/apache/fop/image/ImageIOImage.java (original)
+++ xmlgraphics/fop/trunk/src/java-1.4/org/apache/fop/image/ImageIOImage.java Sun Aug 21 10:09:37
2005
@@ -27,6 +27,8 @@
 // ImageIO
 import javax.imageio.ImageIO;
 
+import org.apache.commons.io.IOUtils;
+
 /**
  * FopImage object using ImageIO.
  * @see AbstractFopImage
@@ -145,6 +147,9 @@
         } catch (Exception ex) {
             log.error("Error while loading image: " + ex.getMessage(), ex);
             return false; 
+        } finally {
+            IOUtils.closeQuietly(inputStream);
+            inputStream = null;
         }
         return true;
     }

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/image/BatikImage.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/image/BatikImage.java?rev=234273&r1=234272&r2=234273&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/image/BatikImage.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/image/BatikImage.java Sun Aug 21 10:09:37
2005
@@ -31,6 +31,7 @@
 import org.apache.batik.ext.awt.image.codec.FileCacheSeekableStream;
 import org.apache.batik.ext.awt.image.rendered.Any2sRGBRed;
 import org.apache.batik.ext.awt.image.rendered.CachableRed;
+import org.apache.commons.io.IOUtils;
 
 /**
  * FopImage object using TIFF
@@ -114,16 +115,8 @@
                 }
             } catch (IOException ioe) {
                 log.error("Error while loading image (Batik): " + ioe.getMessage(), ioe);
-                try {
-                    seekableInput.close();
-                } catch (IOException ioex) {
-                    // ignore
-                }
-                try {
-                    inputStream.close();
-                } catch (IOException ioex) {
-                    // ignore
-                }
+                IOUtils.closeQuietly(seekableInput);
+                IOUtils.closeQuietly(inputStream);
                 seekableInput = null;
                 inputStream = null;
                 return false;
@@ -219,16 +212,8 @@
                 log.error("Error while loading image (Batik): " + ex.getMessage(), ex);
             } finally {
                 // Make sure we clean up
-                try {
-                    seekableInput.close();
-                } catch (IOException ioex) {
-                    // ignore
-                }
-                try {
-                    inputStream.close();
-                } catch (IOException ioex) {
-                    // ignore
-                }
+                IOUtils.closeQuietly(seekableInput);
+                IOUtils.closeQuietly(inputStream);
                 seekableInput = null;
                 inputStream = null;
                 cr = null;

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/image/BmpImage.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/image/BmpImage.java?rev=234273&r1=234272&r2=234273&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/image/BmpImage.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/image/BmpImage.java Sun Aug 21 10:09:37
2005
@@ -22,6 +22,8 @@
 import java.io.IOException;
 import java.awt.color.ColorSpace;
 
+import org.apache.commons.io.IOUtils;
+
 /**
  * Bitmap image.
  * This supports loading a bitmap image into bitmap data.
@@ -84,11 +86,7 @@
             }
         } catch (IOException ex) {
             log.error("Error while loading image (Bmp): " + ex.getMessage(), ex);
-            try {
-                inputStream.close();
-            } catch (java.io.IOException ioe) {
-                // Ignore
-            }
+            IOUtils.closeQuietly(inputStream);
             inputStream = null;
             return false;
         }
@@ -147,11 +145,7 @@
             log.error("Error while loading image (Bmp): " + ex.getMessage(), ex);
             return false;
         } finally {
-            try {
-                inputStream.close();
-            } catch (java.io.IOException ioe) {
-                // Ignore
-            }
+            IOUtils.closeQuietly(inputStream);
             inputStream = null;
         }
 

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/image/GifImage.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/image/GifImage.java?rev=234273&r1=234272&r2=234273&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/image/GifImage.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/image/GifImage.java Sun Aug 21 10:09:37
2005
@@ -28,6 +28,8 @@
 import java.io.IOException;
 import java.net.URLConnection;
 
+import org.apache.commons.io.IOUtils;
+
 /**
  * FopImage object for GIF images, using Java native classes.
  * @author Eric SCHAEFFER
@@ -143,11 +145,7 @@
             log.error("Error while loading image (Gif): " + ex.getMessage(), ex);
             return false;
         } finally {
-            try {
-                inputStream.close();
-            } catch (java.io.IOException ioe) {
-                // Ignore
-            }
+            IOUtils.closeQuietly(inputStream);
             inputStream = null;
         }
 

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/image/JAIImage.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/image/JAIImage.java?rev=234273&r1=234272&r2=234273&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/image/JAIImage.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/image/JAIImage.java Sun Aug 21 10:09:37
2005
@@ -28,6 +28,8 @@
 // JAI
 import javax.media.jai.JAI;
 import javax.media.jai.RenderedOp;
+
+import org.apache.commons.io.IOUtils;
 // Sun codec
 import com.sun.media.jai.codec.FileCacheSeekableStream;
 
@@ -154,18 +156,10 @@
         } catch (Exception ex) {
             log.error("Error while loading image (JAI): " + ex.getMessage(), ex);
         } finally {
-            try {
-                inputStream.close();
-            } catch (java.io.IOException ioe) {
-                // Ignore
-            }
+            IOUtils.closeQuietly(inputStream);
             inputStream = null;
             if (seekableInput != null) {
-                try {
-                    seekableInput.close();
-                } catch (java.io.IOException ioe) {
-                    // Ignore
-                }
+                IOUtils.closeQuietly(seekableInput);
             }
         }
     }

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/image/JimiImage.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/image/JimiImage.java?rev=234273&r1=234272&r2=234273&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/image/JimiImage.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/image/JimiImage.java Sun Aug 21 10:09:37
2005
@@ -25,6 +25,8 @@
 import java.awt.color.ColorSpace;
 import java.awt.Color;
 
+import org.apache.commons.io.IOUtils;
+
 // Jimi
 import com.sun.jimi.core.Jimi;
 
@@ -155,11 +157,7 @@
             log.error("Error while loading image (Jimi): " + ex.getMessage(), ex);
             return;
         } finally {
-            try {
-                inputStream.close();
-            } catch (java.io.IOException ioe) {
-                // Ignore
-            }
+            IOUtils.closeQuietly(inputStream);
             inputStream = null;
         }
 

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/image/JpegImage.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/image/JpegImage.java?rev=234273&r1=234272&r2=234273&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/image/JpegImage.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/image/JpegImage.java Sun Aug 21 10:09:37
2005
@@ -24,6 +24,7 @@
 import java.awt.color.ICC_Profile;
 
 // FOP
+import org.apache.commons.io.IOUtils;
 import org.apache.fop.util.CMYKColorSpace;
 
 /**
@@ -69,11 +70,7 @@
             log.error("Error while loading image (Jpeg): " + ex.getMessage(), ex);
             return false;
         } finally {
-            try {
-                inputStream.close();
-            } catch (java.io.IOException ioe) {
-                // Ignore
-            }
+            IOUtils.closeQuietly(inputStream);
             inputStream = null;
         }
 

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/image/TIFFImage.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/image/TIFFImage.java?rev=234273&r1=234272&r2=234273&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/image/TIFFImage.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/image/TIFFImage.java Sun Aug 21 10:09:37
2005
@@ -26,6 +26,7 @@
 import org.apache.batik.ext.awt.image.codec.tiff.TIFFField;
 import org.apache.batik.ext.awt.image.codec.tiff.TIFFImageDecoder;
 import org.apache.batik.ext.awt.image.rendered.CachableRed;
+import org.apache.commons.io.IOUtils;
 
 /**
  * TIFF implementation using the Batik codecs.
@@ -140,16 +141,8 @@
                 log.error("Error while loading image strip 1 (TIFF): ", ioe);
                 return false;
             } finally {
-                try {
-                    this.seekableInput.close();
-                } catch (IOException ioex) {
-                    // ignore
-                }
-                try {
-                    this.inputStream.close();
-                } catch (IOException ioex) {
-                    // ignore
-                }
+                IOUtils.closeQuietly(seekableInput);
+                IOUtils.closeQuietly(inputStream);
                 this.seekableInput = null;
                 this.inputStream = null;
                 this.cr = null;

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/image/analyser/EPSReader.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/image/analyser/EPSReader.java?rev=234273&r1=234272&r2=234273&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/image/analyser/EPSReader.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/image/analyser/EPSReader.java Sun Aug 21
10:09:37 2005
@@ -24,6 +24,7 @@
 import java.io.IOException;
 
 // FOP
+import org.apache.commons.io.IOUtils;
 import org.apache.fop.image.FopImage;
 import org.apache.fop.image.EPSImage;
 import org.apache.fop.apps.FOUserAgent;
@@ -89,7 +90,7 @@
                 info.height = (int) (data.bbox[3] - data.bbox[1]);
 
                 // image data read
-                bis.close();
+                IOUtils.closeQuietly(bis);
                 info.inputStream = null;
 
                 return info;

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/image/analyser/SVGReader.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/image/analyser/SVGReader.java?rev=234273&r1=234272&r2=234273&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/image/analyser/SVGReader.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/image/analyser/SVGReader.java Sun Aug 21
10:09:37 2005
@@ -33,6 +33,7 @@
 import org.apache.batik.bridge.BridgeContext;
 import org.apache.batik.bridge.UnitProcessor;
 import org.apache.batik.dom.svg.SVGDOMImplementation;
+import org.apache.commons.io.IOUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -60,11 +61,7 @@
             FOUserAgent ua) throws IOException {
         FopImage.ImageInfo info = loadImage(uri, fis, ua);
         if (info != null) {
-            try {
-                fis.close();
-            } catch (Exception e) {
-                //ignore
-            }
+            IOUtils.closeQuietly(fis);
         }
         return info;
     }

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/image/analyser/XMLReader.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/image/analyser/XMLReader.java?rev=234273&r1=234272&r2=234273&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/image/analyser/XMLReader.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/image/analyser/XMLReader.java Sun Aug 21
10:09:37 2005
@@ -1,5 +1,5 @@
 /*
- * Copyright 1999-2004 The Apache Software Foundation.
+ * Copyright 1999-2005 The Apache Software Foundation.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -33,6 +33,7 @@
 import org.apache.fop.apps.FOUserAgent;
 
 // Commons-Logging
+import org.apache.commons.io.IOUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -62,11 +63,7 @@
         throws IOException {
         FopImage.ImageInfo info = loadImage(uri, fis, ua);
         if (info != null) {
-            try {
-                fis.close();
-            } catch (Exception e) {
-                //ignore
-            }
+            IOUtils.closeQuietly(fis);
         }
         return info;
     }



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


Mime
View raw message