Class CloseableDirectory
java.lang.Object
org.apache.aries.util.filesystem.impl.CloseableDirectory
- All Implemented Interfaces:
Closeable,AutoCloseable,Iterable<IFile>,ICloseableDirectory,IDirectory,IFile
- Direct Known Subclasses:
InputStreamClosableDirectory,NestedCloseableDirectory,ZipCloseableDirectory
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal voidclose()convert()Gets the requested file under this directory.longgetName()getRoot()longgetSize()booleanisClosed()Checks whether the closeable directory has been closedbooleanbooleanisFile()booleanisRoot()iterator()open()The input stream returned by this method should always be closed after use.Open a more effective implementation with user regulated resource management.toURL()Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
CloseableDirectory
-
-
Method Details
-
getName
-
isDirectory
public boolean isDirectory()- Specified by:
isDirectoryin interfaceIFile- Returns:
- true iff this IFile is also an IDirectory
-
isFile
public boolean isFile() -
getLastModified
public long getLastModified()- Specified by:
getLastModifiedin interfaceIFile- Returns:
- the last modified date of the file.
-
getFile
Description copied from interface:IDirectoryGets 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:
getFilein interfaceIDirectory- Parameters:
name- the name of the file.- Returns:
- the IFile, or null if no such file exists.
-
getSize
public long getSize() -
convert
-
convertNested
- Specified by:
convertNestedin interfaceIFile- Returns:
- if this is a directory or an archive, returns the opened IDirectory
-
isRoot
public boolean isRoot()- Specified by:
isRootin interfaceIDirectory- Returns:
- true if this IDirectory is the root of the virtual file system.
-
getParent
-
getRoot
-
iterator
-
listFiles
- Specified by:
listFilesin interfaceIDirectory- Returns:
- the list of files in this directory. Files must be in this directory and not in sub-directories.
-
listAllFiles
- Specified by:
listAllFilesin interfaceIDirectory- Returns:
- the list of files in all directories (including sub-directories). This is the complete list.
-
toCloseable
Description copied from interface:IDirectoryOpen 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:
toCloseablein interfaceIDirectory- Returns:
ICloseableDirectoryor null if a batch aware version of thisIDirectoryis not supported
-
open
Description copied from interface:IFileThe input stream returned by this method should always be closed after use.- Specified by:
openin interfaceIFile- Returns:
- An InputStream to read the file from.
- Throws:
IOExceptionUnsupportedOperationException- If the IFile is also an IDirectory.
-
toURL
- Specified by:
toURLin interfaceIFile- Returns:
- a URL that can be used to get at this file at a later date.
- Throws:
MalformedURLException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
isClosed
public boolean isClosed()Description copied from interface:ICloseableDirectoryChecks whether the closeable directory has been closed- Specified by:
isClosedin interfaceICloseableDirectory
-