T - the annotation typepublic class AnnotationBuilder<T extends java.lang.annotation.Annotation> extends java.lang.Object implements IAnnotationBuilder<T>
| Modifier and Type | Field and Description |
|---|---|
private java.lang.Class<T> |
cls
Stores the concrete type of the annotation.
|
private HashMap<java.lang.String,java.lang.Object> |
data
Stores the concrete values of the annotation (method name - value).
|
private AttributeMetaData[] |
dataDefinition
Stores the data attributes in order to implement generic XML reading.
|
private T |
instance
Stores the instance of the annotation (created only once on demand).
|
| Modifier | Constructor and Description |
|---|---|
private |
AnnotationBuilder(AnnotationBuilder<T> builder)
Creates an annotation builder from a given annotation builder by copying
the relevant data, resetting
instance and initializing
data with default values (see setDefaults(). |
|
AnnotationBuilder(java.lang.Class<T> cls)
Creates an instance for a concrete annotation by reading the metadata
directly from the annotation.
|
|
AnnotationBuilder(java.lang.Class<T> cls,
AttributeMetaData[] dataDefinition)
Creates an instance of this builder by providing the meta information
for each attribute to be considered.
|
| Modifier and Type | Method and Description |
|---|---|
T |
create()
Creates the annotation.
|
boolean |
defaultsOnly()
Returns whether the values of this annotation just contains defaults.
|
void |
endElement(java.lang.String qName,
boolean nested)
Is called at the end of an XML element processing step.
|
private java.lang.Object |
getEnumValue(java.lang.Class<?> type,
java.lang.String attribute,
java.lang.Object deflt)
Returns the matching enum constant.
|
java.lang.Class<T> |
getInstanceClass()
Returns the concrete type of the annotation.
|
AnnotationBuilder<T> |
prepareForUse()
Prepares a template instance for use.
|
protected void |
setBooleanData(java.lang.String key,
HashMap<java.lang.String,java.lang.String> attributes,
java.lang.Boolean deflt)
Sets a string data from an attribute.
|
void |
setData(java.lang.String key,
java.lang.Object value)
Sets a data value directly.
|
private void |
setDefaults()
Initializes the data of the annotation to be created with the default
values.
|
protected <E extends java.lang.Enum<E>> |
setEnumData(java.lang.String key,
HashMap<java.lang.String,java.lang.String> attributes,
java.lang.Class<E> values,
E deflt)
Sets an enum data from an attribute.
|
protected void |
setStringData(java.lang.String key,
HashMap<java.lang.String,java.lang.String> attributes,
java.lang.String deflt)
Sets a string data from an attribute.
|
void |
startElement(java.lang.String qName,
boolean nested,
HashMap<java.lang.String,java.lang.String> attributes)
Is called at the beginning of an XML element processing step.
|
java.lang.String |
toString()
Returns a textual representation of this object.
|
private T extends java.lang.annotation.Annotation instance
private HashMap<java.lang.String,java.lang.Object> data
private java.lang.Class<T extends java.lang.annotation.Annotation> cls
private AttributeMetaData[] dataDefinition
public AnnotationBuilder(java.lang.Class<T> cls, AttributeMetaData[] dataDefinition)
cls - the type of the annotationdataDefinition - the meta datapublic AnnotationBuilder(java.lang.Class<T> cls)
cls - the annotation class
{private AnnotationBuilder(AnnotationBuilder<T> builder)
instance and initializing
data with default values (see setDefaults().builder - the builder to copy frompublic java.lang.Class<T> getInstanceClass()
getInstanceClass in interface IAnnotationBuilder<T extends java.lang.annotation.Annotation>public final T create()
create in interface IAnnotationBuilder<T extends java.lang.annotation.Annotation>public void endElement(java.lang.String qName,
boolean nested)
throws QdParserException
qName - the qualified name of the elementnested - if the element is nested as an unknown element in a
known elementQdParserException - in case of any processing errorpublic void startElement(java.lang.String qName,
boolean nested,
HashMap<java.lang.String,java.lang.String> attributes)
throws QdParserException
qName - the qualified name of the elementnested - if the element is nested as an unknown element in a
known elementattributes - the actual XML attributesQdParserException - in case of any processing errorpublic boolean defaultsOnly()
true if only defaults are set, false
elseprivate java.lang.Object getEnumValue(java.lang.Class<?> type,
java.lang.String attribute,
java.lang.Object deflt)
type - the type of the enumerationattribute - the attribute valuedeflt - the default value in case that the attribute is not
defined (may be null)public void setData(java.lang.String key,
java.lang.Object value)
key - the name of the element / attribute.value - the assigned value (must match the type in T)protected void setStringData(java.lang.String key,
HashMap<java.lang.String,java.lang.String> attributes,
java.lang.String deflt)
throws QdParserException
key - the name of the attribute / elementattributes - the actual attributesdeflt - the default value in case that the attribute is not
defined (may be null)QdParserException - in case of any processing errorprotected <E extends java.lang.Enum<E>> void setEnumData(java.lang.String key,
HashMap<java.lang.String,java.lang.String> attributes,
java.lang.Class<E> values,
E deflt)
throws QdParserException
E - the type of the enumkey - the name of the attribute / elementattributes - the actual attributesvalues - the class of the enumdeflt - the default value in case that the attribute is not
defined (may be null)QdParserException - in case of any processing errorprotected void setBooleanData(java.lang.String key,
HashMap<java.lang.String,java.lang.String> attributes,
java.lang.Boolean deflt)
throws QdParserException
key - the name of the attribute / elementattributes - the actual attributesdeflt - the default value in case that the attribute is not
defined (may be null)QdParserException - in case of any processing errorpublic AnnotationBuilder<T> prepareForUse()
private void setDefaults()
public java.lang.String toString()
toString in class java.lang.Object