[jboss-cvs] JBossAS SVN: r90255 - projects/vfs/trunk/src/main/java/org/jboss/virtual/spi/zip.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Jun 16 10:47:37 EDT 2009
Author: david.lloyd at jboss.com
Date: 2009-06-16 10:47:36 -0400 (Tue, 16 Jun 2009)
New Revision: 90255
Modified:
projects/vfs/trunk/src/main/java/org/jboss/virtual/spi/zip/ZipEntry.java
projects/vfs/trunk/src/main/java/org/jboss/virtual/spi/zip/ZipEntryProvider.java
projects/vfs/trunk/src/main/java/org/jboss/virtual/spi/zip/ZipFactory.java
projects/vfs/trunk/src/main/java/org/jboss/virtual/spi/zip/ZipFile.java
projects/vfs/trunk/src/main/java/org/jboss/virtual/spi/zip/ZipUtils.java
Log:
Comprehensive javadoc; also, make closeable entities implement Closeable
Modified: projects/vfs/trunk/src/main/java/org/jboss/virtual/spi/zip/ZipEntry.java
===================================================================
--- projects/vfs/trunk/src/main/java/org/jboss/virtual/spi/zip/ZipEntry.java 2009-06-16 14:43:46 UTC (rev 90254)
+++ projects/vfs/trunk/src/main/java/org/jboss/virtual/spi/zip/ZipEntry.java 2009-06-16 14:47:36 UTC (rev 90255)
@@ -28,25 +28,83 @@
*/
public interface ZipEntry
{
+
+ /**
+ * Get the full name of the entry.
+ *
+ * @return the full name
+ */
String getName();
+ /**
+ * Determine whether this entry is a directory.
+ *
+ * @return {@code true} if the entry is a directory
+ */
boolean isDirectory();
+ /**
+ * Get the modification time of this entry in milliseconds as per {@link System#currentTimeMillis()}.
+ *
+ * @return the modification time
+ */
long getTime();
+ /**
+ * Set the modification time.
+ *
+ * @param time the modification time
+ */
void setTime(long time);
+ /**
+ * Get the uncompressed size of the data referred to by this entry object.
+ *
+ * @return the size
+ */
long getSize();
+ /**
+ * Set the uncompressed size.
+ *
+ * @param size the size
+ */
void setSize(long size);
+ /**
+ * Get the zip file entry comment. May not be available if this object was acquired from a {@link ZipEntryProvider},
+ * since the comment information is present only in the Zip directory, and the {@code ZipEntryProvider} uses only
+ * local file headers to gather its information.
+ *
+ * @return the comment string
+ */
String getComment();
+ /**
+ * Set the zip file entry comment.
+ *
+ * @param comment the comment string
+ */
void setComment(String comment);
+ /**
+ * Get the 32-bit unsigned CRC value.
+ *
+ * @return the CRC value
+ */
long getCrc();
+ /**
+ * Set the CRC value.
+ *
+ * @param crc the CRC value
+ */
void setCrc(long crc);
+ /**
+ * Get the implementation object.
+ *
+ * @return the implementation object
+ */
Object unwrap();
}
Modified: projects/vfs/trunk/src/main/java/org/jboss/virtual/spi/zip/ZipEntryProvider.java
===================================================================
--- projects/vfs/trunk/src/main/java/org/jboss/virtual/spi/zip/ZipEntryProvider.java 2009-06-16 14:43:46 UTC (rev 90254)
+++ projects/vfs/trunk/src/main/java/org/jboss/virtual/spi/zip/ZipEntryProvider.java 2009-06-16 14:47:36 UTC (rev 90255)
@@ -23,17 +23,39 @@
import java.io.InputStream;
import java.io.IOException;
+import java.io.Closeable;
/**
* Zip entry provider abstraction.
*
* @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
*/
-public interface ZipEntryProvider
+public interface ZipEntryProvider extends Closeable
{
+
+ /**
+ * Get the next entry in the stream. This method may render the results of {@link #currentStream()} useless;
+ * such streams should be closed before invoking this method.
+ *
+ * @return the next entry in the stream
+ * @throws IOException if an I/O error occurs
+ */
ZipEntry getNextEntry() throws IOException;
+ /**
+ * Get the current stream for this entry iterator. The stream <b>must</b> be closed or file locking or cleanup
+ * issues may ensue.
+ *
+ * @return the input stream
+ * @throws IOException if an I/O error occurs
+ */
InputStream currentStream() throws IOException;
+ /**
+ * Close the iterator. This <b>may</b> close any outstanding streams returned by this object; however it may not
+ * so callers must be sure to close such streams before calling this method.
+ *
+ * @throws IOException if an I/O error occurs
+ */
void close() throws IOException;
}
\ No newline at end of file
Modified: projects/vfs/trunk/src/main/java/org/jboss/virtual/spi/zip/ZipFactory.java
===================================================================
--- projects/vfs/trunk/src/main/java/org/jboss/virtual/spi/zip/ZipFactory.java 2009-06-16 14:43:46 UTC (rev 90254)
+++ projects/vfs/trunk/src/main/java/org/jboss/virtual/spi/zip/ZipFactory.java 2009-06-16 14:47:36 UTC (rev 90255)
@@ -26,13 +26,32 @@
import java.io.IOException;
/**
- * Zip factory.
+ * Zip factory. This is the main entry point into the Zip abstraction layer.
*
* @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
*/
public interface ZipFactory
{
+
+ /**
+ * Create a zip entry provider for an input stream. The provider will provide the means to iterate over a zip
+ * file one entry at a time. The returned provider <b>must</b> be closed or else file locking or cleanup issues
+ * may ensue.
+ *
+ * @param is the input stream to read
+ * @return the zip entry provider.
+ * @throws IOException if an I/O error occurs
+ */
ZipEntryProvider createProvider(InputStream is) throws IOException;
+ /**
+ * Create a handle to a randomly-accessible zip file. The zip file will allow entries to be accessed at random
+ * and possibly in parallel. The returned object <b>must</b> be closed or else file locking or cleanup issues
+ * may ensue.
+ *
+ * @param file the file to read
+ * @return the zip file handle
+ * @throws IOException if an I/O error occurs
+ */
ZipFile createFile(File file) throws IOException;
}
\ No newline at end of file
Modified: projects/vfs/trunk/src/main/java/org/jboss/virtual/spi/zip/ZipFile.java
===================================================================
--- projects/vfs/trunk/src/main/java/org/jboss/virtual/spi/zip/ZipFile.java 2009-06-16 14:43:46 UTC (rev 90254)
+++ projects/vfs/trunk/src/main/java/org/jboss/virtual/spi/zip/ZipFile.java 2009-06-16 14:47:36 UTC (rev 90255)
@@ -23,6 +23,7 @@
import java.io.InputStream;
import java.io.IOException;
+import java.io.Closeable;
import java.util.Enumeration;
/**
@@ -30,7 +31,7 @@
*
* @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
*/
-public interface ZipFile
+public interface ZipFile extends Closeable
{
/**
Modified: projects/vfs/trunk/src/main/java/org/jboss/virtual/spi/zip/ZipUtils.java
===================================================================
--- projects/vfs/trunk/src/main/java/org/jboss/virtual/spi/zip/ZipUtils.java 2009-06-16 14:43:46 UTC (rev 90254)
+++ projects/vfs/trunk/src/main/java/org/jboss/virtual/spi/zip/ZipUtils.java 2009-06-16 14:47:36 UTC (rev 90255)
@@ -22,6 +22,7 @@
package org.jboss.virtual.spi.zip;
import org.jboss.virtual.spi.zip.jdk.JDKZipFactory;
+import org.jboss.virtual.spi.zip.jzipfile.JZipFileZipFactory;
/**
* Zip utils.
@@ -30,8 +31,8 @@
*/
public class ZipUtils
{
- //private static ZipFactory factory = new JZipFileZipFactory();
- private static ZipFactory factory = new JDKZipFactory();
+ private static ZipFactory factory = new JZipFileZipFactory();
+// private static ZipFactory factory = new JDKZipFactory();
public static ZipFactory getFactory()
{
More information about the jboss-cvs-commits
mailing list