|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.planx.io.MemoryFileSystem
public class MemoryFileSystem
An implementation of FileSystem that uses an in-memory byte
array to store data. Sub-blocks of data cannot be freed. However, there is
a special clear() method that frees all data in the file system.
The implementation is not synchronized and should thus be synchronized externally.
| Constructor Summary | |
|---|---|
MemoryFileSystem()
|
|
MemoryFileSystem(int capacity)
|
|
MemoryFileSystem(int capacity,
SourceId id)
|
|
MemoryFileSystem(SourceId id)
|
|
| Method Summary | |
|---|---|
Bound |
all()
Returns a locator encapsulating all data currently in this file system. |
Bound |
allocate()
Always succeeds and allocates space at end of the buffer. |
Bound |
allocate(long size)
Always succeeds and allocates space at end of the buffer. |
void |
clear()
Frees all data and generates a new SourceId. |
void |
clearModified()
Marks this file system as unmodified. |
void |
close()
No effect. |
void |
free(Bound l)
Space cannot be freed, so this method does nothing. |
PositionalData |
getData(Locator l)
Returns a unique PositionalData instance with a view of the
data in this FileSystem. |
Bound |
getMeta()
Unsupported - returns null. |
SourceId |
id()
Returns a SourceId identifying this FileSystem
in its present state. |
boolean |
isContained(Locator l)
Returns true if the specified Locator
originates from this FileSystem and is valid. |
boolean |
isModified()
Returns true if this file system has been modified since
it was created or since the last call to FileSystem.clearModified(). |
boolean |
isReadOnly()
Returns true if this file system is read-only. |
void |
setMeta(Bound b)
Unsupported. |
void |
setReadOnly(boolean isReadOnly)
Sets the read-only status of this file system. |
long |
size()
Returns the size of this file system. |
String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public MemoryFileSystem()
public MemoryFileSystem(SourceId id)
public MemoryFileSystem(int capacity)
public MemoryFileSystem(int capacity,
SourceId id)
| Method Detail |
|---|
public SourceId id()
FileSystemSourceId identifying this FileSystem
in its present state. The SourceId can change at any point
and is not necessarily equal to the SourceIds
returned by allocation method even though these may still be valid. Thus,
this SourceId should be regarded as a unique canonical
id that identifies only the present state of this FileSystem.
id in interface FileSystem
public Bound allocate()
throws IOException
allocate in interface FileSystemIOException - if an I/O error occurred.
public Bound allocate(long size)
throws IOException
allocate in interface FileSystemIOException - if an I/O error occurred or the specified amount of
bytes could not be allocated.
public Bound all()
throws IOException
FileSystem
all in interface FileSystemIOException - if an I/O error occurred.
public void free(Bound l)
throws IOException
free in interface FileSystemIOException - if an I/O error occurred.
InvalidSourceIdException - if the file system identifier of
the locator is invalid.
OutOfBoundsException - if the locator is out of bounds.
public Bound getMeta()
throws IOException
null.
getMeta in interface FileSystemIOException
public void setMeta(Bound b)
throws IOException
setMeta in interface FileSystemIOExceptionpublic void clear()
SourceId. Thus, old
locators will become invalid.
clear in interface FileSystem
public PositionalData getData(Locator l)
throws IOException
PositionalData instance with a view of the
data in this FileSystem. Any changes written to the
PositionalData is reflected in the FileSystem
and all PositionalData instances returned by this method.
getData in interface FileSystemIOException - if an I/O error occurred.
InvalidSourceIdException - if the file system identifier of
the locator is invalid.
OutOfBoundsException - if the locator is out of bounds.
public long size()
throws IOException
FileSystem
size in interface FileSystemIOException - if an I/O error occurred.public boolean isModified()
FileSystemtrue if this file system has been modified since
it was created or since the last call to FileSystem.clearModified().
isModified in interface FileSystempublic void clearModified()
FileSystem
clearModified in interface FileSystempublic boolean isReadOnly()
FileSystemtrue if this file system is read-only.
isReadOnly in interface FileSystempublic void setReadOnly(boolean isReadOnly)
FileSystem
setReadOnly in interface FileSystem
public void close()
throws IOException
close in interface FileSystemIOException - if an I/O error occurred.
public boolean isContained(Locator l)
throws IOException
FileSystemtrue if the specified Locator
originates from this FileSystem and is valid.
isContained in interface FileSystemIOExceptionpublic String toString()
toString in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||