edu.iu.iv.common.persistence.ivc
Class DelimitedDenseDoubleMatrixModelPersister

java.lang.Object
  |
  +--edu.iu.iv.common.persistence.ivc.DelimitedDenseDoubleMatrixModelPersister
All Implemented Interfaces:
Persister

public class DelimitedDenseDoubleMatrixModelPersister
extends java.lang.Object
implements Persister

This persister can restore dense matrices to a delimited file. The extension for such files should be ".mat". The format for such a file is as follows: The first line should start with the delimiter, then the number of rows and columns. This delimiter is used as the delimiter throughout the file. The second line stores the row labels preceded by the string "RowLabels" (case-insensitive) and the delimiter The labels must be separated by the delimiter again. The third line stores the column labels preceded by the string "columnlabels" (case-insensitive) and the delimiter. The labels must be separated by the delimiter again. The fourth line has the string "Data" (case-insensitive) followed by a delimiter. Finally the data of the matrix is stored in file, with each row occupying a line in the file. The elements of the matrix must be separated by the delimiter again. An example of a complete file:

  ,5,5
  rowlabels,doc1,doc2,doc3,doc4,doc5
  columnlabels,term1,term2,term3,term4,term5
  data,
  11,12,13,14,15
  21,22,23,24,25
  31,32,33,34,35
  41,42,43,44,45
  51,52,53,54,55
 
The labels are optional and you may provide only some of the labels if you wish. For example, the following line: rowlabels,doc1,,doc3,,doc5 will assign labels only to rows 1, 3 and 5 and set the rest to an empty string "".

Version:
0.1
Author:
Team IVC

Constructor Summary
DelimitedDenseDoubleMatrixModelPersister()
           
 
Method Summary
 boolean canPersist(java.lang.Object model)
          Determines if this persister can persist the given data model to the given data resource.
 boolean canRestore(ResourceDescriptor resource)
          Determines if this persister can restore the given data model from the given data resource.
 PropertyMap getPropertyMap()
          Gets a property map describing this persister and file format (if applicable).
 void persist(java.lang.Object model, ResourceDescriptor dataSource)
          Persists a data model to a resource such as a file or database.
 java.lang.Object restore(ResourceDescriptor dataSource)
          Restores a model from the specified resource.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DelimitedDenseDoubleMatrixModelPersister

public DelimitedDenseDoubleMatrixModelPersister()
Method Detail

getPropertyMap

public PropertyMap getPropertyMap()
Description copied from interface: Persister
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.

Specified by:
getPropertyMap in interface Persister
Returns:
The property map of persister properties or null if the persister does not wish to return any map.
See Also:
Persister.getPropertyMap()

persist

public void persist(java.lang.Object model,
                    ResourceDescriptor dataSource)
             throws java.io.IOException,
                    PersistenceException
Description copied from interface: Persister
Persists a data model to a resource such as a file or database.

Specified by:
persist in interface Persister
Parameters:
model - The model to be persisted.
dataSource - The resource to persist the model to.
java.io.IOException
PersistenceException
See Also:
Persister.persist(java.lang.Object, edu.iu.iv.core.persistence.ResourceDescriptor)

restore

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

Specified by:
restore in interface Persister
Returns:
The model to be restored from the data source.
java.io.IOException
PersistenceException
java.lang.OutOfMemoryError
See Also:
Persister.restore(edu.iu.iv.core.persistence.ResourceDescriptor)

canPersist

public boolean canPersist(java.lang.Object model)
Determines if this persister can persist the given data model to the given data resource. This method returns true if The model is of type DoubleMatrixModel.

Specified by:
canPersist in interface Persister
Parameters:
model - The model to be persisted.
Returns:
true if this persister can persist this object, false otherwise.
See Also:
Persister.canPersist(java.lang.Object)

canRestore

public boolean canRestore(ResourceDescriptor resource)
Determines if this persister can restore the given data model from the given data resource. This method returns true if 1. The ResourceDescriptor is of a FileResourceDescriptor type and 2. The format is ".mat" 3. It is uncompressed.

Specified by:
canRestore in interface Persister
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.
See Also:
Persister.canRestore(ResourceDescriptor)