|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.unister.semweb.drums.file.AbstractHeaderFile
public abstract class AbstractHeaderFile
Header structure:
+-----------+--------------+---------------+---------------+
= 1024 bytes (to have enough space for more values)
| FILE SIZE | FILLED UP TO | ............. | ............. |
| 8 bytes . | 8 bytes .... | ............. | ............. |
+-----------+--------------+---------------+---------------+
To use this class correctly, have a look at the following methods:
Nested Class Summary | |
---|---|
static class |
AbstractHeaderFile.AccessMode
The possible AccessModes. |
Field Summary | |
---|---|
int |
DEFAULT_SIZE
the Default size of a file. (16MB) |
static int |
HEADER_SIZE
the size of the header |
java.io.File |
osFile
the file to access |
int |
RETRY_CONNECT_WAITTIME
the time to wait for a retry if a file is locked |
Constructor Summary | |
---|---|
AbstractHeaderFile()
|
Method Summary | |
---|---|
abstract long |
append(byte[] sourceBuffer)
appends the given sourceBuffer to the file and returns the file position of the appended entry |
abstract long |
append(java.nio.ByteBuffer sourceBuffer)
appends the given sourceBuffer to the file and returns the file position of the appended entry |
void |
clear()
sets the start of the content to zero |
void |
close()
closes all open channels and the file |
void |
delete()
tries to delete the file |
abstract void |
enlargeFile(long size)
enlarges the file by the given size |
long |
getFilledUpFromContentStart()
|
long |
getFilledUpTo()
|
long |
getFreeSpace()
|
java.lang.String |
getName()
|
long |
getRemainingBytes(long offset)
returns the remaining bytes between filledUpTo and the given offset |
boolean |
isOpen()
|
void |
lock()
tries to lock the file |
void |
openChannel()
opens the RandomAccessFile and the corresponding FileChannel . |
abstract int |
read(long offset,
byte[] destBuffer)
Reads x bytes from the file to the given byte array, where x is the minimum of the size of the given byte array and the remaining written bytes in the file. |
abstract int |
read(long offset,
java.nio.ByteBuffer destBuffer)
Reads x bytes from the file to the given ByteBuffer, where x is the minimum of the capacity of the buffer and the remaining written bytes in the file. |
void |
unlock()
tries to unlock the file |
abstract void |
write(long offset,
byte[] sourceBuffer)
writes the bytes from the given Byte-array to the file beginning at offset. |
abstract void |
write(long offset,
java.nio.ByteBuffer sourceBuffer)
writes the bytes from the given ByteBuffer to the file beginning at offset. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public final int DEFAULT_SIZE
public final int RETRY_CONNECT_WAITTIME
public static final int HEADER_SIZE
public java.io.File osFile
Constructor Detail |
---|
public AbstractHeaderFile()
Method Detail |
---|
public abstract void enlargeFile(long size) throws java.io.IOException
size
-
java.io.IOException
public abstract void write(long offset, java.nio.ByteBuffer sourceBuffer) throws java.io.IOException
offset
- sourceBuffer
-
java.io.IOException
public abstract void write(long offset, byte[] sourceBuffer) throws java.io.IOException
offset
- sourceBuffer
-
java.io.IOException
public abstract long append(byte[] sourceBuffer) throws java.io.IOException
sourceBuffer
-
java.io.IOException
public abstract long append(java.nio.ByteBuffer sourceBuffer) throws java.io.IOException
sourceBuffer
-
java.io.IOException
public abstract int read(long offset, java.nio.ByteBuffer destBuffer) throws java.io.IOException
offset
- destBuffer
-
java.io.IOException
public abstract int read(long offset, byte[] destBuffer) throws java.io.IOException
offset
- destBuffer
-
java.io.IOException
public long getRemainingBytes(long offset)
filledUpTo
and the given offset
offset
-
public void clear()
public long getFilledUpFromContentStart()
public long getFilledUpTo()
public long getFreeSpace()
public void openChannel() throws FileLockException, java.io.IOException
RandomAccessFile
and the corresponding FileChannel
. Reads the header.
FileLockException
java.io.IOException
public void unlock() throws java.io.IOException
java.io.IOException
public void lock() throws FileLockException, java.io.IOException
FileLockException
java.io.IOException
public boolean isOpen()
public void close()
public void delete() throws java.io.IOException
java.io.IOException
public java.lang.String getName()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |