|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface RandomAccess
This is EntityFS' take on a random access file. Objects of this type can be
had from file entities for randomly accessing their contents. Just like a
RandomAccessFile
, the RandomAccess
object has a file pointer
that stores the current offset in the file.
Unlike the RandomAccessFile
, this interface does not extend
the DataInput
or DataOutput
interfaces that
define methods for reading and writing primitive data types. Any RandomAccess
implementation can be adapted to those interfaces by
RandomAccessToDataInputOutputAdapter
.
For java.io.File
-backed file entities, an ordinary java.io.RandomAccessFile
can be opened by calling
FCFileBacked
methods.
Implementations of this interface are not thread safe. Use the ordinary
EntityFS locking to restrict concurrent access to objects of this type.
Files
has methods for opening lock-aware
implementations of this interface.
RandomAccessToDataInputOutputAdapter
Method Summary | |
---|---|
void |
addCloseObserver(RandomAccessCloseObserver raco)
Add an observer that is notified when this RandomAccess is
closed. |
long |
getFilePointer()
Get the current offset in the file. |
RandomAccessMode |
getMode()
Get the mode that this RandomAccess was opened in. |
long |
length()
Get the file's current length. |
void |
seek(long pos)
Set the file pointer offset, measured from the beginning of the file. |
void |
setLength(long l)
Set the length of the file. |
Methods inherited from interface org.entityfs.DataSink |
---|
close, flush, write, write, write |
Methods inherited from interface org.entityfs.DataSource |
---|
available, close, read, read, read, skipBytes |
Method Detail |
---|
RandomAccessMode getMode()
RandomAccess
was opened in.
This method does not throw an IllegalStateException
if it is
called after the RandomAccess
has been closed.
RandomAccess
was opened in.void addCloseObserver(RandomAccessCloseObserver raco)
RandomAccess
is
closed. The observers are called just after the RandomAccess
has
been closed.
raco
- The observer.long getFilePointer() throws IllegalStateException
IllegalStateException
- If the random access file is closed.long length() throws IllegalStateException
IllegalStateException
- If the random access file is closed.void seek(long pos) throws FileSystemException, IllegalStateException
pos
- The new file pointer offset, measured from the beginning of
the file.
FileSystemException
- If pos < 0
.
IllegalStateException
- If the random access file is closed.DataSource.skipBytes(long)
void setLength(long l) throws ReadOnlyException, IllegalStateException
If the present length of the file is greater than the l
argument,
the file will be truncated.
If the new length is bigger than the current length of the file, the file will be extended. The contents of the extended portion of the file are not defined.
The current file pointer is not changed, unless the file pointer offset is greater than the new file length. If so, it will be set to the new length.
l
- The new length of the file.
IllegalStateException
- If the random access file is closed.
ReadOnlyException
- If the file is opened read only.
FileSystemException
- If the new length is less than 0
.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |