org.biojava.bio.program.tagvalue
Class TagDelegator

java.lang.Object
  extended by org.biojava.bio.program.tagvalue.SimpleTagValueWrapper
      extended by org.biojava.bio.program.tagvalue.TagDelegator
All Implemented Interfaces:
TagValueListener, TagValueWrapper

public class TagDelegator
extends SimpleTagValueWrapper

Pushes a new parser and listener, or delegate to a listener depending on the tag.

setParserListener() is used to associate a tag with a TagValueParser and TagValueListener. When this tag is encountered, the pair will be pushed onto the parser processing stack and will gain control of the stream until that tag has ended. setListener() is used to associate a listener with a tag that will be used to handle those values without pushing a sub-context. The delegator is constructed with a default TagValueListener that will be informed of all events for which there are no explicit delegate pairs registered.

Since:
1.2
Author:
Matthew Pocock

Constructor Summary
TagDelegator()
           
TagDelegator(TagValueListener delegate)
           
 
Method Summary
 void endTag()
          End the current tag.
 TagValueParser getDelegateParser()
           
 TagValueListener getListener(java.lang.Object tag)
           
 TagValueParser getParser(java.lang.Object tag)
           
 java.util.Set getTags()
           
 void setDelegateParser(TagValueParser delegateParser)
           
 void setListener(java.lang.Object tag, TagValueListener listener)
           
 void setParserListener(java.lang.Object tag, TagValueParser parser, TagValueListener listener)
           
 void startTag(java.lang.Object tag)
          Start a new tag.
 void value(TagValueContext tvc, java.lang.Object value)
          A value has been seen.
 
Methods inherited from class org.biojava.bio.program.tagvalue.SimpleTagValueWrapper
endRecord, getDelegate, setDelegate, startRecord
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TagDelegator

public TagDelegator()

TagDelegator

public TagDelegator(TagValueListener delegate)
Method Detail

setDelegateParser

public void setDelegateParser(TagValueParser delegateParser)

getDelegateParser

public TagValueParser getDelegateParser()

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 SimpleTagValueWrapper
Parameters:
tag - the Object representing the new tag
Throws:
ParserException - if the tag could not be started

endTag

public void endTag()
            throws ParserException
Description copied from interface: TagValueListener
End the current tag.

Specified by:
endTag in interface TagValueListener
Overrides:
endTag in class SimpleTagValueWrapper
Throws:
ParserException - if the tag could not be ended

value

public void value(TagValueContext tvc,
                  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 SimpleTagValueWrapper
Parameters:
tvc - a TagValueContext that could be used to push a sub-document
value - the value Object observed
Throws:
ParserException - if the value could not be processed

setParserListener

public void setParserListener(java.lang.Object tag,
                              TagValueParser parser,
                              TagValueListener listener)

setListener

public void setListener(java.lang.Object tag,
                        TagValueListener listener)

getParser

public TagValueParser getParser(java.lang.Object tag)

getListener

public TagValueListener getListener(java.lang.Object tag)

getTags

public java.util.Set getTags()