org.openmobileis.database.fastobjectdb.db.store
Class FODBCollectionFile

java.lang.Object
  |
  +--org.openmobileis.database.fastobjectdb.db.store.FODBCollectionFile

public class FODBCollectionFile
extends java.lang.Object

FODBCollectionFile is a Class that defines simple functions access our data file.


Method Summary
 long addIndex(long indexPos)
          Add an index to the indexs table.
static FODBCollectionFile createCollection(java.lang.String filePath, java.lang.Class objType, java.lang.String colname, FastObjectDB db)
          The function that is called to create a new Collection file.
 void deleteObject(long pos)
          Delete an Object
 FODBCypher getCollectionCypher()
          return the collection cypher if any, null otherwise.
 FODBIndexHeader[] getIndexsHeaders()
          Read the indexs table.
 java.lang.Class getObjectType()
           
 boolean isSynchronized()
           
static FODBCollectionFile openCollection(java.lang.String filePath, java.lang.String colname, FastObjectDB db)
          The function that is called to open an existing Collection file.
 FODBCollectionFileHeader readHeader()
          Read the header which is situated at the beginning of the collection file and return it.
 java.lang.Object readNode(long pos)
          Read Object at pos.
 java.lang.Object readObject(long pos)
          Read Object at pos.
 void rewriteHeader()
           
 void rewriteNode(java.lang.Object obj, long pos)
          Rewrite an object The object has to be the same size it used to be.
 void rewriteObjectt(java.lang.Object obj, long pos)
          Rewrite an object The object has to be the same size it used to be.
 void setCollectionCypher(FODBCypher cypher)
          Init collection encryption with the specified cypher.
 void setSynchronized(boolean sync)
           
 java.lang.String toString()
          Used for debugging.
 void writeHeader()
          Write the header at the beginning of the collection file.
 long writeNode(java.lang.Object obj)
          Write an object.
 long writeObject(java.lang.Object obj)
          Write an object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

isSynchronized

public boolean isSynchronized()

getCollectionCypher

public FODBCypher getCollectionCypher()
                               throws FODBException
return the collection cypher if any, null otherwise.
Returns:
cypher use to encrypt data, null otherwise.

setCollectionCypher

public void setCollectionCypher(FODBCypher cypher)
                         throws FODBException
Init collection encryption with the specified cypher. Must be call just after collection initialization before storing/reading any data. Same cypher must be provided to read already stored object.
Parameters:
cypher - : cypher to be use to encrypt data.

setSynchronized

public void setSynchronized(boolean sync)
                     throws java.io.IOException,
                            java.lang.ClassNotFoundException

createCollection

public static FODBCollectionFile createCollection(java.lang.String filePath,
                                                  java.lang.Class objType,
                                                  java.lang.String colname,
                                                  FastObjectDB db)
                                           throws java.io.IOException,
                                                  java.lang.ClassNotFoundException
The function that is called to create a new Collection file. It just calls the constructor with the argument ACTION_CREATE.
Parameters:
filePath - - same as constructor
objType - - same as constructor
Returns:
the object created.
Throws:
FODBDataFileException -  

openCollection

public static FODBCollectionFile openCollection(java.lang.String filePath,
                                                java.lang.String colname,
                                                FastObjectDB db)
                                         throws java.io.IOException,
                                                java.lang.ClassNotFoundException
The function that is called to open an existing Collection file. It just calls the constructor with the argument ACTION_OPEN.
Parameters:
filePath - - same as constructor
Returns:
the object created or null if the file does not exist.
Throws:
FODBDataFileException -  

addIndex

public long addIndex(long indexPos)
              throws java.io.IOException,
                     java.lang.ClassNotFoundException
Add an index to the indexs table.
Parameters:
indexPos - - position of the new index in the file.
Returns:
indexPos (might be suppressed).
Throws:
FODBDataFileException -  

readNode

public java.lang.Object readNode(long pos)
                          throws java.io.IOException,
                                 java.lang.ClassNotFoundException
Read Object at pos.
Parameters:
pos - - position of the object to read.
Returns:
the read object.
Throws:
FODBDataFileException -  

writeNode

public long writeNode(java.lang.Object obj)
               throws java.io.IOException,
                      java.lang.ClassNotFoundException
Write an object.
Parameters:
obj - - object to wright.
Returns:
- the position of the object written.
Throws:
FODBDataFileException -  

rewriteNode

public void rewriteNode(java.lang.Object obj,
                        long pos)
                 throws java.io.IOException,
                        java.lang.ClassNotFoundException
Rewrite an object The object has to be the same size it used to be. The function doesn't check this. It is the role of the developper.
Parameters:
obj - - object to write
pos - - position in the collection file.
Throws:
FODBDataFileException -  

readObject

public java.lang.Object readObject(long pos)
                            throws java.io.IOException,
                                   java.lang.ClassNotFoundException
Read Object at pos.
Parameters:
pos - - position of the object to read.
Returns:
the read object.
Throws:
FODBDataFileException -  

writeObject

public long writeObject(java.lang.Object obj)
                 throws java.io.IOException,
                        java.lang.ClassNotFoundException
Write an object.
Parameters:
obj - - object to wright.
Returns:
- the position of the object written.
Throws:
FODBDataFileException -  

rewriteObjectt

public void rewriteObjectt(java.lang.Object obj,
                           long pos)
                    throws java.io.IOException,
                           java.lang.ClassNotFoundException
Rewrite an object The object has to be the same size it used to be. The function doesn't check this. It is the role of the developper.
Parameters:
obj - - object to write
pos - - position in the collection file.
Throws:
FODBDataFileException -  

deleteObject

public void deleteObject(long pos)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Delete an Object
Parameters:
pos - - position of the object to delete.
Throws:
FODBDataFileException -  

writeHeader

public void writeHeader()
                 throws java.io.IOException,
                        java.lang.ClassNotFoundException
Write the header at the beginning of the collection file.
Throws:
FODBDataFileException -  

rewriteHeader

public void rewriteHeader()
                   throws java.io.IOException,
                          java.lang.ClassNotFoundException

readHeader

public FODBCollectionFileHeader readHeader()
                                    throws java.io.IOException,
                                           java.lang.ClassNotFoundException
Read the header which is situated at the beginning of the collection file and return it.
Returns:
- The header of the file.
Throws:
FODBDataFileException -  

getObjectType

public java.lang.Class getObjectType()

getIndexsHeaders

public FODBIndexHeader[] getIndexsHeaders()
                                   throws java.io.IOException,
                                          java.lang.ClassNotFoundException
Read the indexs table. Then get all indexs header, and return them as a table.
Returns:
- a table of indexsHeader.
Throws:
FODBDataFileException -  

toString

public java.lang.String toString()
Used for debugging.
Overrides:
toString in class java.lang.Object


Copyright 2005 e-Care. All Rights Reserved.