com.simonstl.fragment
Class FragmentRule

java.lang.Object
  |
  +--com.simonstl.fragment.FragmentRule

public class FragmentRule
extends java.lang.Object

Each FragmentRule describes a regular expression and the results of the fragmentation it produces, described as a series of child elements.

Currently, the series is a simple list. Eventually it may provide for collections (appropriate for the HTML style element and some SVG) and for attribute results.

Rules currently don't keep track of which elements they apply to. That information is stored in the FragmentRules element. This may change in future versions.

Version 0.08 adds better print() and toString() support.

Version 0.07 now returns DocComponent objects more effectively, uses the cleanDuplicate() method to ensure that object reuse doesn't mar results.

Version 0.06 moved regular expression processing to the RegExProc (now RegexProcFactory) class, a first step toward permitting the use of pluggable regular expressions processors.

Version 0.05 adds support for DocComponents rather than Elements, genericizing processing a bit.

Version 0.04 moved regular expression processing from the FragmentFilter into the processRule() method.

Version 0.03 adds support for the split attribute.

Version 0.02 adds information about repetition and skipping the first result. By default, rules don't repeat and are assumed to skip the first result. If the repeat attribute of the fragmentRule element is set to "true", the rule will cycle through the elements in the produces element rather than just proceeding once. Similarly, setting the skipFirst attribute to "false will preserve the first match on the regular expression.

Version:
0.08 4 July 2001
Author:
Simon St.Laurent

Field Summary
protected  ComponentList appliesTo
           
protected  int isSplit
           
protected  int matchLevel
           
protected  java.lang.String pattern
           
protected  RegExInt regExProc
           
protected  boolean repeats
           
protected  ComponentList results
           
protected  boolean skipFirst
           
 
Constructor Summary
FragmentRule(java.lang.String regEx)
           
 
Method Summary
 void addAppliesTo(DocComponent ruleComponent)
           
 void addResult(DocComponent resultComponent)
           
 void complete()
           
 int getIsSplit()
           
 boolean getRepeat()
           
 DocComponent getResults(int which)
           
 int getSize()
           
 boolean getSkipFirst()
           
 void print()
           
 java.util.ArrayList processResult(java.lang.String elementContent)
           
 void setIsSplit(int split)
           
 void setMatchLevel(int level)
           
 void setRepeat(boolean doesRepeat)
           
 void setSkipFirst(boolean skip)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

pattern

protected java.lang.String pattern

appliesTo

protected ComponentList appliesTo

results

protected ComponentList results

repeats

protected boolean repeats

skipFirst

protected boolean skipFirst

isSplit

protected int isSplit

matchLevel

protected int matchLevel

regExProc

protected RegExInt regExProc
Constructor Detail

FragmentRule

public FragmentRule(java.lang.String regEx)
Method Detail

complete

public void complete()

setRepeat

public void setRepeat(boolean doesRepeat)

getRepeat

public boolean getRepeat()

setSkipFirst

public void setSkipFirst(boolean skip)

getSkipFirst

public boolean getSkipFirst()

setIsSplit

public void setIsSplit(int split)

getIsSplit

public int getIsSplit()

getSize

public int getSize()

setMatchLevel

public void setMatchLevel(int level)

getResults

public DocComponent getResults(int which)

processResult

public java.util.ArrayList processResult(java.lang.String elementContent)

print

public void print()

toString

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

addResult

public void addResult(DocComponent resultComponent)

addAppliesTo

public void addAppliesTo(DocComponent ruleComponent)