org.apache.aries.util.filesystem.impl
Class CloseableDirectory
java.lang.Object
org.apache.aries.util.filesystem.impl.CloseableDirectory
- All Implemented Interfaces:
- Closeable, Iterable<IFile>, ICloseableDirectory, IDirectory, IFile
- Direct Known Subclasses:
- InputStreamClosableDirectory, NestedCloseableDirectory, ZipCloseableDirectory
public class CloseableDirectory
- extends Object
- implements ICloseableDirectory
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
delegate
protected IDirectory delegate
CloseableDirectory
public CloseableDirectory(IDirectory delegate)
getName
public String getName()
- Specified by:
getName in interface IFile
- Returns:
- the name of the file relative to the root of the virtual FS. This will return a '/' separated path
indepedent of underlying filesystem
isDirectory
public boolean isDirectory()
- Specified by:
isDirectory in interface IFile
- Returns:
- true iff this IFile is also an IDirectory
isFile
public boolean isFile()
- Specified by:
isFile in interface IFile
- Returns:
- true iff this IFile is not an IDirectory
getLastModified
public long getLastModified()
- Specified by:
getLastModified in interface IFile
- Returns:
- the last modified date of the file.
getFile
public IFile getFile(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 interface IDirectory
- Parameters:
name - the name of the file.
- Returns:
- the IFile, or null if no such file exists.
getSize
public long getSize()
- Specified by:
getSize in interface IFile
- Returns:
- the size of the file.
convert
public IDirectory convert()
- Specified by:
convert in interface IFile
- Returns:
- if this is a directory return this as an IDirectory, otherwise return null.
convertNested
public IDirectory convertNested()
- Specified by:
convertNested in interface IFile
- Returns:
- if this is a directory or an archive, returns the opened IDirectory
isRoot
public boolean isRoot()
- Specified by:
isRoot in interface IDirectory
- Returns:
- true if this IDirectory is the root of the virtual file system.
getParent
public IDirectory getParent()
- Specified by:
getParent in interface IFile
- Returns:
- returns the parent directory of this IFile, or null if this is the root.
getRoot
public IDirectory getRoot()
- Specified by:
getRoot in interface IFile
- Returns:
- the root of this file system.
iterator
public Iterator<IFile> iterator()
- Specified by:
iterator in interface Iterable<IFile>
listFiles
public List<IFile> listFiles()
- Specified by:
listFiles in interface IDirectory
- Returns:
- the list of files in this directory. Files must be in this directory
and not in sub-directories.
listAllFiles
public List<IFile> listAllFiles()
- Specified by:
listAllFiles in interface IDirectory
- Returns:
- the list of files in all directories (including sub-directories). This is the complete list.
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 interface IDirectory
- Returns:
ICloseableDirectory or null if a batch aware version of this IDirectory is not supported
open
public InputStream open()
throws IOException,
UnsupportedOperationException
- Description copied from interface:
IFile
- The input stream returned by this method should always be closed after use.
- Specified by:
open in interface IFile
- Returns:
- An InputStream to read the file from.
- Throws:
IOException
UnsupportedOperationException - If the IFile is also an IDirectory.
toURL
public URL toURL()
throws MalformedURLException
- Specified by:
toURL in interface IFile
- Returns:
- a URL that can be used to get at this file at a later date.
- Throws:
MalformedURLException
close
public final void close()
throws IOException
- Specified by:
close in interface Closeable
- Throws:
IOException
cleanup
protected void cleanup()
checkNotClosed
protected void checkNotClosed()
isClosed
public boolean isClosed()
- Description copied from interface:
ICloseableDirectory
- Checks whether the closeable directory has been closed
- Specified by:
isClosed in interface ICloseableDirectory
Copyright © 2009-2011 The Apache Software Foundation. All Rights Reserved.