org.objectweb.telosys.dal.tools
Class Serializer

java.lang.Object
  extended byorg.objectweb.telosys.dal.tools.Serializer

public class Serializer
extends java.lang.Object

Serializer tool to build basic DAO with "save/load/delete" operations


Constructor Summary
Serializer(java.lang.String sDataDirectory)
          Constructor
 
Method Summary
 int delete(java.lang.Class cl, java.lang.String sKey)
          Deletes the object instance file corresponding to the given key
 java.lang.Object load(java.lang.Class cl, java.lang.String sKey)
          Load an object from the instance file corresponding to the given key
 void save(java.lang.Object obj, java.lang.String sKey)
          Save the given object in a instance file indentifying by the given key
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Serializer

public Serializer(java.lang.String sDataDirectory)
Constructor

Parameters:
sDataDirectory - : the full path of the directory where to store the instances files
Method Detail

save

public void save(java.lang.Object obj,
                 java.lang.String sKey)
          throws TelosysException
Save the given object in a instance file indentifying by the given key

Parameters:
obj - : the object to save
sKey - : the key to use to identify the instance
Throws:
TelosysException

load

public java.lang.Object load(java.lang.Class cl,
                             java.lang.String sKey)
                      throws TelosysException
Load an object from the instance file corresponding to the given key

Parameters:
cl - : the class of the object to load
sKey - : the key of the object to load
Returns:
: the instance loaded, or null if not found
Throws:
TelosysException

delete

public int delete(java.lang.Class cl,
                  java.lang.String sKey)
           throws TelosysException
Deletes the object instance file corresponding to the given key

Parameters:
cl - : the class of the object to delete
sKey - : the key of the object to delete
Returns:
: 1 if the object file exists and has been deleted, 0 if the object file doesn't exist
Throws:
TelosysException