|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.objectledge.filesystem.impl.ReadOnlyFileSystemProvider
public abstract class ReadOnlyFileSystemProvider
A base class for read only FileSystem backend implemetations.
| Field Summary | |
|---|---|
private Map<String,Object> |
directoryTree
The directory tree. |
private Map<String,Long> |
lengths
The file listing. |
private Map<String,Object> |
listing
The file listing. |
static String |
LISTING_ENCODING
the character encoding used in file listings. |
static String[] |
LISTING_LOCATION
locations of the file listings, in order of precedence. |
protected String |
name
Providers's name. |
private Map<String,Long> |
times
The file listing. |
| Constructor Summary | |
|---|---|
ReadOnlyFileSystemProvider(String name)
Creates an instance of the provider. |
|
| Method Summary | |
|---|---|
boolean |
canRead(String path)
Checks if the application is allowed to read given file or directory. |
boolean |
canWrite(String path)
Checks if the application is allowed to write given file or directory. |
boolean |
checkPathChars(String path)
Returns true if the given path contains acceptable characters. |
boolean |
createNewFile(String path)
Atomically creates a new, empty file named by this abstract pathname if and only if a file with this name does not yet exist. |
void |
delete(String path)
Deletes a file or directory. |
boolean |
exists(String path)
Checks if the given file or directory exists. |
abstract InputStream |
getInputStream(String path)
Opens an input stream for reading a file. |
String |
getName()
Returns the name of the provider. |
OutputStream |
getOutputStream(String path,
boolean append)
Opens an output stream for writing to file. |
RandomAccessFile |
getRandomAccess(String path,
String mode)
Returns a RandomAccess interface implementation for accessing the file at
arbitrary positions. |
boolean |
isDirectory(String path)
Checks if the given pathname points to a directory. |
boolean |
isFile(String path)
Checks if the given pathname points to an ordinary file. |
boolean |
isReadOnly()
Returns true if the provider is readonly. |
long |
lastModified(String path)
Returns the time of the last modificaion of the specified file. |
long |
length(String path)
Returns the size of the specified file. |
Set<String> |
list(String dir)
Lists the files and directories inside a directory. |
void |
mkdirs(String path)
Creates a directory, and all necceray parent directories. |
protected void |
processListing(String location,
InputStream is)
Processes a listing. |
protected void |
processListings()
Processes the liststings at the common locations. |
void |
rename(String from,
String to)
Atomically renames a file or directory. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface org.objectledge.filesystem.FileSystemProvider |
|---|
getResource |
| Field Detail |
|---|
public static final String[] LISTING_LOCATION
public static final String LISTING_ENCODING
protected String name
private Map<String,Object> listing
private Map<String,Object> directoryTree
private Map<String,Long> times
private Map<String,Long> lengths
| Constructor Detail |
|---|
public ReadOnlyFileSystemProvider(String name)
name - the name of the provider.| Method Detail |
|---|
protected void processListings()
throws IOException
getInputStream(String) method must be functional at the point of calling this
method.
IOException - if the listings cannot be processed.public String getName()
getName in interface FileSystemProviderpublic boolean isReadOnly()
true if the provider is readonly.
isReadOnly in interface FileSystemProvidertrue if the provider is readonly.
protected void processListing(String location,
InputStream is)
throws IOException
location - the location of the listingis - the stream used for reading the listing.
IOException - if the index file cannot be processed.public boolean checkPathChars(String path)
true if the given path contains acceptable characters.
checkPathChars in interface FileSystemProviderpath - the path.
true if the given path contains acceptable characters.public boolean exists(String path)
exists in interface FileSystemProviderpath - the path.
true if the given file or directory exists.public boolean isFile(String path)
isFile in interface FileSystemProviderpath - the path
true if the given pathname points to a directory.public boolean isDirectory(String path)
isDirectory in interface FileSystemProviderpath - the path
true if the given pathname points to a directory.public boolean canRead(String path)
canRead in interface FileSystemProviderpath - the path.
true if the application is allowed to read given
file or directory.public boolean canWrite(String path)
canWrite in interface FileSystemProviderpath - the path.
true if the application is allowed to write given
file or directory.
public Set<String> list(String dir)
throws IOException
list in interface FileSystemProviderdir - the directory.
IOException - if dir does not exist
or is not a directory.
public boolean createNewFile(String path)
throws IOException
The check for the existence of the file and the creation of the file if it does not exist are a single operation that is atomic with respect to all other filesystem activities that might affect the file.
createNewFile in interface FileSystemProviderpath - the pathname of the file to create.
true if the named file does not exist and was
successfully created; false if the named file
already exists.
IOException - if the operation fails.
public void mkdirs(String path)
throws IOException
mkdirs in interface FileSystemProviderpath - the path.
IOException - if the operation fails.
public void delete(String path)
throws IOException
Directories must be empty when being deleted.
delete in interface FileSystemProviderpath - the path.
IOException - if the operation fails.
public void rename(String from,
String to)
throws IOException
rename in interface FileSystemProviderfrom - source path.to - destination path.
IOException - if the operation fails.public abstract InputStream getInputStream(String path)
getInputStream in interface FileSystemProviderpath - the path.
public OutputStream getOutputStream(String path,
boolean append)
getOutputStream in interface FileSystemProviderpath - the path.append - true to append, false to truncate.
public RandomAccessFile getRandomAccess(String path,
String mode)
RandomAccess interface implementation for accessing the file at
arbitrary positions.
getRandomAccess in interface FileSystemProviderpath - the abstract pathname.mode - the string which defines the opening mode for this random access file,
the form of this string is equal to the mode parameter in
java.io.RandomAccessFile constructor.
null
if the operation is not supported.public long lastModified(String path)
The time of the modification is returned as the number of milliseconds sice the epoch (Jan 1 1970), or -1L if the feature is not supported.
lastModified in interface FileSystemProviderpath - the path.
public long length(String path)
length in interface FileSystemProviderpath - the path.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||