@NotStorableClass public abstract class AbstractFileStorable extends Object implements IFileStorable
FileForStorable
:FileForStorable
manager to useModifier 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, wait
getPreviousRecordPositionInFile, getRecordSize
protected 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()
IFileStorable
clear
in interface IFileStorable
public long getPositionInFile()
getPositionInFile
in interface IFileStorable
public void readFromFile() throws HeapException
IFileStorable
readFromFile
in interface IFileStorable
HeapException
public void writeToFile() throws HeapException
IFileStorable
writeToFile
in interface IFileStorable
HeapException
public byte[] writeToFileGetWrited() throws HeapException
writeToFileGetWrited
in interface IFileStorable
HeapException
protected abstract int toMarshallSize() throws HeapException
HeapException
protected abstract void unmarshallImpl() throws HeapException
#crc32
is set to zeroHeapException
protected abstract void marshallImpl() throws HeapException
#crc32
is set to zeroHeapException
public boolean isJustCreated()
isJustCreated
in interface IFileStorable
public boolean isValueChangedToSave()
IFileStorable
isValueChangedToSave
in interface IFileStorable
public void setValueIsChangedValueToSave() throws HeapException
IFileStorable
setValueIsChangedValueToSave
in interface IFileStorable
HeapException
protected abstract void valueChangedAction() throws HeapException
HeapException
public void setValueIsNotChanged()
setValueIsNotChanged
in interface IFileStorable
protected int readFileToIoBuffer(int size) throws HeapException
HeapException
protected int readFileAppendToIoBuffer(int newSize) throws HeapException
newSize
- ioBuffer new sizeHeapException
protected void readAndCheckCrc32(int offset) throws HeapException
HeapException
protected byte[] readBytes(int length) throws HeapException
length
- number of bytes to readHeapException
protected void readBytes(byte[] destination) throws HeapException
length
- number of bytes to readHeapException
protected long readLong() throws HeapException
#dataByteArrayIndex
index to
long#dataByteArrayIndex
is updated to next data to read positiondataByteArray
- HeapException
protected int readInteger() throws HeapException
HeapException
protected boolean readBoolean() throws HeapException
HeapException
protected byte readByte() throws HeapException
HeapException
protected void writeBytes(byte[] dataByteArray) throws HeapException
dataByteArray
- bytes to writeHeapException
protected void writeLong(long value) throws HeapException
#dataByteArrayIndex
index#dataByteArrayIndex
is updated to next data to write positionvalue
- the value to marshalHeapException
protected void writeInteger(int value) throws HeapException
HeapException
protected void writeCrc32(int offset) throws HeapException
HeapException
protected void writeBoolean(boolean value) throws HeapException
HeapException
protected void writeByte(byte value) throws HeapException
HeapException
Copyright © 2007-2012 Luc Peuvrier. All Rights Reserved.