edu.iu.iv.core.persistence
Interface Persister

All Known Implementing Classes:
DelimitedDenseDoubleMatrixModelPersister, DelimitedSparseDoubleMatrixModelPersister, JUNGGraphMLPersister, JUNGGraphPajekPersister

public interface Persister

A Persister is responsible for saving and restoring models to and from a resource. It is recommended that all components in the IVC communicate their persistence needs to the Persistence layer instead of directly writing file readers and writers or establishing database connections. This ensures that the framework is 'aware' of all such processes at runtime. This awareness can be communicated to the user at all times; such transparency of operation is fundamental to the IVC. Delegating the persistence operations to the persistence layer also helps the algorithm implementations to concentrate on optimizing the algorithm itself and cleanly separates the algorithm from its data persistence functions.

Version:
0.1
Author:
Team IVC
See Also:
IVC, ResourceDescriptor

Method Summary
 boolean canPersist(java.lang.Object model)
          Determines if this persister can persist the given data model.
 boolean canRestore(ResourceDescriptor resource)
           
 PropertyMap getPropertyMap()
          Gets a property map describing this persister and file format (if applicable).
 void persist(java.lang.Object model, ResourceDescriptor resource)
          Persists a data model to a resource such as a file or database.
 java.lang.Object restore(ResourceDescriptor resource)
          Restores a model from the specified resource.
 

Method Detail

persist

public void persist(java.lang.Object model,
                    ResourceDescriptor resource)
             throws java.io.IOException,
                    PersistenceException
Persists a data model to a resource such as a file or database.

Parameters:
model - The model to be persisted.
resource - The resource to persist the model to.
Throws:
java.lang.Exception
java.io.IOException
PersistenceException

restore

public java.lang.Object restore(ResourceDescriptor resource)
                         throws java.io.IOException,
                                java.lang.OutOfMemoryError,
                                PersistenceException
Restores a model from the specified resource. This method

Returns:
The model to be restored from the data source.
java.io.IOException
java.lang.OutOfMemoryError
PersistenceException

canPersist

public boolean canPersist(java.lang.Object model)
Determines if this persister can persist the given data model.

Parameters:
model - The model for which persistence is desired.
Returns:
true if this persister can persist this object, false otherwise.

canRestore

public boolean canRestore(ResourceDescriptor resource)
Parameters:
resource - The resource from which restoration is desired. An example of a resource is a file on disk.
Returns:
true if this persister can persist to or restore from this resource, false otherwise.

getPropertyMap

public PropertyMap getPropertyMap()
Gets a property map describing this persister and file format (if applicable). If a persister does not wish to return a property map, it may return null. Returning a null value is highly discouraged. A persister must always provide enough information to let an application allow the user to make an informed choice.

Returns:
The property map of persister properties or null if the persister does not wish to return any map.
See Also:
edu.iu.iv.core.persistence.PersisterPropertyMap