org.neodatis.odb.core.layers.layer3
Interface IObjectWriter

All Superinterfaces:
ITwoPhaseInit
All Known Implementing Classes:
AbstractObjectWriter, LocalObjectWriter, ServerObjectWriter

public interface IObjectWriter
extends ITwoPhaseInit


Method Summary
 ClassInfo addClass(ClassInfo newClassInfo, boolean addDependentClasses)
           
 ClassInfoList addClasses(ClassInfoList classInfoList)
           
 void afterInit()
           
 long associateIdToObject(byte idType, byte idStatus, long currentBlockIdPosition, OID oid, long objectPosition, boolean writeInTransaction)
          Associate an object OID to its position
 void close()
           
 void createEmptyDatabaseHeader(long creationDate, java.lang.String user, java.lang.String password)
          Creates the header of the file
 OID delete(ObjectInfoHeader header)
           
 void flush()
           
 IFileSystemInterface getFsi()
           
 IIdManager getIdManager()
           
 ISession getSession()
           
 OID insertNonNativeObject(OID oid, NonNativeObjectInfo nnoi, boolean isNewObject)
           
 int manageIndexesForDelete(OID oid, NonNativeObjectInfo nnoi)
          Insert the object in the index
 int manageIndexesForInsert(OID oid, NonNativeObjectInfo nnoi)
          Insert the object in the index
 int manageIndexesForUpdate(OID oid, NonNativeObjectInfo nnoi, NonNativeObjectInfo oldMetaRepresentation)
           
 int markAsDeleted(long currentPosition, OID oid, boolean writeInTransaction)
          Mark a block as deleted
 long markIdBlockAsFull(long blockPosition, long nextBlockPosition, boolean writeInTransaction)
          Marks a block of type id as full, changes the status and the next block position
 ClassInfo persistClass(ClassInfo newClassInfo, int lastClassInfoIndex, boolean addClass, boolean addDependentClasses)
          Persist a single class info - This method is used by the XML Importer.
 void setTriggerManager(ITriggerManager triggerManager)
           
 void updateClassInfo(ClassInfo classInfo, boolean writeInTransaction)
           
 void updateClassPositionForClassOIDWithPosition(long idPosition, long objectPosition, boolean writeInTransaction)
          Udates the real class positon of the class OID
 void updateInstanceFieldsOfClassInfo(ClassInfo classInfo, boolean writeInTransaction)
          Updates the instance related field of the class info into the database file Updates the number of objects, the first object oid and the next class oid
 void updateNextObjectFieldOfObjectInfo(OID objectOID, OID nextObjectOID, boolean writeInTransaction)
          Update next object oid field of the object at the specific position
 OID updateNonNativeObjectInfo(NonNativeObjectInfo nnoi, boolean forceUpdate)
          Updates an object.
 void updateObjectPositionForObjectOIDWithPosition(long idPosition, long objectPosition, boolean writeInTransaction)
          Updates the real object position of the object OID
 void updatePreviousObjectFieldOfObjectInfo(OID objectOID, OID previousObjectOID, boolean writeInTransaction)
          Updates the previous object position field of the object at objectPosition
 void updateStatusForIdWithPosition(long idPosition, byte newStatus, boolean writeInTransaction)
           
 long writeAtomicNativeObject(AtomicNativeObjectInfo anoi, boolean writeInTransaction, int totalSpaceIfString)
           
 void writeClassInfoHeader(ClassInfo classInfo, long position, boolean writeInTransaction)
          Write the class info header to the database file
 long writeIdBlock(long position, int idBlockSize, byte blockStatus, int blockNumber, long previousBlockPosition, boolean writeInTransaction)
          Writes the header of a block of type ID - a block that contains ids of objects and classes
 void writeLastODBCloseStatus(boolean ok, boolean writeInTransaction)
          Write the status of the last odb close
 void writeLastTransactionId(TransactionId transactionId)
           
 OID writeNonNativeObjectInfo(OID existingOid, NonNativeObjectInfo objectInfo, long position, boolean writeDataInTransaction, boolean isNewObject)
          Write an object representation to database file
 
Methods inherited from interface org.neodatis.odb.core.ITwoPhaseInit
init2
 

Method Detail

addClasses

ClassInfoList addClasses(ClassInfoList classInfoList)

writeClassInfoHeader

void writeClassInfoHeader(ClassInfo classInfo,
                          long position,
                          boolean writeInTransaction)
Write the class info header to the database file

Parameters:
classInfo - The class info to be written
position - The position at which it must be written
writeInTransaction - true if the write must be done in transaction, false to write directly

updateClassInfo

void updateClassInfo(ClassInfo classInfo,
                     boolean writeInTransaction)

updateNonNativeObjectInfo

OID updateNonNativeObjectInfo(NonNativeObjectInfo nnoi,
                              boolean forceUpdate)
Updates an object.
 Try to update in place. Only change what has changed. This is restricted to particular types (fixed size types). If in place update is 
 not possible, then deletes the current object and creates a new at the end of the database file and updates
 OID object position.

Parameters:
nnoi - The meta representation of the object to be updated
forceUpdate - when true, no verification is done to check if update must be done.
Returns:
The oid of the object, as a negative number

writeNonNativeObjectInfo

OID writeNonNativeObjectInfo(OID existingOid,
                             NonNativeObjectInfo objectInfo,
                             long position,
                             boolean writeDataInTransaction,
                             boolean isNewObject)
Write an object representation to database file

Parameters:
existingOid - The oid of the object, can be null
objectInfo - The Object meta representation
position - The position where the object must be written, can be -1
writeDataInTransaction - To indicate if the write must be done in or out of transaction
Returns:
The oid of the object
Throws:
java.lang.Exception

writeAtomicNativeObject

long writeAtomicNativeObject(AtomicNativeObjectInfo anoi,
                             boolean writeInTransaction,
                             int totalSpaceIfString)

getIdManager

IIdManager getIdManager()

getSession

ISession getSession()

close

void close()

getFsi

IFileSystemInterface getFsi()

createEmptyDatabaseHeader

void createEmptyDatabaseHeader(long creationDate,
                               java.lang.String user,
                               java.lang.String password)
Creates the header of the file

Parameters:
creationDate - The creation date
user - The user
password - The password

markAsDeleted

int markAsDeleted(long currentPosition,
                  OID oid,
                  boolean writeInTransaction)
Mark a block as deleted

Parameters:
currentPosition -
Returns:
The block size

manageIndexesForInsert

int manageIndexesForInsert(OID oid,
                           NonNativeObjectInfo nnoi)
Insert the object in the index

Parameters:
oid - The object id
nnoi - The object meta represenation
Returns:
The number of indexes

manageIndexesForDelete

int manageIndexesForDelete(OID oid,
                           NonNativeObjectInfo nnoi)
Insert the object in the index

Parameters:
oid - The object id
nnoi - The object meta represenation
Returns:
The number of indexes
Throws:
java.lang.Exception

manageIndexesForUpdate

int manageIndexesForUpdate(OID oid,
                           NonNativeObjectInfo nnoi,
                           NonNativeObjectInfo oldMetaRepresentation)

writeLastODBCloseStatus

void writeLastODBCloseStatus(boolean ok,
                             boolean writeInTransaction)
Write the status of the last odb close


flush

void flush()

delete

OID delete(ObjectInfoHeader header)

updateStatusForIdWithPosition

void updateStatusForIdWithPosition(long idPosition,
                                   byte newStatus,
                                   boolean writeInTransaction)

updateObjectPositionForObjectOIDWithPosition

void updateObjectPositionForObjectOIDWithPosition(long idPosition,
                                                  long objectPosition,
                                                  boolean writeInTransaction)
Updates the real object position of the object OID

Parameters:
idPosition - The OID position
objectPosition - The real object position
writeInTransaction - To indicate if write must be done in transaction

updateClassPositionForClassOIDWithPosition

void updateClassPositionForClassOIDWithPosition(long idPosition,
                                                long objectPosition,
                                                boolean writeInTransaction)
Udates the real class positon of the class OID

Parameters:
idPosition -
objectPosition -
writeInTransaction -

associateIdToObject

long associateIdToObject(byte idType,
                         byte idStatus,
                         long currentBlockIdPosition,
                         OID oid,
                         long objectPosition,
                         boolean writeInTransaction)
Associate an object OID to its position

Parameters:
idType - The type : can be object or class
idStatus - The status of the OID
currentBlockIdPosition - The current OID block position
oid - The OID
objectPosition - The position
writeInTransaction - To indicate if write must be executed in transaction
Returns:

markIdBlockAsFull

long markIdBlockAsFull(long blockPosition,
                       long nextBlockPosition,
                       boolean writeInTransaction)
Marks a block of type id as full, changes the status and the next block position

Parameters:
blockPosition -
nextBlockPosition -
writeInTransaction -
Returns:
The block position

writeIdBlock

long writeIdBlock(long position,
                  int idBlockSize,
                  byte blockStatus,
                  int blockNumber,
                  long previousBlockPosition,
                  boolean writeInTransaction)
Writes the header of a block of type ID - a block that contains ids of objects and classes

Parameters:
position - Position at which the block must be written, if -1, take the next available position
idBlockSize - The block size in byte
blockStatus - The block status
blockNumber - The number of the block
previousBlockPosition - The position of the previous block of the same type
writeInTransaction - To indicate if write must be done in transaction
Returns:
The position of the id

updatePreviousObjectFieldOfObjectInfo

void updatePreviousObjectFieldOfObjectInfo(OID objectOID,
                                           OID previousObjectOID,
                                           boolean writeInTransaction)
Updates the previous object position field of the object at objectPosition

Parameters:
objectOID -
previousObjectOID -
writeInTransaction -

updateNextObjectFieldOfObjectInfo

void updateNextObjectFieldOfObjectInfo(OID objectOID,
                                       OID nextObjectOID,
                                       boolean writeInTransaction)
Update next object oid field of the object at the specific position

Parameters:
objectOID -
nextObjectOID -
writeInTransaction -

updateInstanceFieldsOfClassInfo

void updateInstanceFieldsOfClassInfo(ClassInfo classInfo,
                                     boolean writeInTransaction)
Updates the instance related field of the class info into the database file Updates the number of objects, the first object oid and the next class oid

Parameters:
classInfo - The class info to be updated
writeInTransaction - To specify if it must be part of a transaction

afterInit

void afterInit()

addClass

ClassInfo addClass(ClassInfo newClassInfo,
                   boolean addDependentClasses)

persistClass

ClassInfo persistClass(ClassInfo newClassInfo,
                       int lastClassInfoIndex,
                       boolean addClass,
                       boolean addDependentClasses)
Persist a single class info - This method is used by the XML Importer.


writeLastTransactionId

void writeLastTransactionId(TransactionId transactionId)

setTriggerManager

void setTriggerManager(ITriggerManager triggerManager)

insertNonNativeObject

OID insertNonNativeObject(OID oid,
                          NonNativeObjectInfo nnoi,
                          boolean isNewObject)
Parameters:
oid - The Oid of the object to be inserted
nnoi - The object meta representation The object to be inserted in the database
isNewObject - To indicate if object is new
Returns:
The position of the inserted object