@NotStorableClass public abstract class AbstractFileStorable extends Object implements IFileStorable
FileForStorable:FileForStorable manager to use| Modifier and Type | Field and Description |
|---|---|
protected IFileForStorable |
fileForStorable
to read/write this in file
|
protected boolean |
justCreated
true if just created in memory, never read from file
|
protected JoafipLogger |
logger |
protected int |
numberOfByteReadWrote
current number of byte read or wrote
|
protected long |
positionInFile
position in file of this in marshallized forms
|
protected boolean |
valueChangedToSave
true if this value changed, creation implies no value to save since not
read and not write
|
| Constructor and Description |
|---|
AbstractFileStorable(IFileForStorable fileForStorable,
long positionInFile) |
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
initial state:no value to save since not read and not write
|
boolean |
equals(Object obj) |
long |
getPositionInFile() |
int |
hashCode() |
boolean |
isJustCreated() |
boolean |
isValueChangedToSave()
to know if the value state change
|
protected abstract void |
marshallImpl()
marshaling implementation for write
#crc32 is set to zero |
protected void |
readAndCheckCrc32(int offset) |
protected boolean |
readBoolean() |
protected byte |
readByte() |
protected void |
readBytes(byte[] destination)
read bytes
|
protected byte[] |
readBytes(int length)
read bytes
|
protected int |
readFileAppendToIoBuffer(int newSize)
read extending ioBuffer
|
protected int |
readFileToIoBuffer(int size) |
void |
readFromFile()
read this file storable from file
|
protected int |
readInteger() |
protected long |
readLong()
unmarshal from byte array current
#dataByteArrayIndex index to
long#dataByteArrayIndex is updated to next data to read position |
void |
setValueIsChangedValueToSave()
set this record have value changed, so to save
|
void |
setValueIsNotChanged() |
protected abstract int |
toMarshallSize() |
String |
toString() |
protected abstract void |
unmarshallImpl()
Unmarshalling implementation for read
#crc32 is set to zero |
protected abstract void |
valueChangedAction() |
protected void |
writeBoolean(boolean value) |
protected void |
writeByte(byte value) |
protected void |
writeBytes(byte[] dataByteArray)
write bytes
|
protected void |
writeCrc32(int offset) |
protected void |
writeInteger(int value) |
protected void |
writeLong(long value)
Marshal long value to byte array current
#dataByteArrayIndex
index#dataByteArrayIndex is updated to next data to write position |
void |
writeToFile()
write this file storable to file
|
byte[] |
writeToFileGetWrited() |
clone, finalize, getClass, notify, notifyAll, wait, wait, waitgetPreviousRecordPositionInFile, getRecordSizeprotected final JoafipLogger logger
protected final long positionInFile
protected final IFileForStorable fileForStorable
protected transient int numberOfByteReadWrote
protected boolean valueChangedToSave
protected boolean justCreated
public AbstractFileStorable(IFileForStorable fileForStorable, long positionInFile)
fileForStorable - positionInFile - public void clear()
IFileStorableclear in interface IFileStorablepublic long getPositionInFile()
getPositionInFile in interface IFileStorablepublic void readFromFile()
throws HeapException
IFileStorablereadFromFile in interface IFileStorableHeapExceptionpublic void writeToFile()
throws HeapException
IFileStorablewriteToFile in interface IFileStorableHeapExceptionpublic byte[] writeToFileGetWrited()
throws HeapException
writeToFileGetWrited in interface IFileStorableHeapExceptionprotected abstract int toMarshallSize()
throws HeapException
HeapExceptionprotected abstract void unmarshallImpl()
throws HeapException
#crc32 is set to zeroHeapExceptionprotected abstract void marshallImpl()
throws HeapException
#crc32 is set to zeroHeapExceptionpublic boolean isJustCreated()
isJustCreated in interface IFileStorablepublic boolean isValueChangedToSave()
IFileStorableisValueChangedToSave in interface IFileStorablepublic void setValueIsChangedValueToSave()
throws HeapException
IFileStorablesetValueIsChangedValueToSave in interface IFileStorableHeapExceptionprotected abstract void valueChangedAction()
throws HeapException
HeapExceptionpublic void setValueIsNotChanged()
setValueIsNotChanged in interface IFileStorableprotected int readFileToIoBuffer(int size)
throws HeapException
HeapExceptionprotected int readFileAppendToIoBuffer(int newSize)
throws HeapException
newSize - ioBuffer new sizeHeapExceptionprotected void readAndCheckCrc32(int offset)
throws HeapException
HeapExceptionprotected byte[] readBytes(int length)
throws HeapException
length - number of bytes to readHeapExceptionprotected void readBytes(byte[] destination)
throws HeapException
length - number of bytes to readHeapExceptionprotected long readLong()
throws HeapException
#dataByteArrayIndex index to
long#dataByteArrayIndex is updated to next data to read positiondataByteArray - HeapExceptionprotected int readInteger()
throws HeapException
HeapExceptionprotected boolean readBoolean()
throws HeapException
HeapExceptionprotected byte readByte()
throws HeapException
HeapExceptionprotected void writeBytes(byte[] dataByteArray)
throws HeapException
dataByteArray - bytes to writeHeapExceptionprotected void writeLong(long value)
throws HeapException
#dataByteArrayIndex
index#dataByteArrayIndex is updated to next data to write positionvalue - the value to marshalHeapExceptionprotected void writeInteger(int value)
throws HeapException
HeapExceptionprotected void writeCrc32(int offset)
throws HeapException
HeapExceptionprotected void writeBoolean(boolean value)
throws HeapException
HeapExceptionprotected void writeByte(byte value)
throws HeapException
HeapExceptionCopyright © 2007-2012 Luc Peuvrier. All Rights Reserved.