Class AnnotationFactory

java.lang.Object
org.simpleframework.xml.core.AnnotationFactory

class AnnotationFactory extends Object
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 Details

    • 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 Details

    • AnnotationFactory

      public AnnotationFactory(Detail detail, Support support)
      Constructor for the AnnotationFactory 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 class
      support - this contains various support functions
  • Method Details

    • getInstance

      public Annotation getInstance(Class type, Class[] dependents) throws Exception
      This is used to create an annotation for the provided type. Annotations created are used to match the type provided. So a List will have an ElementList 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
      dependents - these are the dependents for the type
      Returns:
      this returns the synthetic annotation to be used
      Throws:
      Exception
    • getInstance

      private Annotation getInstance(Class type) throws 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 an ElementArray 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

      private Annotation getInstance(ClassLoader loader, Class label) throws 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 annotation
      label - this is the annotation interface to be used
      Returns:
      this returns the synthetic annotation to be used
      Throws:
      Exception
    • getInstance

      private Annotation getInstance(ClassLoader loader, Class label, boolean attribute) throws 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 annotation
      label - this is the annotation interface to be used
      attribute - determines if a map has an attribute key
      Returns:
      this returns the synthetic annotation to be used
      Throws:
      Exception
    • getClassLoader

      private ClassLoader getClassLoader() throws 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:
      Exception
    • isPrimitiveKey

      private boolean isPrimitiveKey(Class[] dependents)
      This is used to determine if a map contains a primitive key. A primitive key is a key for a Map 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(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