Class RandomAccessFilePaged
java.lang.Object
com.semedy.reasoner.edb.persistentstore.RandomAccessFilePaged
- All Implemented Interfaces:
RandomAccessToFile
A ramdom acess file paged. It provides a linear address room
- Author:
- juergen
-
Constructor Summary
ConstructorsConstructorDescriptionRandomAccessFilePaged(String filePath, String accessRights, int pagesize) creates a new file with given filepath and access rights "r" for read,
"rw" for read and write -
Method Summary
Modifier and TypeMethodDescriptionbooleancheckFile(long offset, int len) check file contentsvoidclose()close filevoiddelete()voidflush()close filelongget the current position of the filelonglength()Get the file lengthvoidread(byte[] bytes) Reads a byte array from current position.voidread(byte[] bytes, int offset, int len) Reads len bytes from current file position to array from offset position on.bytereadByte()Reads a byte from current position.intreadInt()Reads an int at current position.longreadLong()Reads a long at current position.voidseek(long position) Positions to an addressstatic voidunmap(MappedByteBuffer buffer) voidwrite(byte[] bytes) Writes a byte array to current position.voidwrite(byte[] bytes, int offset, int len) Writes len bytes from byte array from offset position on to current file position.voidwriteByte(int b) Reads a byte current positionvoidwriteInt(int value) Writes an int to current position.voidwriteInternal(byte[] bytes, int offset, int len) voidwriteLong(long value) Writes a long to current position.
-
Constructor Details
-
RandomAccessFilePaged
creates a new file with given filepath and access rights "r" for read,
"rw" for read and write- Parameters:
filePath-accessRights-- Throws:
IOException
-
-
Method Details
-
seek
Positions to an address- Specified by:
seekin interfaceRandomAccessToFile- Parameters:
position-- Throws:
IOException
-
read
Reads a byte array from current position.- Specified by:
readin interfaceRandomAccessToFile- Parameters:
bytes-- Throws:
IOException
-
read
Reads len bytes from current file position to array from offset position on.- Specified by:
readin interfaceRandomAccessToFile- Parameters:
bytes-- Throws:
IOException
-
write
Writes a byte array to current position.- Specified by:
writein interfaceRandomAccessToFile- Parameters:
bytes-- Throws:
IOException
-
writeInternal
public void writeInternal(byte[] bytes, int offset, int len) -
write
Writes len bytes from byte array from offset position on to current file position.- Specified by:
writein interfaceRandomAccessToFile- Parameters:
bytes-- Throws:
IOException
-
readByte
Description copied from interface:RandomAccessToFileReads a byte from current position.- Specified by:
readBytein interfaceRandomAccessToFile- Throws:
IOException
-
writeByte
Description copied from interface:RandomAccessToFileReads a byte current position- Specified by:
writeBytein interfaceRandomAccessToFile- Throws:
IOException
-
readInt
Reads an int at current position.- Specified by:
readIntin interfaceRandomAccessToFile- Throws:
IOException
-
writeInt
Writes an int to current position.- Specified by:
writeIntin interfaceRandomAccessToFile- Parameters:
value-- Throws:
IOException
-
close
close file- Specified by:
closein interfaceRandomAccessToFile- Throws:
IOException
-
flush
close file- Specified by:
flushin interfaceRandomAccessToFile- Throws:
IOException
-
readLong
Reads a long at current position. Creates an exception if byte array crosses a page border- Specified by:
readLongin interfaceRandomAccessToFile- Throws:
IOException
-
writeLong
Writes a long to current position. Creates an exception if byte array crosses a page border- Specified by:
writeLongin interfaceRandomAccessToFile- Parameters:
value-- Throws:
IOException
-
length
Get the file length- Specified by:
lengthin interfaceRandomAccessToFile- Throws:
IOException
-
delete
- Specified by:
deletein interfaceRandomAccessToFile- Throws:
IOException
-
unmap
-
getFilePointer
public long getFilePointer()Description copied from interface:RandomAccessToFileget the current position of the file- Specified by:
getFilePointerin interfaceRandomAccessToFile- Returns:
-
checkFile
Description copied from interface:RandomAccessToFilecheck file contents- Specified by:
checkFilein interfaceRandomAccessToFile- Returns:
- Throws:
IOException
-