Package org.simpleframework.xml.core
Class AnnotationFactory
- java.lang.Object
-
- org.simpleframework.xml.core.AnnotationFactory
-
class AnnotationFactory extends java.lang.Object
TheAnnotationFactory
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:
AnnotationHandler
-
-
Constructor Summary
Constructors Constructor Description AnnotationFactory(Detail detail, Support support)
Constructor for theAnnotationFactory
object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private java.lang.ClassLoader
getClassLoader()
This is used to create a suitable class loader to be used to load the synthetic annotation classes.private java.lang.annotation.Annotation
getInstance(java.lang.Class type)
This is used to create an annotation for the provided type.private java.lang.annotation.Annotation
getInstance(java.lang.ClassLoader loader, java.lang.Class label)
This will create a synthetic annotation using the provided interface.private java.lang.annotation.Annotation
getInstance(java.lang.ClassLoader loader, java.lang.Class label, boolean attribute)
This will create a synthetic annotation using the provided interface.java.lang.annotation.Annotation
getInstance(java.lang.Class type, java.lang.Class[] dependents)
This is used to create an annotation for the provided type.private boolean
isAttribute()
This is used to determine whether the format for the current serialization is verbose or not.private boolean
isPrimitive(java.lang.Class type)
This is used to determine if the type specified is primitive.private boolean
isPrimitiveKey(java.lang.Class[] dependents)
This is used to determine if a map contains a primitive key.
-
-
-
Field Detail
-
format
private final Format format
This represents the format used for the serialization process.
-
required
private final boolean required
This is used to determine if the defaults are required.
-
-
Constructor Detail
-
AnnotationFactory
public AnnotationFactory(Detail detail, Support support)
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 Detail
-
getInstance
public java.lang.annotation.Annotation getInstance(java.lang.Class type, java.lang.Class[] dependents) throws java.lang.Exception
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:
java.lang.Exception
-
getInstance
private java.lang.annotation.Annotation getInstance(java.lang.Class type) throws java.lang.Exception
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:
java.lang.Exception
-
getInstance
private java.lang.annotation.Annotation getInstance(java.lang.ClassLoader loader, java.lang.Class label) throws java.lang.Exception
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:
java.lang.Exception
-
getInstance
private java.lang.annotation.Annotation getInstance(java.lang.ClassLoader loader, java.lang.Class label, boolean attribute) throws java.lang.Exception
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:
java.lang.Exception
-
getClassLoader
private java.lang.ClassLoader getClassLoader() throws java.lang.Exception
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:
java.lang.Exception
-
isPrimitiveKey
private boolean isPrimitiveKey(java.lang.Class[] dependents)
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
private boolean isPrimitive(java.lang.Class type)
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
-
-