dochelper
Class AbstractTableRecordSet

java.lang.Object
  extended by dochelper.AbstractTableRecordSet
All Implemented Interfaces:
Configurable, RecordSet
Direct Known Subclasses:
JdbcTableRecordSet

public abstract class AbstractTableRecordSet
extends java.lang.Object
implements RecordSet

The AbstractTableRecordSet is the base class for defining Database table record sets. It implements common methodology but lets subclasses define connection creation and record retrieval. The AbstractTableRecordSet only requires that Abstra


Field Summary
private  java.lang.String name
          Reference Name for this instance.
protected  java.util.HashMap<java.lang.String,java.lang.Object> params
          The parameters that describe this File Records Set.
private  java.util.ArrayList<DocPattern> patterns
          The patterns that should be matched to the records for this record set.
 
Constructor Summary
AbstractTableRecordSet()
           
 
Method Summary
 void addPattern(DocPattern pattern)
          Add a single pattern to be applied to this record set.
 void checkParams()
          Checks that the parameters are correct for the TableRecordSet defined by the implementing subclass.
protected abstract  void checkParamsImpl()
          Subclass should implement this method
 void clearPatterns()
          Empty pattern list.
 ResultNode execute(ResultNode doc)
          Main method of RecordSet.
 java.lang.String getName()
          Name Accessor + Modifier
protected abstract  java.util.List<Record> getRecords()
          Method used to retrieve a list of Records for this RecordSet.
 void init()
          Initialize the Table Record Set.
protected abstract  void initImpl()
          Subclass should implement this method.
 void setName(java.lang.String name)
          Set the name of this Record Set.
 void setParam(java.lang.String paramName, java.lang.Object value)
          Add an initialization parameter to the Record Set.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

params

protected java.util.HashMap<java.lang.String,java.lang.Object> params
The parameters that describe this File Records Set.


patterns

private java.util.ArrayList<DocPattern> patterns
The patterns that should be matched to the records for this record set.


name

private java.lang.String name
Reference Name for this instance. Used to fetch info when rendering or processing.

Constructor Detail

AbstractTableRecordSet

public AbstractTableRecordSet()
Method Detail

initImpl

protected abstract void initImpl()
                          throws java.sql.SQLException,
                                 ResourceUnavailableException
Subclass should implement this method.

Throws:
java.sql.SQLException
ResourceUnavailableException

checkParamsImpl

protected abstract void checkParamsImpl()
                                 throws MissingArgumentException,
                                        InvalidValueException,
                                        ResourceUnavailableException
Subclass should implement this method

Throws:
MissingArgumentException
InvalidValueException
ResourceUnavailableException

getRecords

protected abstract java.util.List<Record> getRecords()
                                              throws ResourceUnavailableException,
                                                     java.sql.SQLException
Method used to retrieve a list of Records for this RecordSet. Depending on implementation, this may mean the fetching a list that has been retrieved during initialization, or it may mean actually performing the database retrieveal operation.

Returns:
List of Record objects.
Throws:
ResourceUnavailableException
java.sql.SQLException

setParam

public void setParam(java.lang.String paramName,
                     java.lang.Object value)
              throws IllegalParamterTypeException
Add an initialization parameter to the Record Set. These parameters are used during the call to init to Establish - Initialize the RecordSet. It is the responsibility of this method to check correct types for params used.

Specified by:
setParam in interface Configurable
Parameters:
paramName - String Name of the paramter to be stored
value - String value of the named param
Throws:
IllegalParamterTypeException

checkParams

public void checkParams()
                 throws InvalidValueException,
                        MissingArgumentException,
                        ResourceUnavailableException
Checks that the parameters are correct for the TableRecordSet defined by the implementing subclass. This method will not return a boolean indicating success, rather, it will throw an exception if it fails.

Specified by:
checkParams in interface Configurable
Throws:
InvalidValueException
MissingArgumentException
ResourceUnavailableException

init

public void init()
          throws InitializationException,
                 ResourceUnavailableException
Initialize the Table Record Set. This implies creating the connection and possibly preemptivley retrieving the records depending on implementation.

Specified by:
init in interface Configurable
Throws:
InitializationException
ResourceUnavailableException

execute

public ResultNode execute(ResultNode doc)
                   throws ResourceUnavailableException
Main method of RecordSet. This method should append to the document the output generated by interpreting this RecordSet. The abstract RecordSet class iterates through records obtained through a call to the abstract method getRecords(). The implementing subclass will decide how and when these are fetched.

Specified by:
execute in interface RecordSet
Parameters:
doc - The document onto which the results of running this record set should be appended to.
Returns:
The document with the results of the matches and rendering appended to it.
Throws:
ResourceUnavailableException
java.lang.Exception
See Also:
RecordSet

getName

public java.lang.String getName()
Name Accessor + Modifier

Returns:
name

setName

public void setName(java.lang.String name)
Description copied from interface: RecordSet
Set the name of this Record Set. The name of the Record Set is used in conjunction with items that use the name to fetch the appropriate part of the result tree. This includes renderers.

Specified by:
setName in interface RecordSet

addPattern

public void addPattern(DocPattern pattern)
Add a single pattern to be applied to this record set.

Specified by:
addPattern in interface RecordSet
Parameters:
pattern - DocPettern to add to this Record Set.

clearPatterns

public void clearPatterns()
Empty pattern list.

Specified by:
clearPatterns in interface RecordSet