protected abstract class DatabaseObject.MetaData extends RandomStream
Modifier and Type | Field and Description |
---|---|
int |
numberOfFragments
This is only valid after a read operation.
|
READ_ONLY, READ_WRITE
Modifier | Constructor and Description |
---|---|
protected |
MetaData(String name) |
Modifier and Type | Method and Description |
---|---|
abstract void |
close()
This method closes the stream.
|
abstract boolean |
delete() |
abstract long |
getLength()
Return the full length of the Stream.
|
byte[] |
openAndReadAll() |
ByteArray |
openAndReadAll(ByteArray ba) |
abstract boolean |
openForAppending(boolean mustExist) |
abstract void |
openForOverwriting(int bytesNeededToWrite) |
abstract int |
openForReading() |
abstract void |
openForReplacing(int bytesNeededToWrite) |
int |
read()
This method reads an unsigned byte from the input stream and returns it
as an int in the range of 0-255.
|
abstract int |
read(byte[] data,
int offset,
int length)
This method read bytes from a stream and stores them into a
caller supplied buffer.
|
void |
readAll(byte[] data,
int offset,
int length) |
abstract void |
write(byte[] data,
int offset,
int length)
This method writes
len bytes from the specified array
b starting at index off into the array. |
void |
write(int b)
This method writes a single byte to the output stream.
|
canSetLength, flush, getPosition, isOpenForWriting, isReadWrite, mark, markSupported, reset, setLength, setMode, setPosition, skip, throwCantWrite, toOutputStream, validateMode, write
available, finalize, hashCode, read
public int numberOfFragments
protected MetaData(String name)
public abstract void openForReplacing(int bytesNeededToWrite) throws IOException
IOException
public abstract boolean openForAppending(boolean mustExist) throws IOException
IOException
public abstract void openForOverwriting(int bytesNeededToWrite) throws IOException
IOException
public abstract int openForReading() throws IOException
IOException
public abstract void write(byte[] data, int offset, int length) throws IOException
RandomStream
len
bytes from the specified array
b
starting at index off
into the array.
This method in this class calls the single byte write()
method in a loop until all bytes have been written. Subclasses should
override this method if possible in order to provide a more efficent
implementation.
write
in class RandomStream
data
- The array of bytes to write fromoffset
- The index into the array to start writing fromlength
- The number of bytes to writeIOException
- If an error occurspublic void write(int b) throws IOException
RandomStream
int
passed as the argument.
Subclasses must provide an implementation of this method.
write
in class RandomStream
b
- The byte to be written to the output stream, passed as
the low eight bits of an int
IOException
- If an error occurspublic abstract int read(byte[] data, int offset, int length) throws IOException
InputStream
off
into the buffer and attempts to read
len
bytes. This method can return before reading the
number of bytes requested. The actual number of bytes read is
returned as an int. A -1 is returned to indicate the end of the
stream.
This method will block until some data can be read.
This method operates by calling the single byte read()
method
in a loop until the desired number of bytes are read. The read loop
stops short if the end of the stream is encountered or if an IOException
is encountered on any read operation except the first. If the first
attempt to read a bytes fails, the IOException is allowed to propagate
upward. And subsequent IOException is caught and treated identically
to an end of stream condition. Subclasses can (and should if possible)
override this method to provide a more efficient implementation.
read
in class InputStream
data
- The array into which the bytes read should be storedoffset
- The offset into the array to start storing byteslength
- The requested number of bytes to readIOException
- If an error occurs.public int read() throws IOException
InputStream
This method will block until the byte can be read.
read
in class InputStream
IOException
- If an error occurspublic abstract long getLength() throws IOException
RandomStream
getLength
in class RandomStream
IOException
- if an IO error occured.public abstract boolean delete() throws IOException
IOException
public abstract void close() throws IOException
InputStream
IOException
This method does nothing in this class, but subclasses may override this method in order to provide additional functionality.
close
in class InputStream
IOException
- If an error occurs, which can only happen
in a subclasspublic void readAll(byte[] data, int offset, int length) throws IOException
IOException
public ByteArray openAndReadAll(ByteArray ba) throws IOException
IOException
public byte[] openAndReadAll() throws IOException
IOException