Package com.blackrook.fs
Class FSFileArchive
- java.lang.Object
-
- com.blackrook.fs.FSFileArchive
-
- Direct Known Subclasses:
ClasspathArchive
,FolderArchive
,ZipArchive
public abstract class FSFileArchive extends Object
Wrapper structure that is used to create a common interface with all files. A wrapper class should be used to wrap an archive or directory type in order for the file system to be able to read it without needing to know what kind of file it is looking in.- Author:
- Matthew Tropiano
-
-
Constructor Summary
Constructors Constructor Description FSFileArchive()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract boolean
canCreateFiles()
Can this archive create a new file within itself?abstract OutputStream
createFile(String path)
Creates a file in this archive using the name and path provided.abstract FSFile[]
getAllFiles()
Retrieves all of the files within this object as FSFile objects.abstract FSFile[]
getAllFiles(FSFileFilter filter)
Retrieves all of the files within this object that pass the filter test as FSFile objects.abstract FSFile[]
getAllFilesInDir(String path)
Retrieves all of the files within a directory as FSFile objects.abstract FSFile[]
getAllFilesInDir(String path, FSFileFilter filter)
Retrieves all of the files within this object as FSFile objects that pass the filter test.String
getArchiveName()
Gets the name of this archive.abstract FSFile
getFile(String path)
Returns an FSFile reference of a file within this wrapped file.String
getPath()
Gets the path of this archive.protected void
setArchiveName(String name)
Sets the name of this archive.protected void
setPath(String path)
Sets the path of this archive.
-
-
-
Method Detail
-
getFile
public abstract FSFile getFile(String path) throws IOException
Returns an FSFile reference of a file within this wrapped file.- Parameters:
path
- the abstract path of a file inside this file.- Returns:
- a new reference to the file requested, or null if the path refers to a location that is not inside this file.
- Throws:
IOException
- if a read error occurs during the fetch.
-
getAllFiles
public abstract FSFile[] getAllFiles() throws IOException
Retrieves all of the files within this object as FSFile objects.- Returns:
- an array of FSFiles, each entry representing a particular file in this object.
- Throws:
IOException
- if a read error occurs during the fetch.
-
getAllFilesInDir
public abstract FSFile[] getAllFilesInDir(String path) throws IOException
Retrieves all of the files within a directory as FSFile objects.- Parameters:
path
- the abstract path of a directory inside this file.- Returns:
- an array of FSFiles, each entry representing a particular file in this object.
- Throws:
IOException
- if a read error occurs during the fetch.
-
getAllFilesInDir
public abstract FSFile[] getAllFilesInDir(String path, FSFileFilter filter) throws IOException
Retrieves all of the files within this object as FSFile objects that pass the filter test.- Parameters:
path
- the abstract path of a directory inside this file.filter
- the file filter to use.- Returns:
- an array of FSFiles, each entry representing a particular file in this object.
- Throws:
IOException
- if a read error occurs during the fetch.
-
getAllFiles
public abstract FSFile[] getAllFiles(FSFileFilter filter) throws IOException
Retrieves all of the files within this object that pass the filter test as FSFile objects.- Parameters:
filter
- the file filter to use.- Returns:
- an array of FSFiles, each entry representing a particular file in this object.
- Throws:
IOException
- if a read error occurs during the fetch.
-
canCreateFiles
public abstract boolean canCreateFiles()
Can this archive create a new file within itself?- Returns:
- true if it can, false if it is read-only.
-
createFile
public abstract OutputStream createFile(String path) throws IOException
Creates a file in this archive using the name and path provided.- Parameters:
path
- the path of the file to create.- Returns:
- an acceptable OutputStream for filling the file with data.
- Throws:
UnsupportedOperationException
- if this is called on an archive that does not support writing.IOException
- if a read error occurs during the fetch.
-
setArchiveName
protected void setArchiveName(String name)
Sets the name of this archive.- Parameters:
name
- the new archive name.
-
setPath
protected void setPath(String path)
Sets the path of this archive.- Parameters:
path
- the new archive name.
-
getArchiveName
public String getArchiveName()
Gets the name of this archive.- Returns:
- the archive name.
-
getPath
public String getPath()
Gets the path of this archive.- Returns:
- the path.
-
-