commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ebo...@apache.org
Subject svn commit: r668746 - in /commons/sandbox/compress/trunk/src/java/org/apache/commons/compress: ArchiverFactory.java CompressorFactory.java PackableObject.java PackableObjectException.java
Date Tue, 17 Jun 2008 17:07:53 GMT
Author: ebourg
Date: Tue Jun 17 10:07:53 2008
New Revision: 668746

URL: http://svn.apache.org/viewvc?rev=668746&view=rev
Log:
Changed PackableObjectException to extends IOException and simplified a couple exception handlings

Modified:
    commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/ArchiverFactory.java
    commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/CompressorFactory.java
    commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/PackableObject.java
    commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/PackableObjectException.java

Modified: commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/ArchiverFactory.java
URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/ArchiverFactory.java?rev=668746&r1=668745&r2=668746&view=diff
==============================================================================
--- commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/ArchiverFactory.java
(original)
+++ commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/ArchiverFactory.java
Tue Jun 17 10:07:53 2008
@@ -67,7 +67,7 @@
 	 * The archiver must implement the archiver interface and must
 	 * be an concrete implementation
 	 * 
-	 * @param className full qualified archiver implementation
+	 * @param clazz full qualified archiver implementation
 	 * @throws ArchiveException if the new archiver does not implement the archiver interface
 	 */
 	public static void registerArchiver(Class clazz) 
@@ -119,7 +119,7 @@
 	 * Returns an archiver, filled with an existing archive.
 	 * Uses the byte header to identify the archiver. If no corresponding
 	 * archiver could be found, a filename extension check will be done.
-	 * @param archivedFile an existing archive
+	 * @param file an existing archive
 	 * @return an archiver, filled with the archive
 	 */
 	public static Archive getInstance(File file) 
@@ -145,12 +145,8 @@
 			throw new ArchiveException("A security violation occured while reading the field ARCHIVER_NAME",
e);
 		} catch (IllegalArgumentException e) {
 			throw new ArchiveException("Internal factory exception", e);
-		} catch (InstantiationException e) {
-			throw new ArchiveException("ArchiverFactory could not create instance", e);
-		} catch (IllegalAccessException e) {
+		} catch (Exception e) {
 			throw new ArchiveException("ArchiverFactory could not create instance", e);
-		} catch (PackableObjectException e) {
-			throw new ArchiveException("ArchiverFactory could not create instance", e);
-		} 
+		}
 	}
 }

Modified: commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/CompressorFactory.java
URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/CompressorFactory.java?rev=668746&r1=668745&r2=668746&view=diff
==============================================================================
--- commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/CompressorFactory.java
(original)
+++ commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/CompressorFactory.java
Tue Jun 17 10:07:53 2008
@@ -63,7 +63,7 @@
 	 * The archiver must implement the archiver interface and must
 	 * be an concrete implementation
 	 * 
-	 * @param className full qualified archiver implementation
+	 * @param clazz full qualified archiver implementation
 	 * @throws ArchiveException if the new archiver does not implement the archiver interface
 	 */
 	public static void registerCompressor(Class clazz) 
@@ -84,7 +84,7 @@
 
 	/**
 	 * Constructor. Takes the name of the implementation.
-	 * @param _name - name of the implementation
+	 * @param name - name of the implementation
 	 */
 	private CompressorFactory(String name) { 
 		this.name = name; 
@@ -103,7 +103,7 @@
 	 * the first matching implementation will be instanciated.
 	 * 
 	 * @return the compressor, or null, if no matching compressor could be found
-	 * @throws CompressorException if the compressor could not be created
+	 * @throws CompressException if the compressor could not be created
 	 */
 	public static Compressor getInstance(String compressorName) 
 		throws CompressException {
@@ -130,7 +130,7 @@
 	 * Returns an archiver, filled with an existing archive.
 	 * Uses the byte header to identify the archiver. If no corresponding
 	 * archiver could be found, a filename extension check will be done.
-	 * @param archivedFile an existing archive
+	 * @param file an existing archive
 	 * @return an archiver, filled with the archive
 	 */
 	public static Compressor getInstance(File file) 
@@ -155,13 +155,9 @@
 			throw new CompressException("A security violation occured while reading the field ARCHIVER_NAME",
e);
 		} catch (IllegalArgumentException e) {
 			throw new CompressException("Internal factory exception", e);
-		} catch (InstantiationException e) {
-			throw new CompressException("CompressorFactory could not create instance", e);
-		} catch (IllegalAccessException e) {
+		} catch (Exception e) {
 			throw new CompressException("CompressorFactory could not create instance", e);
-		} catch (PackableObjectException e) {
-			throw new CompressException("CompressorFactory could not create instance", e);
-		} 
+		}
 	}
 	/**
 	 * <code>BZIP2</code> Compressor Factory

Modified: commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/PackableObject.java
URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/PackableObject.java?rev=668746&r1=668745&r2=668746&view=diff
==============================================================================
--- commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/PackableObject.java
(original)
+++ commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/PackableObject.java
Tue Jun 17 10:07:53 2008
@@ -20,7 +20,6 @@
 
 import java.io.File;
 import java.io.FileInputStream;
-import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.util.Iterator;
 import java.util.List;
@@ -54,10 +53,8 @@
 	/**
 	 * String Chooser.
 	 * @param value
-	 * @param methodName
+	 * @param choose
 	 * @return
-	 * @throws ArchiveException
-	 * @throws FileNotFoundException 
 	 */
 	protected boolean isPackableWith(Object value, int choose) {
 		if(value == null) {
@@ -83,10 +80,9 @@
 	 * @param file the file to identify
 	 * @param packables a list of packables
 	 * @return a matching packable object, or null
-	 * @throws ArchiveException
+	 * @throws IOException
 	 */
-	public static PackableObject identifyByHeader(File file, List packables) 
-		throws PackableObjectException {
+	public static PackableObject identifyByHeader(File file, List packables) throws IOException
{
 		/* FileInputStream for the archive */
 		FileInputStream fis = null;
 		
@@ -129,16 +125,9 @@
 			
 			// No implementation found
 			return null;
-		} catch (FileNotFoundException e) {
-			throw new PackableObjectException("File not found", e);
-		} catch (IOException e) {
-			throw new PackableObjectException("Internal factory exception", e);
+
 		} finally {
-			try {
-				fis.close();
-			} catch (IOException e1) {
-				throw new PackableObjectException("Error while closing InputStream to file", e1);
-			}
+	        fis.close();
 		}
 	}
 }

Modified: commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/PackableObjectException.java
URL: http://svn.apache.org/viewvc/commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/PackableObjectException.java?rev=668746&r1=668745&r2=668746&view=diff
==============================================================================
--- commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/PackableObjectException.java
(original)
+++ commons/sandbox/compress/trunk/src/java/org/apache/commons/compress/PackableObjectException.java
Tue Jun 17 10:07:53 2008
@@ -18,10 +18,12 @@
  */
 package org.apache.commons.compress;
 
+import java.io.IOException;
+
 /**
  * Exception for the archiver. 
  */
-public class PackableObjectException extends Exception {
+public class PackableObjectException extends IOException {
 	/**
 	 * Comment for <code>serialVersionUID</code>
 	 */



Mime
View raw message