context.arch.storage
Class VectorStorage

java.lang.Object
  extended bycontext.arch.storage.VectorStorage
All Implemented Interfaces:
Storage

public class VectorStorage
extends java.lang.Object
implements Storage

This class allows storage and retrieval of data in String, Integer, Long, Float, Double, or Short format. It implements the Storage interface, using a Vector to store data temporarily. It can flush locally stored data to persistent data upon request.


Field Summary
static long DEFAULT_FLUSH_CONDITION
          Default flush condition is 2 (i.e.
static int DEFAULT_FLUSH_TYPE
          Default flush type is by number of stores
static char NEW_SEPARATOR
          Separator used by database in structured info
static java.lang.String NEW_SEPARATOR_STRING
          Separator used by database in structured info - String
static char OLD_SEPARATOR
          Separator used in structured info
static java.lang.String OLD_SEPARATOR_STRING
          Separator used in structured info - String
 
Fields inherited from interface context.arch.storage.Storage
DATA, EQUAL, GREATERTHAN, GREATERTHANEQUAL, LESSTHAN, LESSTHANEQUAL, NO_STORAGE, TIME
 
Constructor Summary
VectorStorage(java.lang.String table)
          Basic constructor that uses the default flush condition
VectorStorage(java.lang.String tableName, java.lang.Integer flushType, java.lang.Long flushCondition)
          Basic constructor that uses the given flush type and condition
 
Method Summary
 boolean checkFlushCondition()
          Checks condition under which local data is sent to persistent storage.
 void flushStorage()
          Flushes local data to persistent storage
 RetrievalResults retrieveAttributes(Retrieval retrieval)
          This method returns a Vector containing AttributeNameValue objects that match the given conditions in the Retrieval object.
 RetrievalResults retrieveAttributes(java.lang.String accessorId, Retrieval retrieval)
          This method returns a Vector containing AttributeNameValue objects that match the given conditions in the Retrieval object.
 void setAttributes(Attributes attributes, java.util.Hashtable attTypes)
          This method sets the attributes to use for storage.
 void store(Attributes atts)
          This method stores the given AttributeNameValues object
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_FLUSH_TYPE

public static final int DEFAULT_FLUSH_TYPE
Default flush type is by number of stores

See Also:
Constant Field Values

DEFAULT_FLUSH_CONDITION

public static final long DEFAULT_FLUSH_CONDITION
Default flush condition is 2 (i.e. flush after 2 stores)

See Also:
Constant Field Values

OLD_SEPARATOR

public static final char OLD_SEPARATOR
Separator used in structured info

See Also:
Constant Field Values

OLD_SEPARATOR_STRING

public static final java.lang.String OLD_SEPARATOR_STRING
Separator used in structured info - String


NEW_SEPARATOR

public static final char NEW_SEPARATOR
Separator used by database in structured info

See Also:
Constant Field Values

NEW_SEPARATOR_STRING

public static final java.lang.String NEW_SEPARATOR_STRING
Separator used by database in structured info - String

Constructor Detail

VectorStorage

public VectorStorage(java.lang.String table)
              throws java.sql.SQLException
Basic constructor that uses the default flush condition

Parameters:
table - Name of table to use
Throws:
java.sql.SQLException - if errors in accessing table info

VectorStorage

public VectorStorage(java.lang.String tableName,
                     java.lang.Integer flushType,
                     java.lang.Long flushCondition)
              throws java.sql.SQLException
Basic constructor that uses the given flush type and condition

Parameters:
flushType - Flush to database based on TIME or DATA
flushCondition - Condition to flush local storage to database
Throws:
java.sql.SQLException - if errors in accessing table info
Method Detail

store

public void store(Attributes atts)
This method stores the given AttributeNameValues object

Specified by:
store in interface Storage
Parameters:
atts - AttributeNameValues to store

retrieveAttributes

public RetrievalResults retrieveAttributes(java.lang.String accessorId,
                                           Retrieval retrieval)
This method returns a Vector containing AttributeNameValue objects that match the given conditions in the Retrieval object. It takes in the accessorId of the "user" requesting the information, but does nothing with it currently.

Specified by:
retrieveAttributes in interface Storage
Parameters:
accessorId - Id of the "user" trying to retrieve the data
retrieval - Retrievals object containing conditions for data retrieval
Returns:
RetrievalResults containing AttributeNameValues objects that match the given conditions

retrieveAttributes

public RetrievalResults retrieveAttributes(Retrieval retrieval)
This method returns a Vector containing AttributeNameValue objects that match the given conditions in the Retrieval object.

Specified by:
retrieveAttributes in interface Storage
Parameters:
retrieval - Retrievals object containing conditions for data retrieval
Returns:
RetrievalResults containing AttributeNameValues objects that match the given conditions

checkFlushCondition

public boolean checkFlushCondition()
Checks condition under which local data is sent to persistent storage.

Specified by:
checkFlushCondition in interface Storage
Returns:
Boolean value which indicates flushing is necessary or not

flushStorage

public void flushStorage()
Flushes local data to persistent storage

Specified by:
flushStorage in interface Storage

setAttributes

public void setAttributes(Attributes attributes,
                          java.util.Hashtable attTypes)
This method sets the attributes to use for storage. The attributes are used to set up the columns in a database table.

Specified by:
setAttributes in interface Storage
Parameters:
attributes - Attributes object containing attributes and type info
attTypes - Flattened hashtable version of Attributes