© 2006-2007 ETH Zurich

org.ximtec.igesture.storage
Class StorageManager

java.lang.Object
  extended by org.ximtec.igesture.storage.StorageManager
All Implemented Interfaces:
IStorageManager, StorageEngine

public class StorageManager
extends Object
implements IStorageManager

The front-end of the storage system. The storage manager uses a storage engine which provides functionality to access different data sources.

Version:
1.0, Dec 2006
Author:
Ueli Kurmann, igesture@uelikurmann.ch, Beat Signer, signer@inf.ethz.ch

Nested Class Summary
static class StorageManager.StorageEngineType
           
 
Constructor Summary
StorageManager(StorageEngine engine)
          Instantiates the storage manager with the given storage engine.
 
Method Summary
 void commit()
          Commits the Transaction
 void copyTo(File file)
           
static StorageEngine createStorageEngine(File file)
          Creates a new storage engine.
 void dispose()
          Disposes the storage engine.
static String generateUUID()
          Generates a UUID.
static StorageManager.StorageEngineType getEngineType(File file)
           
<T extends DataObject>
List<T>
load(Class<T> clazz)
          Returns a typed list of data objects.
<T extends DataObject>
T
load(Class<T> clazz, String id)
          Loads the data object of the given type with the given id.
<T extends DataObject>
List<T>
load(Class<T> clazz, String fieldName, Object value)
          Loads a collection of data objects
 void remove(DataObject dataObject)
          Removes the given data object from the storage.
 void store(DataObject dataObject)
          Stores a data object.
 void store(List<DataObject> dataObjects)
          Stores a list of data objects.
 void update(DataObject dataObject)
          Updates a data object.
 void update(List<DataObject> dataObjects)
          Updates a list of data objects.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StorageManager

public StorageManager(StorageEngine engine)
Instantiates the storage manager with the given storage engine.

Parameters:
engine - the storage engine to be used.
Method Detail

load

public <T extends DataObject> T load(Class<T> clazz,
                                     String id)
Loads the data object of the given type with the given id.

Specified by:
load in interface StorageEngine
Parameters:
clazz - the type of the data object to be retrieved.
id - the id of the data object.
Returns:
the data object with the given id.

load

public <T extends DataObject> List<T> load(Class<T> clazz)
Returns a typed list of data objects. All objects available in the collection with the given type are returned.

Specified by:
load in interface StorageEngine
Parameters:
clazz - the type of the data objects.
Returns:
a list of data objects of the given type.

remove

public void remove(DataObject dataObject)
Removes the given data object from the storage.

Specified by:
remove in interface StorageEngine

store

public void store(DataObject dataObject)
Stores a data object.

Specified by:
store in interface StorageEngine
Parameters:
object - the data object to be stored.

store

public void store(List<DataObject> dataObjects)
Stores a list of data objects.

Specified by:
store in interface IStorageManager
Parameters:
dataObjects - the data objects to be stored.

update

public void update(DataObject dataObject)
Updates a data object.

Specified by:
update in interface StorageEngine
Parameters:
dataObject - the data object to be updated.

update

public void update(List<DataObject> dataObjects)
Updates a list of data objects.

Specified by:
update in interface IStorageManager
Parameters:
dataObjects - the list of data objects to be updated.

generateUUID

public static String generateUUID()
Generates a UUID. This id is used to identify data objects.

Returns:
an new UUID

createStorageEngine

public static StorageEngine createStorageEngine(File file)
Creates a new storage engine. The type of the storage engine is determined based on the file extension. Dynamic class loading should be used to avoid any license conflicts.

Parameters:
file - the file from which the storage engine is created.
Returns:
the new storage engine.

getEngineType

public static StorageManager.StorageEngineType getEngineType(File file)

dispose

public void dispose()
Disposes the storage engine.

Specified by:
dispose in interface StorageEngine

load

public <T extends DataObject> List<T> load(Class<T> clazz,
                                           String fieldName,
                                           Object value)
Description copied from interface: StorageEngine
Loads a collection of data objects

Specified by:
load in interface StorageEngine

commit

public void commit()
Description copied from interface: StorageEngine
Commits the Transaction

Specified by:
commit in interface StorageEngine

copyTo

public void copyTo(File file)
Specified by:
copyTo in interface StorageEngine

© 2006-2007 ETH Zurich

Copyright © 2007-2010 Global Information Systems Group, ETH Zurich. All Rights Reserved.