org.biojava.bio.program.tagvalue
Class ValueChanger

java.lang.Object
  extended byorg.biojava.bio.program.tagvalue.TagValueWrapper
      extended byorg.biojava.bio.program.tagvalue.ValueChanger
All Implemented Interfaces:
TagValueListener

public class ValueChanger
extends TagValueWrapper

Intercept the values associated with some tags and change them systematically.

The two forms of changes that can be made are:

For a given tag, changers take precendence over splitters, and explicitly registered changers or splitters take precendence over the default handlers. If there is not a specific handler for a tag and there is no default set, then the value is passed on unchanged.

Since:
1.2
Author:
Matthew Pocock

Constructor Summary
ValueChanger(TagValueListener delegate)
           
ValueChanger(TagValueListener delegate, ChangeTable changeTable)
          Create a new changer that will pass the modified event stream to a delegate.
 
Method Summary
 ChangeTable getChangeTable()
           
 ChangeTable.Changer getDefaultChanger()
          Get the changer that will be applied to values of tags with no specific handler registered.
 ChangeTable.Splitter getDefaultSplitter()
          Get the splitter that will be applied to values of tags with no specific handler registered.
 void setChangeTable(ChangeTable changeTable)
           
 void setDefaultChanger(ChangeTable.Changer c)
          The changer that will be applied to the values of tags not registered explicitly to any changer or splitter instance.
 void setDefaultSplitter(ChangeTable.Splitter s)
          The splitter that will be applied to the values of tags not registered explicitly to any changer or splitter instance.
 void startTag(java.lang.Object tag)
          Start a new tag.
 void value(TagValueContext ctxt, java.lang.Object value)
          A value has been seen.
 
Methods inherited from class org.biojava.bio.program.tagvalue.TagValueWrapper
endRecord, endTag, getDelegate, setDelegate, startRecord
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ValueChanger

public ValueChanger(TagValueListener delegate)

ValueChanger

public ValueChanger(TagValueListener delegate,
                    ChangeTable changeTable)
Create a new changer that will pass the modified event stream to a delegate.

Parameters:
delegate - the TagValueListener that will receive the events
Method Detail

setDefaultChanger

public void setDefaultChanger(ChangeTable.Changer c)
The changer that will be applied to the values of tags not registered explicitly to any changer or splitter instance.

Parameters:
c - the default ChangeTable.Changer

getDefaultChanger

public ChangeTable.Changer getDefaultChanger()
Get the changer that will be applied to values of tags with no specific handler registered.

Returns:
the default ChangeTable.Changer, or null

setDefaultSplitter

public void setDefaultSplitter(ChangeTable.Splitter s)
The splitter that will be applied to the values of tags not registered explicitly to any changer or splitter instance.


getDefaultSplitter

public ChangeTable.Splitter getDefaultSplitter()
Get the splitter that will be applied to values of tags with no specific handler registered.

Returns:
the default ChangeTable.Splitter, or null

getChangeTable

public ChangeTable getChangeTable()

setChangeTable

public void setChangeTable(ChangeTable changeTable)

startTag

public void startTag(java.lang.Object tag)
              throws ParserException
Description copied from interface: TagValueListener
Start a new tag.

Specified by:
startTag in interface TagValueListener
Overrides:
startTag in class TagValueWrapper
Throws:
ParserException

value

public void value(TagValueContext ctxt,
                  java.lang.Object value)
           throws ParserException
Description copied from interface: TagValueListener
A value has been seen.

Specified by:
value in interface TagValueListener
Overrides:
value in class TagValueWrapper
Throws:
ParserException