org.jlf.dataMap
Class DataMapper

java.lang.Object
  |
  +--org.jlf.dataMap.DataMapper
Direct Known Subclasses:
CRUDDataMapper, HTTPRequestDataMapper, XMLDataMapper

public abstract class DataMapper
extends java.lang.Object

This class is used as the base of all data mapping mechanisms in the data mapping framework. A data mapper is used to abstract the mechanism for communicating with a data source or sink. It generally maintains some sort of connection to the data source/sink.

See Also:
DataLocation, DataMappedObject

Field Summary
protected  DataArray dataArray
          Holds an array of data read in from a data location to be mapped to DataMappedObjects.
protected  DataLocation dataLocation
          The DataLocation that spawned the mapper.
 
Constructor Summary
DataMapper()
          Allow the default constructor, but please use a parameterized constructor!
DataMapper(DataLocation dataLocation)
          Constructs a new data mapper which references back to the DataLocation who created it.
 
Method Summary
abstract  void close()
          Close the data mapper so it can clean up any resources it may have allocated.
abstract  void commitWrites()
          This method is an abstract method for the purpose of commiting all writes to the data sink and doing any necessary cleanup afterward.
abstract  java.util.Vector findBySearchCriteria(DataMappedObject dmo, java.lang.String criteriaKey)
          This method is an abstract method for the purpose of using the current data location mapper to read any number of objects according to the DataMappedObject's type and search criteria.
protected  DataAttribute findDataAttributeForReplacementString(DataMappedObject dmo, java.lang.String replacementString)
          Retrieves a data attribute from the data mapped object (or a relationship of the object if the attribute has "." in it, with the prefix being the relationship name) for the replacement string given.
protected  java.util.Vector getCascadedRelationships(DataMappedObject dmo)
          Helper method to retrieve cascade write relationships for an object.
 DataLocation getDataLocation()
          Returns the DataLocation that spawned the mapper.
protected  java.lang.String replaceAttributeParameters(java.lang.String parameterString, DataMappedObject dmo)
          Replaces parameters in braces {} with the corresponding values from the data mapped object.
 void rollbackWrites()
          This method is an abstract method for the purpose of rolling back any writes to the data sink.
 void setDataLocation(DataLocation dataLocation)
           
protected  java.lang.String stringForDataAttributeReplacement(DataMappedObject dmo, java.lang.String replacementString)
          Retrieves a data attribute for the data mapped object and replacement string, then converts that attribute into a useful string.
abstract  void write(DataMappedObject dmo, Relationship relationship)
          This method is an abstract method for the purpose of writing a data mapped object, potentially in the context of a relationship, to a data store.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dataLocation

protected DataLocation dataLocation
The DataLocation that spawned the mapper.


dataArray

protected DataArray dataArray
Holds an array of data read in from a data location to be mapped to DataMappedObjects.

Constructor Detail

DataMapper

public DataMapper()
Allow the default constructor, but please use a parameterized constructor!


DataMapper

public DataMapper(DataLocation dataLocation)
Constructs a new data mapper which references back to the DataLocation who created it.

Method Detail

getDataLocation

public DataLocation getDataLocation()
Returns the DataLocation that spawned the mapper.


setDataLocation

public void setDataLocation(DataLocation dataLocation)

close

public abstract void close()
Close the data mapper so it can clean up any resources it may have allocated.


findDataAttributeForReplacementString

protected DataAttribute findDataAttributeForReplacementString(DataMappedObject dmo,
                                                              java.lang.String replacementString)
Retrieves a data attribute from the data mapped object (or a relationship of the object if the attribute has "." in it, with the prefix being the relationship name) for the replacement string given. For any relationships processed, the attribute will come from the 1st element in the relationship vector.


stringForDataAttributeReplacement

protected java.lang.String stringForDataAttributeReplacement(DataMappedObject dmo,
                                                             java.lang.String replacementString)
Retrieves a data attribute for the data mapped object and replacement string, then converts that attribute into a useful string.


replaceAttributeParameters

protected java.lang.String replaceAttributeParameters(java.lang.String parameterString,
                                                      DataMappedObject dmo)
Replaces parameters in braces {} with the corresponding values from the data mapped object.


getCascadedRelationships

protected java.util.Vector getCascadedRelationships(DataMappedObject dmo)
Helper method to retrieve cascade write relationships for an object.


findBySearchCriteria

public abstract java.util.Vector findBySearchCriteria(DataMappedObject dmo,
                                                      java.lang.String criteriaKey)
This method is an abstract method for the purpose of using the current data location mapper to read any number of objects according to the DataMappedObject's type and search criteria.


write

public abstract void write(DataMappedObject dmo,
                           Relationship relationship)
This method is an abstract method for the purpose of writing a data mapped object, potentially in the context of a relationship, to a data store.

The relationship can be null if not in context of a relationship.


rollbackWrites

public void rollbackWrites()
This method is an abstract method for the purpose of rolling back any writes to the data sink. It does not do any necessary cleanup afterward, as the cleanup would make you think the write functioned properly when it actually did not go through. So your objects will be in a state inconsistent with the database.


commitWrites

public abstract void commitWrites()
This method is an abstract method for the purpose of commiting all writes to the data sink and doing any necessary cleanup afterward.