dochelper
Class FileRecordSet

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

public class FileRecordSet
extends java.lang.Object
implements RecordSet

The class FileRecordSet implements the RecordSet interface to create a set of Records to be processed. This class is used to drive the DocHelper process by invoking the render function on each Record within the RecordSet passing in the DocPattern defined for this records set.

See Also:
Record, DocumentSection

Field Summary
protected static java.lang.String GLOB
          Param key: glob
private  java.lang.String name
          Reference Name for this instance.
protected  java.util.HashMap<java.lang.String,java.lang.Object> params
          Paramters for this configurable.
protected static java.lang.String PATH
          Param keys, path, glob and recursive
private  java.util.ArrayList<DocPattern> patterns
           
protected static java.lang.String RECUR
          Param key: recursive
protected  java.util.ArrayList<Record> rsfiles
          The files that are represented by this Path and Filter.
 
Constructor Summary
FileRecordSet()
           
 
Method Summary
protected  void _listDirectory(java.util.ArrayList stack, java.util.ArrayList files, java.lang.String directory, java.lang.String glob, boolean recursive)
           
 void addPattern(DocPattern pattern)
          Add a single pattern to be applied to this record set.
 void checkParams()
          Checks that the parameters are correct for this File Record Set.
 void clearPatterns()
          Empty pattern list.
 ResultNode execute(ResultNode doc)
          Main method of FileRecordSet.
 java.lang.String getName()
          Name Accessors + Modifiers
 java.util.ArrayList<DocPattern> getPatterns()
          Pattern Accessors + Modifiers
 java.util.ArrayList<Record> getRsfiles()
          Record Files (rsfiles) Accessors + Modifiers
 void init()
          Initialize the Record Set.
 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.
 void setPatterns(java.util.ArrayList<DocPattern> patterns)
           
 void setRsfiles(java.util.ArrayList<Record> rsfiles)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PATH

protected static final java.lang.String PATH
Param keys, path, glob and recursive

See Also:
Constant Field Values

RECUR

protected static final java.lang.String RECUR
Param key: recursive

See Also:
Constant Field Values

GLOB

protected static final java.lang.String GLOB
Param key: glob

See Also:
Constant Field Values

name

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


params

protected java.util.HashMap<java.lang.String,java.lang.Object> params
Paramters for this configurable.


rsfiles

protected java.util.ArrayList<Record> rsfiles
The files that are represented by this Path and Filter. This is equivalent to the records in this record set


patterns

private java.util.ArrayList<DocPattern> patterns
Constructor Detail

FileRecordSet

public FileRecordSet()
Method Detail

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. Eg. These paramters set the path, glob, recursive. It is the responsibility of this method to check correct types for params used. For the FileRecordSet only string parameters are 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 this File Record Set. Validate required parameters and semantic and format rules. This method will not return a boolean indicating success, rather, it will fire an Exception indicating error type

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

init

public void init()
          throws InitializationException,
                 ResourceUnavailableException
Initialize the Record Set. This method builds the list of files represented by the parameter set. Given the path, glob and recursive params a list is built recursivley.

Specified by:
init in interface Configurable
Throws:
ResourceUnavailableException
InitializationException

execute

public ResultNode execute(ResultNode doc)
                   throws ResourceUnavailableException
Main method of FileRecordSet. This appends to the document tree the output generated by interpreting this FileRecordSet. The results are obtained by matching each pattern (n number of times ) within the value returned by Record getValue(). This call returns the contects of the file itself.

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

_listDirectory

protected void _listDirectory(java.util.ArrayList stack,
                              java.util.ArrayList files,
                              java.lang.String directory,
                              java.lang.String glob,
                              boolean recursive)
                       throws java.io.IOException
Parameters:
stack -
files -
directory -
glob -
recursive -
Throws:
java.io.IOException

getRsfiles

public java.util.ArrayList<Record> getRsfiles()
Record Files (rsfiles) Accessors + Modifiers

Returns:

setRsfiles

public void setRsfiles(java.util.ArrayList<Record> rsfiles)
Parameters:
rsfiles -

getPatterns

public java.util.ArrayList<DocPattern> getPatterns()
Pattern Accessors + Modifiers

Returns:

setPatterns

public void setPatterns(java.util.ArrayList<DocPattern> patterns)
Parameters:
patterns -

getName

public java.lang.String getName()
Name Accessors + Modifiers

Returns:

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

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object