Class CloseableDirectory
- java.lang.Object
-
- org.apache.aries.util.filesystem.impl.CloseableDirectory
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,java.lang.Iterable<IFile>
,ICloseableDirectory
,IDirectory
,IFile
- Direct Known Subclasses:
InputStreamClosableDirectory
,NestedCloseableDirectory
,ZipCloseableDirectory
public class CloseableDirectory extends java.lang.Object implements ICloseableDirectory
-
-
Constructor Summary
Constructors Constructor Description CloseableDirectory(IDirectory delegate)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
IDirectory
convert()
IDirectory
convertNested()
IFile
getFile(java.lang.String name)
Gets the requested file under this directory.long
getLastModified()
java.lang.String
getName()
IDirectory
getParent()
IDirectory
getRoot()
long
getSize()
boolean
isClosed()
Checks whether the closeable directory has been closedboolean
isDirectory()
boolean
isFile()
boolean
isRoot()
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.java.net.URL
toURL()
-
-
-
Constructor Detail
-
CloseableDirectory
public CloseableDirectory(IDirectory delegate)
-
-
Method Detail
-
getName
public java.lang.String getName()
-
isDirectory
public boolean isDirectory()
- Specified by:
isDirectory
in interfaceIFile
- Returns:
- true iff this IFile is also an IDirectory
-
isFile
public boolean isFile()
-
getLastModified
public long getLastModified()
- Specified by:
getLastModified
in interfaceIFile
- Returns:
- the last modified date of the file.
-
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.
-
getSize
public long getSize()
-
convert
public IDirectory convert()
-
convertNested
public IDirectory convertNested()
- Specified by:
convertNested
in interfaceIFile
- Returns:
- if this is a directory or an archive, returns the opened IDirectory
-
isRoot
public boolean isRoot()
- Specified by:
isRoot
in interfaceIDirectory
- Returns:
- true if this IDirectory is the root of the virtual file system.
-
getParent
public IDirectory getParent()
-
getRoot
public IDirectory getRoot()
-
iterator
public java.util.Iterator<IFile> iterator()
- Specified by:
iterator
in interfacejava.lang.Iterable<IFile>
-
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.
-
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
-
open
public java.io.InputStream open() throws java.io.IOException, java.lang.UnsupportedOperationException
Description copied from interface:IFile
The input stream returned by this method should always be closed after use.
-
toURL
public java.net.URL toURL() throws java.net.MalformedURLException
-
close
public final void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Throws:
java.io.IOException
-
isClosed
public boolean isClosed()
Description copied from interface:ICloseableDirectory
Checks whether the closeable directory has been closed- Specified by:
isClosed
in interfaceICloseableDirectory
-
-