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

java.lang.Object
  extended byorg.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, FODBCollectionDescriptor descriptor, 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.
 FODBCollectionDescriptor getDescriptor()
           
 FODBIndexHeader[] getIndexsHeaders()
          Read the indexs table.
 java.lang.Class getObjectType()
           
 boolean isCompressed()
          if isCompressed return true, all stored data object are zipped.
 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.
 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.
Throws:
FODBException

isCompressed

public boolean isCompressed()
if isCompressed return true, all stored data object are zipped. The compressed behaviour is defined by the FODBCollection descriptor. To gzip collection allow to gain around 25% of the collection file length but increase the synhro file size for complete synchro.


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.
Throws:
FODBException

createCollection

public static FODBCollectionFile createCollection(java.lang.String filePath,
                                                  FODBCollectionDescriptor descriptor,
                                                  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
Returns:
the object created.
Throws:
FODBDataFileException
java.io.IOException
java.lang.ClassNotFoundException

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
java.io.IOException
java.lang.ClassNotFoundException

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
java.io.IOException
java.lang.ClassNotFoundException

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
java.io.IOException
java.lang.ClassNotFoundException

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
java.io.IOException
java.lang.ClassNotFoundException

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
java.io.IOException
java.lang.ClassNotFoundException

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
java.io.IOException
java.lang.ClassNotFoundException

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
java.io.IOException
java.lang.ClassNotFoundException

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
java.io.IOException
java.lang.ClassNotFoundException

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
java.io.IOException
java.lang.ClassNotFoundException

writeHeader

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

Throws:
FODBDataFileException
java.io.IOException
java.lang.ClassNotFoundException

rewriteHeader

public void rewriteHeader()
                   throws java.io.IOException,
                          java.lang.ClassNotFoundException
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
java.io.IOException
java.lang.ClassNotFoundException

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
java.io.IOException
java.lang.ClassNotFoundException

getDescriptor

public FODBCollectionDescriptor getDescriptor()

toString

public java.lang.String toString()
Used for debugging.



Copyright 2006 OpenMobileIS. All Rights Reserved.