Package org.simpleframework.xml.core
Class AnnotationHandler
java.lang.Object
org.simpleframework.xml.core.AnnotationHandler
- All Implemented Interfaces:
InvocationHandler
The
AnnotationHandler
object is used to handle all
invocation made on a synthetic annotation. This is required so
that annotations can be created without an implementation. The
java.lang.reflect.Proxy
object is used to wrap this
invocation handler with the annotation interface.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final boolean
This determines if a map should have a key attribute.private static final String
This is used to determine if a key should be an attribute.private static final String
This is the method used to acquire the associated type.private final Comparer
This is used to perform a comparison of the annotations.private static final String
This is used to perform a comparison of the annotations.private final boolean
This is used to determine if the annotation is required.private static final String
This is used to determine if annotations are optional.private static final String
This is used to acquire a string value for the annotation.private final Class
This is annotation type associated with this handler. -
Constructor Summary
ConstructorsConstructorDescriptionAnnotationHandler
(Class type) Constructor for theAnnotationHandler
object.AnnotationHandler
(Class type, boolean required) Constructor for theAnnotationHandler
object.AnnotationHandler
(Class type, boolean required, boolean attribute) Constructor for theAnnotationHandler
object. -
Method Summary
Modifier and TypeMethodDescriptionprivate void
attributes
(StringBuilder builder) This is used to build a string from the annotation.private boolean
This is used to determine if two annotations are equals based on the attributes of the annotation.This is used to handle all invocations on the wrapped annotation.private void
name
(StringBuilder builder) This is used to build a string from the annotation.toString()
This is used to build a string from the annotation.private Object
This is used to extract the default value used for the provided annotation attribute.
-
Field Details
-
CLASS
This is the method used to acquire the associated type.- See Also:
-
STRING
This is used to acquire a string value for the annotation.- See Also:
-
REQUIRED
This is used to determine if annotations are optional.- See Also:
-
ATTRIBUTE
This is used to determine if a key should be an attribute.- See Also:
-
EQUAL
This is used to perform a comparison of the annotations.- See Also:
-
comparer
This is used to perform a comparison of the annotations. -
type
This is annotation type associated with this handler. -
attribute
private final boolean attributeThis determines if a map should have a key attribute. -
required
private final boolean requiredThis is used to determine if the annotation is required.
-
-
Constructor Details
-
AnnotationHandler
Constructor for theAnnotationHandler
object. This is used to create a handler for invocations on a synthetic annotation. The annotation type wrapped must be provided. By default the requirement of the annotations is true.- Parameters:
type
- this is the annotation type that this is wrapping
-
AnnotationHandler
Constructor for theAnnotationHandler
object. This is used to create a handler for invocations on a synthetic annotation. The annotation type wrapped must be provided.- Parameters:
type
- this is the annotation type that this is wrappingrequired
- this is used to determine if its required
-
AnnotationHandler
Constructor for theAnnotationHandler
object. This is used to create a handler for invocations on a synthetic annotation. The annotation type wrapped must be provided.- Parameters:
type
- this is the annotation type that this is wrappingrequired
- this is used to determine if its requiredattribute
- determines if map keys are attributes
-
-
Method Details
-
invoke
This is used to handle all invocations on the wrapped annotation. Typically the response to an invocation will result in the default value of the annotation attribute being returned. If the method is anequals
ortoString
then this will be handled by an internal implementation.- Specified by:
invoke
in interfaceInvocationHandler
- Parameters:
proxy
- this is the proxy object the invocation was made onmethod
- this is the method that was invoked on the proxylist
- this is the list of parameters to be used- Returns:
- this is used to return the result of the invocation
- Throws:
Throwable
-
equals
This is used to determine if two annotations are equals based on the attributes of the annotation. The comparison done can ignore specific attributes, for instance the name attribute.- Parameters:
proxy
- this is the annotation the invocation was made onlist
- this is the parameters provided to the invocation- Returns:
- this returns true if the annotations are equals
- Throws:
Throwable
-
toString
This is used to build a string from the annotation. The string produces adheres to the typical string representation of a normal annotation. This ensures that an exceptions that are thrown with a string representation of the annotation are identical to those thrown with a normal annotation. -
name
This is used to build a string from the annotation. The string produces adheres to the typical string representation of a normal annotation. This ensures that an exceptions that are thrown with a string representation of the annotation are identical to those thrown with a normal annotation.- Parameters:
builder
- this is the builder used to compose the text
-
attributes
This is used to build a string from the annotation. The string produces adheres to the typical string representation of a normal annotation. This ensures that an exceptions that are thrown with a string representation of the annotation are identical to those thrown with a normal annotation.- Parameters:
builder
- this is the builder used to compose the text
-
value
This is used to extract the default value used for the provided annotation attribute. This will return the default value for all attributes except that it makes the requirement optional. Making the requirement optional provides better functionality.- Parameters:
method
- this is the annotation representing the attribute- Returns:
- this returns the default value for the attribute
-