Class ZipDirectory
- java.lang.Object
-
- org.apache.aries.util.filesystem.impl.ZipFileImpl
-
- org.apache.aries.util.filesystem.impl.ZipDirectory
-
- All Implemented Interfaces:
java.lang.Iterable<IFile>
,IDirectory
,IFile
public class ZipDirectory extends ZipFileImpl implements IDirectory
A directory in the zip.
-
-
Constructor Summary
Constructors Constructor Description ZipDirectory(java.io.File zip1, java.util.zip.ZipEntry entry1, ZipDirectory parent, ZipCloseableDirectory cache)
Constructs a directory in the zip.ZipDirectory(java.io.File fs, IDirectory parent)
This constructor creates the root of the zip.ZipDirectory(ZipDirectory other, ZipCloseableDirectory cache)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description IDirectory
convert()
boolean
equals(java.lang.Object other)
IFile
getFile(java.lang.String name)
Gets the requested file under this directory.IDirectory
getRoot()
int
hashCode()
boolean
isDirectory()
boolean
isFile()
boolean
isRoot()
boolean
isZipRoot()
java.util.Iterator<IFile>
iterator()
java.util.List<IFile>
listAllFiles()
java.util.List<IFile>
listFiles()
java.io.InputStream
open()
The input stream returned by this method should always be closed after use.ICloseableDirectory
toCloseable()
Open a more effective implementation with user regulated resource management.-
Methods inherited from class org.apache.aries.util.filesystem.impl.ZipFileImpl
convertNested, getLastModified, getName, getNameInZip, getParent, getSize, getZipPathToRoot, toString, toURL
-
Methods inherited from interface org.apache.aries.util.filesystem.IFile
convertNested, getLastModified, getName, getParent, getSize, toURL
-
-
-
-
Constructor Detail
-
ZipDirectory
public ZipDirectory(java.io.File zip1, java.util.zip.ZipEntry entry1, ZipDirectory parent, ZipCloseableDirectory cache)
Constructs a directory in the zip.- Parameters:
zip1
- the zip file.entry1
- the entry in the zip representing this dir.parent
- the parent directory.
-
ZipDirectory
public ZipDirectory(java.io.File fs, IDirectory parent) throws java.net.MalformedURLException
This constructor creates the root of the zip.- Parameters:
file
-fs
-parent
-- Throws:
java.net.MalformedURLException
-
ZipDirectory
public ZipDirectory(ZipDirectory other, ZipCloseableDirectory cache)
-
-
Method Detail
-
getFile
public IFile getFile(java.lang.String name)
Description copied from interface:IDirectory
Gets the requested file under this directory. The file may be located any number of levels within this directory. The name is relative to this directory. If the file cannot be found it will return null.- Specified by:
getFile
in interfaceIDirectory
- Parameters:
name
- the name of the file.- Returns:
- the IFile, or null if no such file exists.
-
isRoot
public boolean isRoot()
- Specified by:
isRoot
in interfaceIDirectory
- Returns:
- true if this IDirectory is the root of the virtual file system.
-
listFiles
public java.util.List<IFile> listFiles()
- Specified by:
listFiles
in interfaceIDirectory
- Returns:
- the list of files in this directory. Files must be in this directory and not in sub-directories.
-
listAllFiles
public java.util.List<IFile> listAllFiles()
- Specified by:
listAllFiles
in interfaceIDirectory
- Returns:
- the list of files in all directories (including sub-directories). This is the complete list.
-
iterator
public java.util.Iterator<IFile> iterator()
- Specified by:
iterator
in interfacejava.lang.Iterable<IFile>
-
convert
public IDirectory convert()
- Specified by:
convert
in interfaceIFile
- Overrides:
convert
in classZipFileImpl
- Returns:
- if this is a directory return this as an IDirectory, otherwise return null.
-
isDirectory
public boolean isDirectory()
- Specified by:
isDirectory
in interfaceIFile
- Overrides:
isDirectory
in classZipFileImpl
- Returns:
- true iff this IFile is also an IDirectory
-
isFile
public boolean isFile()
- Specified by:
isFile
in interfaceIFile
- Overrides:
isFile
in classZipFileImpl
- Returns:
- true iff this IFile is not an IDirectory
-
open
public java.io.InputStream open()
Description copied from interface:IFile
The input stream returned by this method should always be closed after use.- Specified by:
open
in interfaceIFile
- Overrides:
open
in classZipFileImpl
- Returns:
- An InputStream to read the file from.
-
getRoot
public IDirectory getRoot()
- Specified by:
getRoot
in interfaceIFile
- Overrides:
getRoot
in classZipFileImpl
- Returns:
- the root of this file system.
-
isZipRoot
public boolean isZipRoot()
-
equals
public boolean equals(java.lang.Object other)
- Overrides:
equals
in classZipFileImpl
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classZipFileImpl
-
toCloseable
public ICloseableDirectory toCloseable()
Description copied from interface:IDirectory
Open a more effective implementation with user regulated resource management. The implementation will be more efficient for batch operations. Make sure to call close when finished with the returned IDirectory. IFiles and IDirectories other than the returned closeable directory will stay valid after calling the close method but will no longer perform as efficiently. InputStreams that are open at the time of calling close may be invalidated.- Specified by:
toCloseable
in interfaceIDirectory
- Returns:
ICloseableDirectory
or null if a batch aware version of thisIDirectory
is not supported
-
-