dochelper
Class DocPattern

java.lang.Object
  extended by dochelper.DocPattern
All Implemented Interfaces:
TransformDefinition

public class DocPattern
extends java.lang.Object
implements TransformDefinition

The class DocPattern implements one of the principal components of DocHelper, the Pattern. It is intended to hold a Regular Expression pattern in String form and RenderDefinition. The regular expression indicates what to match in Record, and the RenderDefinition indicates how to render the matches for each Record. This class implements RenderDefinition to become a rendering mechanism itself. TODO. This class implements DocumentSection in order to implement output encapsulation.

See Also:
DocumentSection, RenderDefinition

Field Summary
private  java.lang.String name
           
(package private)  TransformDefinition node
          The Node Definition that tells this pattern how to render matches
(package private)  java.util.HashMap<java.lang.String,java.lang.String> params
           
(package private)  java.util.regex.Pattern regExp
          String: Regular Expressions Pattern to Match
 
Constructor Summary
DocPattern(java.lang.String pattern)
          Creates a new instance.
DocPattern(java.lang.String pattern, TransformDefinition transform)
          Creates a new instance.
 
Method Summary
 ResultNode execute(java.lang.String value)
          Executes this pattern for the given value.
 java.lang.String getName()
          Name Accessor + Modifier
 java.lang.String getText()
          Implementation of the RenderDefinition interface.
 java.lang.String render(java.util.regex.MatchResult mr)
          Render the matchresult passed in behaving as if this pattern was a RenderDefiniton.
 void setName(java.lang.String name)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

node

TransformDefinition node
The Node Definition that tells this pattern how to render matches


regExp

java.util.regex.Pattern regExp
String: Regular Expressions Pattern to Match


name

private java.lang.String name

params

java.util.HashMap<java.lang.String,java.lang.String> params
Constructor Detail

DocPattern

public DocPattern(java.lang.String pattern)
           throws java.util.regex.PatternSyntaxException
Creates a new instance. This Object represents a regular expression pattern and how it should be rendered in the resulting document. The rendering is done through the relationship to its NodeDefinition. A pattern implements the NodeDefinition interface itself in order to be itself a valid way to render a node.

Parameters:
pattern - String that defines the regular expression to search for
Throws:
java.util.regex.PatternSyntaxException

DocPattern

public DocPattern(java.lang.String pattern,
                  TransformDefinition transform)
           throws java.util.regex.PatternSyntaxException
Creates a new instance. This Object represents a regular expression pattern and how it should be rendered in the resulting document. The rendering is done through the relationship to its RenderDefinition. A pattern implements the RenderDefinition interface itself in order to be itself a valid way to render a pattern.

Parameters:
pattern - String that defines the regular expression to search for
transform -
Throws:
java.util.regex.PatternSyntaxException
Method Detail

execute

public ResultNode execute(java.lang.String value)
Executes this pattern for the given value. This method will match the regular expression for this DocPattern and pass the result to the RenderDefinition associated with it , to render the result.

Parameters:
value - String that hold the value that will be search for matches of the pattern.
Returns:
The resulting document section after searching for matches and rendering them acording to the RenderDefinition and encapsulating the result between START and END if defined.

render

public java.lang.String render(java.util.regex.MatchResult mr)
Render the matchresult passed in behaving as if this pattern was a RenderDefiniton. Implementation of the RenderDefinition. TODO: X or Implement, Document.

Specified by:
render in interface TransformDefinition
Parameters:
mr -
Returns:
String containing the render result.

getText

public java.lang.String getText()
Implementation of the RenderDefinition interface. Implementing the RenderDefinition interface allows a DocPattern to have a sub pattern perform the rendering functions. The allow nesting to occur. TODO: X or Implement, Document.

Specified by:
getText in interface TransformDefinition
Returns:
String containing template to be used to render matches.

getName

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

Returns:

setName

public void setName(java.lang.String name)
Parameters:
name -