com.mobixess.jodb.soda.api
Interface ObjectContainer

All Known Implementing Classes:
JODBSessionContainer

public interface ObjectContainer

database engine interface.

The ObjectContainer interface provides all methods to store, retrieve and delete objects and to change object state.


Method Summary
 void activate(java.lang.Object obj, int depth)
          Activates all members on a stored object to the specified depth.
 boolean close()
          closes the ObjectContainer.
 void commit()
          Commits the running transaction.
 void deactivate(java.lang.Object obj, int depth)
          deactivates a stored object by setting all members to NULL.
 void delete(java.lang.Object obj)
          deletes a stored object permanently.
<T> ObjectSet<T>
get(java.lang.Object template)
          Query-By-Example interface to retrieve objects.
 Query query()
          creates a new S.O.D.A.
<Type> ObjectSet<Type>
query(java.lang.Class<Type> clazz)
          queries for all instances of a class.
 void rollback()
          rolls back the running transaction.
 void set(java.lang.Object obj)
          Newly stores objects or updates stored objects.
 void set(java.lang.Object obj, int depth)
          Newly stores objects or updates stored objects.
 

Method Detail

activate

void activate(java.lang.Object obj,
              int depth)
              throws java.io.IOException
Activates all members on a stored object to the specified depth.

Throws:
java.io.IOException

close

boolean close()
              throws java.io.IOException
closes the ObjectContainer.

A call to close() automatically performs a commit().

Every session opened with JODB.openFile() requires one close()call, even if the same filename was used multiple times.

Use while(!close()){} to close all sessions using this container.

Returns:
success - true denotes that the last used instance of this container and the database file were closed.
Throws:
java.io.IOException

commit

void commit()
            throws java.io.IOException
Commits the running transaction.

Throws:
java.io.IOException

deactivate

void deactivate(java.lang.Object obj,
                int depth)
deactivates a stored object by setting all members to NULL.
Primitive types will be set to their default values. The method has no effect, if the passed object is not stored in the ObjectContainer

Parameters:
obj - the object to be deactivated.
depth - the member to which deactivate is to cascade.

delete

void delete(java.lang.Object obj)
            throws java.io.IOException
deletes a stored object permanently.

Note that this method has to be called for every single object individually. Delete does not recurse to object members. Simple and array member types are destroyed. The method has no effect, if the passed object is not stored in the ObjectContainer. which can be also used for cascaded deletes.

Parameters:
obj - the object to be deleted from the ObjectContainer.
Throws:
java.io.IOException

get

<T> ObjectSet<T> get(java.lang.Object template)
                 throws java.io.IOException,
                        IllegalClassTypeException
Query-By-Example interface to retrieve objects.

get() creates an ObjectSet containing all objects in the ObjectContainer that match the passed template object.

Calling get(NULL) returns all objects stored in the ObjectContainer.


Query Evaluation
All non-null members of the template object are compared against all stored objects of the same class. Primitive type members are ignored if they are 0 or false respectively.

Returned Objects
The objects returned in the ObjectSet are instantiated and activated to the preconfigured depth. The activation depth may be configured globally via com.mobixess.jodb.core.JODBConfig#setDefaultActivationDepth() .

The database keeps track of all instantiatied objects. Queries will return references to these objects instead of instantiating them a second time.

Parameters:
template - object to be used as an example to find all matching objects.

Returns:
ObjectSet containing all found objects.

Throws:
java.io.IOException
IllegalClassTypeException

query

Query query()
creates a new S.O.D.A. Query.

Use get(Object template) for simple Query-By-Example.



Returns:
a new Query object

query

<Type> ObjectSet<Type> query(java.lang.Class<Type> clazz)
                      throws java.io.IOException,
                             IllegalClassTypeException
queries for all instances of a class.

Parameters:
clazz - the class to query for.
Returns:
the ObjectSet returned by the query.
Throws:
java.io.IOException
IllegalClassTypeException

rollback

void rollback()
rolls back the running transaction.

Modified application objects im memory are not restored. Use combined calls to deactivate() and activate() to reload an objects member values.


set

void set(java.lang.Object obj)
         throws IllegalClassTypeException,
                java.io.IOException
Newly stores objects or updates stored objects.

An object not yet stored in the ObjectContainer will be stored when it is passed to set(). An object already stored in the ObjectContainer will be updated.

Parameters:
obj - the object to be stored or updated.
Throws:
java.io.IOException
{@link - IllegalClassTypeException}
IllegalClassTypeException

set

void set(java.lang.Object obj,
         int depth)
         throws IllegalClassTypeException,
                java.io.IOException
Newly stores objects or updates stored objects.

An object not yet stored in the ObjectContainer will be stored when it is passed to set(). An object already stored in the ObjectContainer will be updated.

Parameters:
obj - the object to be stored or updated.
depth - the depth to which the object is to be updated
Throws:
IllegalClassTypeException
java.io.IOException


Copyright © Mobixess Inc. All Rights Reserved.