dochelper
Class URLRecordSet

java.lang.Object
  extended by dochelper.URLRecordSet
All Implemented Interfaces:
Configurable, RecordSet

public class URLRecordSet
extends java.lang.Object
implements RecordSet

The class URLRecordSet implements the RecordSet interface to represent a set of WebPage 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
static java.lang.String DEPTH
          Param key: depth
protected  java.util.regex.Pattern links
          Pattern tp identify links
protected  java.lang.String name
          Reference Name for this instance.
protected  java.util.HashMap<java.lang.String,java.lang.Object> params
          Paramters for this configurable.
private  java.util.ArrayList<DocPattern> patterns
           
protected  int recordSetDepth
          The depth for this record set
static java.lang.String ROOT_URL
          Param key: URLRoot
protected  java.util.ArrayList<Record> rsfiles
          The files that are represented by this Path and Filter.
 
Constructor Summary
URLRecordSet()
           
 
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 this File Record Set.
 void clearPatterns()
          Empty pattern list.
 ResultNode execute(ResultNode doc)
          Main method of URLRecordSet.
private  void fetchRecords(int depth, java.lang.String rootURL)
          Fetch all the URLs from root node to a depth of 'depth'.
 java.lang.String getName()
          Name 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.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ROOT_URL

public static final java.lang.String ROOT_URL
Param key: URLRoot

See Also:
Constant Field Values

DEPTH

public static final java.lang.String DEPTH
Param key: depth

See Also:
Constant Field Values

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


name

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


recordSetDepth

protected int recordSetDepth
The depth for this record set


links

protected java.util.regex.Pattern links
Pattern tp identify links


patterns

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

URLRecordSet

public URLRecordSet()
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 rootURL and the depth of the search. It is the responsibility of this method to check correct types for params used. For the URLRecordSet 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.

Specified by:
init in interface Configurable
Throws:
ResourceUnavailableException
InitializationException

fetchRecords

private void fetchRecords(int depth,
                          java.lang.String rootURL)
Fetch all the URLs from root node to a depth of 'depth'. Make the record list while doing this.

Parameters:
depth - currentDepth
rootURL - String representing starting point

execute

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

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

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