Package org.simpleframework.xml.core
Class AnnotationFactory
java.lang.Object
org.simpleframework.xml.core.AnnotationFactory
The
AnnotationFactory
is used to create annotations
using a given class. This will classify the provided type as
either a list, map, array, or a default object. Depending on the
type provided a suitable annotation will be created. Annotations
produced by this will have default attribute values.- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionAnnotationFactory
(Detail detail, Support support) Constructor for theAnnotationFactory
object. -
Method Summary
Modifier and TypeMethodDescriptionprivate ClassLoader
This is used to create a suitable class loader to be used to load the synthetic annotation classes.private Annotation
getInstance
(Class type) This is used to create an annotation for the provided type.private Annotation
getInstance
(ClassLoader loader, Class label) This will create a synthetic annotation using the provided interface.private Annotation
getInstance
(ClassLoader loader, Class label, boolean attribute) This will create a synthetic annotation using the provided interface.getInstance
(Class type, Class[] dependents) This is used to create an annotation for the provided type.private boolean
This is used to determine whether the format for the current serialization is verbose or not.private boolean
isPrimitive
(Class type) This is used to determine if the type specified is primitive.private boolean
isPrimitiveKey
(Class[] dependents) This is used to determine if a map contains a primitive key.
-
Field Details
-
format
This represents the format used for the serialization process. -
required
private final boolean requiredThis is used to determine if the defaults are required.
-
-
Constructor Details
-
AnnotationFactory
Constructor for theAnnotationFactory
object. This is used to create a factory for annotations used to provide the default annotations for generated labels.- Parameters:
detail
- this contains details for the annotated classsupport
- this contains various support functions
-
-
Method Details
-
getInstance
This is used to create an annotation for the provided type. Annotations created are used to match the type provided. So aList
will have anElementList
annotation for example. Matching the annotation to the type ensures the best serialization for that type.- Parameters:
type
- the type to create the annotation fordependents
- these are the dependents for the type- Returns:
- this returns the synthetic annotation to be used
- Throws:
Exception
-
getInstance
This is used to create an annotation for the provided type. Annotations created are used to match the type provided. So an array of objects will have anElementArray
annotation for example. Matching the annotation to the type ensures the best serialization for that type.- Parameters:
type
- the type to create the annotation for- Returns:
- this returns the synthetic annotation to be used
- Throws:
Exception
-
getInstance
This will create a synthetic annotation using the provided interface. All attributes for the provided annotation will have their default values.- Parameters:
loader
- this is the class loader to load the annotationlabel
- this is the annotation interface to be used- Returns:
- this returns the synthetic annotation to be used
- Throws:
Exception
-
getInstance
This will create a synthetic annotation using the provided interface. All attributes for the provided annotation will have their default values.- Parameters:
loader
- this is the class loader to load the annotationlabel
- this is the annotation interface to be usedattribute
- determines if a map has an attribute key- Returns:
- this returns the synthetic annotation to be used
- Throws:
Exception
-
getClassLoader
This is used to create a suitable class loader to be used to load the synthetic annotation classes. The class loader provided will be the same as the class loader that was used to load this class.- Returns:
- this returns the class loader that is to be used
- Throws:
Exception
-
isPrimitiveKey
This is used to determine if a map contains a primitive key. A primitive key is a key for aMap
that is of a primitive type and thus can be used as an attribute. Here we accept all primitive types and also enumerations.- Parameters:
dependents
- these are the dependents of the map- Returns:
- this returns true if the key is a primitive type
-
isPrimitive
This is used to determine if the type specified is primitive. A primitive is any type that can be reliably transformed in to an XML attribute without breaking the XML.- Parameters:
type
- this is the type that is to be evaluated- Returns:
- true if the type provided is a primitive type
-
isAttribute
private boolean isAttribute()This is used to determine whether the format for the current serialization is verbose or not. The verbosity dictates the type of default annotations that are generated for an object.- Returns:
- this is used to determine the verbosity to use
-