[jboss-cvs] JBossAS SVN: r90315 - in projects/vfs/trunk/src/main/java/org/jboss/virtual/spi/zip: jdk and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Jun 17 06:51:02 EDT 2009
Author: alesj
Date: 2009-06-17 06:51:02 -0400 (Wed, 17 Jun 2009)
New Revision: 90315
Added:
projects/vfs/trunk/src/main/java/org/jboss/virtual/spi/zip/truezip/
projects/vfs/trunk/src/main/java/org/jboss/virtual/spi/zip/truezip/TrueZipEntry.java
projects/vfs/trunk/src/main/java/org/jboss/virtual/spi/zip/truezip/TrueZipEntryProvider.java
projects/vfs/trunk/src/main/java/org/jboss/virtual/spi/zip/truezip/TrueZipFactory.java
projects/vfs/trunk/src/main/java/org/jboss/virtual/spi/zip/truezip/TrueZipFile.java
Modified:
projects/vfs/trunk/src/main/java/org/jboss/virtual/spi/zip/jdk/JDKZipProvider.java
Log:
Add TrueZip impl.
Modified: projects/vfs/trunk/src/main/java/org/jboss/virtual/spi/zip/jdk/JDKZipProvider.java
===================================================================
--- projects/vfs/trunk/src/main/java/org/jboss/virtual/spi/zip/jdk/JDKZipProvider.java 2009-06-17 10:47:49 UTC (rev 90314)
+++ projects/vfs/trunk/src/main/java/org/jboss/virtual/spi/zip/jdk/JDKZipProvider.java 2009-06-17 10:51:02 UTC (rev 90315)
@@ -46,11 +46,22 @@
public ZipEntry getNextEntry() throws IOException
{
java.util.zip.ZipEntry entry = zis.getNextEntry();
- return entry != null ? new JDKZipEntry(entry) : null;
+ return entry != null ? wrap(entry) : null;
}
- public InputStream currentStream()
+ /**
+ * Wrap the entry.
+ *
+ * @param entry the entry
+ * @return wrapped entry
+ */
+ protected ZipEntry wrap(java.util.zip.ZipEntry entry)
{
+ return new JDKZipEntry(entry);
+ }
+
+ public InputStream currentStream() throws IOException
+ {
return new IgnoreCloseInputStream(zis);
}
Added: projects/vfs/trunk/src/main/java/org/jboss/virtual/spi/zip/truezip/TrueZipEntry.java
===================================================================
--- projects/vfs/trunk/src/main/java/org/jboss/virtual/spi/zip/truezip/TrueZipEntry.java (rev 0)
+++ projects/vfs/trunk/src/main/java/org/jboss/virtual/spi/zip/truezip/TrueZipEntry.java 2009-06-17 10:51:02 UTC (rev 90315)
@@ -0,0 +1,100 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.virtual.spi.zip.truezip;
+
+import org.jboss.virtual.spi.zip.ZipEntry;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class TrueZipEntry implements ZipEntry
+{
+ private de.schlichtherle.util.zip.ZipEntry entry;
+ private Boolean directory;
+
+ public TrueZipEntry(de.schlichtherle.util.zip.ZipEntry entry)
+ {
+ if (entry == null)
+ throw new IllegalArgumentException("Null entry");
+ this.entry = entry;
+ }
+
+ public String getName()
+ {
+ return entry.getName();
+ }
+
+ public boolean isDirectory()
+ {
+ return directory != null ? directory : entry.isDirectory();
+ }
+
+ public void setDirectory(boolean directory)
+ {
+ this.directory = directory;
+ }
+
+ public long getTime()
+ {
+ return entry.getTime();
+ }
+
+ public void setTime(long time)
+ {
+ entry.setTime(time);
+ }
+
+ public long getSize()
+ {
+ return entry.getSize();
+ }
+
+ public void setSize(long size)
+ {
+ entry.setSize(size);
+ }
+
+ public String getComment()
+ {
+ return entry.getComment();
+ }
+
+ public void setComment(String comment)
+ {
+ entry.setComment(comment);
+ }
+
+ public long getCrc()
+ {
+ return entry.getCrc() & 0xffffffffL;
+ }
+
+ public void setCrc(long crc)
+ {
+ entry.setCrc(crc);
+ }
+
+ public Object unwrap()
+ {
+ return entry;
+ }
+}
\ No newline at end of file
Added: projects/vfs/trunk/src/main/java/org/jboss/virtual/spi/zip/truezip/TrueZipEntryProvider.java
===================================================================
--- projects/vfs/trunk/src/main/java/org/jboss/virtual/spi/zip/truezip/TrueZipEntryProvider.java (rev 0)
+++ projects/vfs/trunk/src/main/java/org/jboss/virtual/spi/zip/truezip/TrueZipEntryProvider.java 2009-06-17 10:51:02 UTC (rev 90315)
@@ -0,0 +1,55 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.virtual.spi.zip.truezip;
+
+import java.util.zip.ZipInputStream;
+
+import org.jboss.virtual.spi.zip.jdk.JDKZipProvider;
+import org.jboss.virtual.spi.zip.ZipEntry;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class TrueZipEntryProvider extends JDKZipProvider
+{
+ public TrueZipEntryProvider(ZipInputStream zis)
+ {
+ super(zis);
+ }
+
+ @Override
+ protected ZipEntry wrap(java.util.zip.ZipEntry entry)
+ {
+ de.schlichtherle.util.zip.ZipEntry zipEntry = new de.schlichtherle.util.zip.ZipEntry(entry.getName());
+ zipEntry.setComment(entry.getComment());
+ zipEntry.setCompressedSize(entry.getCompressedSize());
+ zipEntry.setCrc(entry.getCrc());
+ zipEntry.setExtra(entry.getExtra());
+ zipEntry.setMethod(entry.getMethod());
+ zipEntry.setSize(entry.getSize());
+ zipEntry.setTime(entry.getTime());
+
+ TrueZipEntry trueZipEntry = new TrueZipEntry(zipEntry);
+ trueZipEntry.setDirectory(entry.isDirectory());
+ return trueZipEntry;
+ }
+}
\ No newline at end of file
Added: projects/vfs/trunk/src/main/java/org/jboss/virtual/spi/zip/truezip/TrueZipFactory.java
===================================================================
--- projects/vfs/trunk/src/main/java/org/jboss/virtual/spi/zip/truezip/TrueZipFactory.java (rev 0)
+++ projects/vfs/trunk/src/main/java/org/jboss/virtual/spi/zip/truezip/TrueZipFactory.java 2009-06-17 10:51:02 UTC (rev 90315)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.virtual.spi.zip.truezip;
+
+import java.io.InputStream;
+import java.io.IOException;
+import java.io.File;
+import java.util.zip.ZipInputStream;
+
+import org.jboss.virtual.spi.zip.ZipFactory;
+import org.jboss.virtual.spi.zip.ZipEntryProvider;
+import org.jboss.virtual.spi.zip.ZipFile;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class TrueZipFactory implements ZipFactory
+{
+ public ZipEntryProvider createProvider(InputStream is) throws IOException
+ {
+ ZipInputStream zis = new ZipInputStream(is);
+ return new TrueZipEntryProvider(zis);
+ }
+
+ public ZipFile createFile(File file) throws IOException
+ {
+ de.schlichtherle.util.zip.ZipFile zipFile = new de.schlichtherle.util.zip.ZipFile(file);
+ return new TrueZipFile(zipFile);
+ }
+}
Added: projects/vfs/trunk/src/main/java/org/jboss/virtual/spi/zip/truezip/TrueZipFile.java
===================================================================
--- projects/vfs/trunk/src/main/java/org/jboss/virtual/spi/zip/truezip/TrueZipFile.java (rev 0)
+++ projects/vfs/trunk/src/main/java/org/jboss/virtual/spi/zip/truezip/TrueZipFile.java 2009-06-17 10:51:02 UTC (rev 90315)
@@ -0,0 +1,74 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.virtual.spi.zip.truezip;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Enumeration;
+
+import org.jboss.virtual.spi.zip.ZipEntry;
+import org.jboss.virtual.spi.zip.ZipFile;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class TrueZipFile implements ZipFile
+{
+ private de.schlichtherle.util.zip.ZipFile file;
+
+ public TrueZipFile(de.schlichtherle.util.zip.ZipFile file)
+ {
+ if (file == null)
+ throw new IllegalArgumentException("Null file");
+ this.file = file;
+ }
+
+ public InputStream getInputStream(ZipEntry entry) throws IOException
+ {
+ Object unwraped = entry.unwrap();
+ return file.getInputStream(de.schlichtherle.util.zip.ZipEntry.class.cast(unwraped));
+ }
+
+ public void close() throws IOException
+ {
+ file.close();
+ }
+
+ public Enumeration<? extends ZipEntry> entries()
+ {
+ @SuppressWarnings("unchecked")
+ final Enumeration<? extends de.schlichtherle.util.zip.ZipEntry> entries = file.entries();
+ return new Enumeration<ZipEntry>()
+ {
+ public boolean hasMoreElements()
+ {
+ return entries.hasMoreElements();
+ }
+
+ public ZipEntry nextElement()
+ {
+ de.schlichtherle.util.zip.ZipEntry entry = entries.nextElement();
+ return entry != null ? new TrueZipEntry(entry) : null;
+ }
+ };
+ }
+}
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list