Package org.biojava.bio.program.tagvalue
Class TagDelegator
- java.lang.Object
-
- org.biojava.bio.program.tagvalue.SimpleTagValueWrapper
-
- 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
Constructors Constructor Description TagDelegator()TagDelegator(TagValueListener delegate)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidendTag()End the current tag.TagValueParsergetDelegateParser()TagValueListenergetListener(Object tag)TagValueParsergetParser(Object tag)SetgetTags()voidsetDelegateParser(TagValueParser delegateParser)voidsetListener(Object tag, TagValueListener listener)voidsetParserListener(Object tag, TagValueParser parser, TagValueListener listener)voidstartTag(Object tag)Start a new tag.voidvalue(TagValueContext tvc, Object value)A value has been seen.-
Methods inherited from class org.biojava.bio.program.tagvalue.SimpleTagValueWrapper
endRecord, getDelegate, setDelegate, startRecord
-
-
-
-
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(Object tag) throws ParserException
Description copied from interface:TagValueListenerStart a new tag.- Specified by:
startTagin interfaceTagValueListener- Overrides:
startTagin classSimpleTagValueWrapper- 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:TagValueListenerEnd the current tag.- Specified by:
endTagin interfaceTagValueListener- Overrides:
endTagin classSimpleTagValueWrapper- Throws:
ParserException- if the tag could not be ended
-
value
public void value(TagValueContext tvc, Object value) throws ParserException
Description copied from interface:TagValueListenerA value has been seen.- Specified by:
valuein interfaceTagValueListener- Overrides:
valuein classSimpleTagValueWrapper- Parameters:
tvc- a TagValueContext that could be used to push a sub-documentvalue- the value Object observed- Throws:
ParserException- if the value could not be processed
-
setParserListener
public void setParserListener(Object tag, TagValueParser parser, TagValueListener listener)
-
setListener
public void setListener(Object tag, TagValueListener listener)
-
getParser
public TagValueParser getParser(Object tag)
-
getListener
public TagValueListener getListener(Object tag)
-
-