Structured Text Toolkit

com.saelist.stx.operators
Class AbstractOperator

java.lang.Object
  extended bycom.saelist.stx.operators.AbstractOperator
All Implemented Interfaces:
Operator
Direct Known Subclasses:
ReplaceOperator, SelectOperator, SplitOperator, YankOperator

public abstract class AbstractOperator
extends java.lang.Object
implements Operator

See Operator for general description of the Operator concept in stx.

 Lifecycle: Create { init(config) init() { visit(pairs) { operator(pair) } } }
 Usage: Create { init(config) { visit(pairs) } }
 


Field Summary
protected  Pair config
           
protected  Logger logger
           
 
Constructor Summary
AbstractOperator()
           
 
Method Summary
protected  void init()
          Descendants should overide this if they vant to cache elements of config in member variables or do some other inital setup.
 void init(Pair config)
          Validates the configuration against the schema and stores it in config, then calls init() to allow descendants to further initialize themselves.
abstract  void operate(Pair pair)
          Descendant classes will put the code for the actual operation here.
 void visit(java.util.Iterator pairs)
          Visits the given pairs, typically the result of Pair.select(xpath).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected Logger logger

config

protected Pair config
Constructor Detail

AbstractOperator

public AbstractOperator()
Method Detail

init

public void init(Pair config)
Validates the configuration against the schema and stores it in config, then calls init() to allow descendants to further initialize themselves.

Specified by:
init in interface Operator
Throws:
IllegalArgumentExeption - if config doesn't validate against #getSchema. The Validator will log warnings aswell as print linenumbers of the mismatches in both files to the standard error.

init

protected void init()
Descendants should overide this if they vant to cache elements of config in member variables or do some other inital setup.


visit

public final void visit(java.util.Iterator pairs)
Visits the given pairs, typically the result of Pair.select(xpath).

Specified by:
visit in interface Operator
Throws:
java.lang.ClassCastException - if pairs contains a non-Pair.

operate

public abstract void operate(Pair pair)
Descendant classes will put the code for the actual operation here.

Specified by:
operate in interface Operator
Throws:
java.lang.IllegalStateException - if this hasn't been initialized.

Structured Text Toolkit