commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r911381 - /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveEntry.java
Date Thu, 18 Feb 2010 13:08:32 GMT
Author: bodewig
Date: Thu Feb 18 13:08:31 2010
New Revision: 911381

URL: http://svn.apache.org/viewvc?rev=911381&view=rev
Log:
allow format to be specified with convenience constructors

Modified:
    commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveEntry.java

Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveEntry.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveEntry.java?rev=911381&r1=911380&r2=911381&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveEntry.java
(original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/cpio/CpioArchiveEntry.java
Thu Feb 18 13:08:31 2010
@@ -148,7 +148,7 @@
     // Header description fields - should be same throughout an archive
 
     /**
-     * See {@link CpioArchiveEntry#setFormat(short)} for possible values.
+     * See constructor documenation for possible values.
      */
     private final short fileFormat; 
 
@@ -188,7 +188,7 @@
     private long uid = 0;
 
     /**
-     * Ceates a CPIOArchiveEntry with a specified format.
+     * Creates a CPIOArchiveEntry with a specified format.
      * 
      * @param format
      *            The cpio format for this entry.
@@ -226,20 +226,39 @@
     }
 
     /**
-     * Ceates a CPIOArchiveEntry with a specified name. The format of this entry
-     * will be the new format.
+     * Creates a CPIOArchiveEntry with a specified name. The format of
+     * this entry will be the new format.
      * 
      * @param name
      *            The name of this entry.
      */
     public CpioArchiveEntry(final String name) {
-        this(FORMAT_NEW);
+        this(FORMAT_NEW, name);
+    }
+
+    /**
+     * Creates a CPIOArchiveEntry with a specified name.
+     * 
+     * @param format
+     *            The cpio format for this entry.
+     * @param name
+     *            The name of this entry.
+     * <br/>
+     * Possible format values are:
+     * <p>
+     * CpioConstants.FORMAT_NEW<br/>
+     * CpioConstants.FORMAT_NEW_CRC<br/>
+     * CpioConstants.FORMAT_OLD_BINARY<br/>
+     * CpioConstants.FORMAT_OLD_ASCII<br/>
+     */
+    public CpioArchiveEntry(final short format, final String name) {
+        this(format);
         this.name = name;
     }
 
     /**
-     * Creates a CPIOArchiveEntry with a specified name. The format of this entry
-     * will be the new format.
+     * Creates a CPIOArchiveEntry with a specified name. The format of
+     * this entry will be the new format.
      * 
      * @param name
      *            The name of this entry.
@@ -247,20 +266,76 @@
      *            The size of this entry
      */
     public CpioArchiveEntry(final String name, final long size) {
-        this(FORMAT_NEW);
-        this.name = name;
+        this(name);
+        this.setSize(size);
+    }
+
+    /**
+     * Creates a CPIOArchiveEntry with a specified name.
+     * 
+     * @param format
+     *            The cpio format for this entry.
+     * @param name
+     *            The name of this entry.
+     * @param size
+     *            The size of this entry
+     * <br/>
+     * Possible format values are:
+     * <p>
+     * CpioConstants.FORMAT_NEW<br/>
+     * CpioConstants.FORMAT_NEW_CRC<br/>
+     * CpioConstants.FORMAT_OLD_BINARY<br/>
+     * CpioConstants.FORMAT_OLD_ASCII<br/>
+     */
+    public CpioArchiveEntry(final short format, final String name,
+                            final long size) {
+        this(format, name);
         this.setSize(size);
     }
 
+    /**
+     * Creates a CPIOArchiveEntry with a specified name for a
+     * specified file. The format of this entry will be the new
+     * format.
+     * 
+     * @param inputFile
+     *            The file to gather information from.
+     * @param entryName
+     *            The name of this entry.
+     */
     public CpioArchiveEntry(File inputFile, String entryName) {
-        this(entryName, inputFile.isFile() ? inputFile.length() : 0);
+        this(FORMAT_NEW, inputFile, entryName);
+    }
+
+    /**
+     * Creates a CPIOArchiveEntry with a specified name for a
+     * specified file.
+     * 
+     * @param format
+     *            The cpio format for this entry.
+     * @param inputFile
+     *            The file to gather information from.
+     * @param entryName
+     *            The name of this entry.
+     * <br/>
+     * Possible format values are:
+     * <p>
+     * CpioConstants.FORMAT_NEW<br/>
+     * CpioConstants.FORMAT_NEW_CRC<br/>
+     * CpioConstants.FORMAT_OLD_BINARY<br/>
+     * CpioConstants.FORMAT_OLD_ASCII<br/>
+     */
+    public CpioArchiveEntry(final short format, File inputFile,
+                            String entryName) {
+        this(format, entryName, inputFile.isFile() ? inputFile.length() : 0);
         long mode=0;
         if (inputFile.isDirectory()){
             mode |= C_ISDIR;
         } else if (inputFile.isFile()){
             mode |= C_ISREG;
         } else {
-            throw new IllegalArgumentException("Cannot determine type of file "+inputFile.getName());
+            throw new IllegalArgumentException("Cannot determine type of file "
+                                               + inputFile.getName());
         }
         // TODO set other fields as needed
         setMode(mode);



Mime
View raw message