Class DirectoryImpl
- java.lang.Object
-
- org.apache.aries.util.filesystem.impl.FileImpl
-
- org.apache.aries.util.filesystem.impl.DirectoryImpl
-
- All Implemented Interfaces:
java.lang.Iterable<IFile>
,IDirectory
,IFile
public class DirectoryImpl extends FileImpl implements IDirectory
An IDirectory representing a java.io.File whose isDirectory method returns true.
-
-
Constructor Summary
Constructors Constructor Description DirectoryImpl(java.io.File dir, java.io.File rootFile)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description IDirectory
convert()
IFile
getFile(java.lang.String name)
Gets the requested file under this directory.long
getLastModified()
IDirectory
getParent()
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.-
Methods inherited from class org.apache.aries.util.filesystem.impl.FileImpl
convertNested, equals, getName, getRoot, getSize, hashCode, isDirectory, isFile, toString, toURL
-
Methods inherited from interface org.apache.aries.util.filesystem.IFile
convertNested, getName, getRoot, getSize, isDirectory, isFile, toURL
-
-
-
-
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>
-
getParent
public IDirectory getParent()
-
convert
public IDirectory convert()
-
open
public java.io.InputStream open() throws java.io.IOException
Description copied from interface:IFile
The input stream returned by this method should always be closed after use.
-
getLastModified
public long getLastModified()
- Specified by:
getLastModified
in interfaceIFile
- Overrides:
getLastModified
in classFileImpl
- Returns:
- the last modified date of the file.
-
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
-
-