public class AnnotationBuilder extends Object implements TagValueListener
Builds an Annotation tree from TagValue events using an AnnotationType to work out which fields are of what type.
Constructor and Description |
---|
AnnotationBuilder(AnnotationType type)
Make a new AnnotationBuilder that will build Annotation instances of a
given type.
|
Modifier and Type | Method and Description |
---|---|
void |
endRecord()
The current record has ended.
|
void |
endTag()
End the current tag.
|
Annotation |
getLast()
Get the last complete annotation built.
|
void |
startRecord()
A new record is about to start.
|
void |
startTag(Object tag)
Start a new tag.
|
void |
value(TagValueContext ctxt,
Object value)
A value has been seen.
|
public AnnotationBuilder(AnnotationType type)
Make a new AnnotationBuilder that will build Annotation instances of a given type.
The type is used to provide appropriate accessors for properties. As tag -value events stream through this TagValueListener, they will be matched against the properties of the annotation type. As sub-trees of events are pushed, child annotation bundles will be pushed into the appropriate properties. If any of the tag-value events are of a type that are not accepted by the annotation type, a ClassCastException will be thrown.
type
- the AnnotationType stating what will be built and howClassCastException
- if any of the tag-value events are of
inappropriate typepublic Annotation getLast()
Get the last complete annotation built.
The value of this is undefined before the first annotation has been built and during the parsing of an event stream.
public void startRecord()
TagValueListener
startRecord
in interface TagValueListener
public void endRecord()
TagValueListener
endRecord
in interface TagValueListener
public void startTag(Object tag)
TagValueListener
startTag
in interface TagValueListener
tag
- the Object representing the new tagpublic void value(TagValueContext ctxt, Object value)
TagValueListener
value
in interface TagValueListener
ctxt
- a TagValueContext that could be used to push a sub-documentvalue
- the value Object observedpublic void endTag()
TagValueListener
endTag
in interface TagValueListener
Copyright © 2020 BioJava. All rights reserved.