Class AnnotationBuilder
- All Implemented Interfaces:
TagValueListener
Builds an Annotation tree from TagValue events using an AnnotationType to work out which fields are of what type.
- Since:
- 1.2
- Author:
- Matthew Pocock
-
Constructor Summary
ConstructorsConstructorDescriptionMake a new AnnotationBuilder that will build Annotation instances of a given type. -
Method Summary
Modifier and TypeMethodDescriptionvoidThe current record has ended.voidendTag()End the current tag.getLast()Get the last complete annotation built.voidA new record is about to start.voidStart a new tag.voidvalue(TagValueContext ctxt, Object value) A value has been seen.
-
Constructor Details
-
AnnotationBuilder
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.
- Parameters:
type- the AnnotationType stating what will be built and how- Throws:
ClassCastException- if any of the tag-value events are of inappropriate type
-
-
Method Details
-
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.
- Returns:
- the Annotation that was last built
-
startRecord
Description copied from interface:TagValueListenerA new record is about to start.- Specified by:
startRecordin interfaceTagValueListener
-
endRecord
Description copied from interface:TagValueListenerThe current record has ended.- Specified by:
endRecordin interfaceTagValueListener
-
startTag
Description copied from interface:TagValueListenerStart a new tag.- Specified by:
startTagin interfaceTagValueListener- Parameters:
tag- the Object representing the new tag
-
value
Description copied from interface:TagValueListenerA value has been seen.- Specified by:
valuein interfaceTagValueListener- Parameters:
ctxt- a TagValueContext that could be used to push a sub-documentvalue- the value Object observed
-
endTag
Description copied from interface:TagValueListenerEnd the current tag.- Specified by:
endTagin interfaceTagValueListener
-