Class ClassScanner

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

class ClassScanner extends Object
The ClassScanner performs the reflective inspection of a class and extracts all the class level annotations. This will also extract the methods that are annotated. This ensures that the callback methods can be invoked during the deserialization process. Also, this will read the namespace annotations that are used.
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private Function
    This function acts as a pointer to the types commit process.
    private Function
    This function acts as a pointer to the types complete process.
    This is the namespace decorator associated with this scanner.
    private Order
    This is the order annotation that has been scanned from the type.
    private Function
    This function acts as a pointer to the types persist process.
    private Function
    This function is used as a pointer to the replacement method.
    private Function
    This function is used as a pointer to the resolution method.
    private Root
    This is the root annotation that has been scanned from the type.
    This is the scanner that is used to acquire the constructors.
    private Support
    This object contains various support functions for the class.
    private Function
    This function acts as a pointer to the types validate process.
  • Constructor Summary

    Constructors
    Constructor
    Description
    ClassScanner(Detail detail, Support support)
    Constructor for the ClassScanner object.
  • Method Summary

    Modifier and Type
    Method
    Description
    private void
    commit(Method method)
    This method is used to check the provided method to determine if it contains the Commit annotation.
    private void
    commit(Detail detail)
    This is used to set the primary namespace for nodes that will be decorated by the namespace decorator.
    private void
    complete(Method method)
    This method is used to check the provided method to determine if it contains the Complete annotation.
    private void
    This method is used to extract the Root annotation and the Order annotation from the detail provided.
    This method is used to retrieve the schema class commit method during the deserialization process.
    This method is used to retrieve the schema class completion method.
    This is used to acquire the Decorator for this.
    private Function
    This is used to acquire a Function object for the method provided.
    This returns the order annotation used to determine the order of serialization of attributes and elements.
    This returns a map of all parameters that exist.
    This method is used to retrieve the schema class persistence method.
    This method is used to retrieve the schema class replacement method.
    This method is used to retrieve the schema class replacement method.
    This returns the root of the class processed by this scanner.
    This is used to acquire the default signature for the class.
    This returns the signatures for the type.
    This method is used to retrieve the schema class validation method during the deserialization process.
    private boolean
    This is used to determine whether the annotated method takes a contextual object.
    private void
    method(Detail detail)
    This is used to scan the specified class for methods so that the persister callback annotations can be collected.
    private void
    Scans the provided method for a persister callback method.
    private void
    namespace(Detail detail)
    This is used to acquire the namespace annotations that apply to the scanned class.
    private void
    persist(Method method)
    This method is used to check the provided method to determine if it contains the Persist annotation.
    private void
    replace(Method method)
    This method is used to check the provided method to determine if it contains the Replace annotation.
    private void
    resolve(Method method)
    This method is used to check the provided method to determine if it contains the Resolve annotation.
    private void
    scan(Detail detail)
    Scan the fields and methods such that the given class is scanned first then all super classes up to the root Object.
    private void
    validate(Method method)
    This method is used to check the provided method to determine if it contains the Validate annotation.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • decorator

      private NamespaceDecorator decorator
      This is the namespace decorator associated with this scanner.
    • scanner

      private ConstructorScanner scanner
      This is the scanner that is used to acquire the constructors.
    • commit

      private Function commit
      This function acts as a pointer to the types commit process.
    • validate

      private Function validate
      This function acts as a pointer to the types validate process.
    • persist

      private Function persist
      This function acts as a pointer to the types persist process.
    • complete

      private Function complete
      This function acts as a pointer to the types complete process.
    • replace

      private Function replace
      This function is used as a pointer to the replacement method.
    • resolve

      private Function resolve
      This function is used as a pointer to the resolution method.
    • support

      private Support support
      This object contains various support functions for the class.
    • root

      private Root root
      This is the root annotation that has been scanned from the type.
    • order

      private Order order
      This is the order annotation that has been scanned from the type.
  • Constructor Details

    • ClassScanner

      public ClassScanner(Detail detail, Support support) throws Exception
      Constructor for the ClassScanner object. This is used to scan the provided class for annotations that are used to build a schema for an XML file to follow.
      Parameters:
      detail - this contains the details for the class scanned
      support - this contains various support functions
      Throws:
      Exception
  • Method Details

    • getSignature

      public Signature getSignature()
      This is used to acquire the default signature for the class. The default signature is the signature for the no argument constructor for the type. If there is no default constructor for the type then this will return null.
      Returns:
      this returns the default signature if it exists
    • getSignatures

      public List<Signature> getSignatures()
      This returns the signatures for the type. All constructors are represented as a signature and returned. More signatures than constructors will be returned if a constructor is annotated with a union annotation.
      Returns:
      this returns the list of signatures for the type
    • getParameters

      public ParameterMap getParameters()
      This returns a map of all parameters that exist. This is used to validate all the parameters against the field and method annotations that exist within the class.
      Returns:
      this returns a map of all parameters within the type
    • getDecorator

      public Decorator getDecorator()
      This is used to acquire the Decorator for this. A decorator is an object that adds various details to the node without changing the overall structure of the node. For example comments and namespaces can be added to the node with a decorator as they do not affect the deserialization.
      Returns:
      this returns the decorator associated with this
    • getOrder

      public Order getOrder()
      This returns the order annotation used to determine the order of serialization of attributes and elements. The order is a class level annotation that can be used only once per class XML schema. If none exists then this will return null. of the class processed by this scanner.
      Returns:
      this returns the name of the object being scanned
    • getRoot

      public Root getRoot()
      This returns the root of the class processed by this scanner. The root determines the type of deserialization that is to be performed and also contains the name of the root element.
      Returns:
      this returns the name of the object being scanned
    • getCommit

      public Function getCommit()
      This method is used to retrieve the schema class commit method during the deserialization process. The commit method must be marked with the Commit annotation so that when the object is deserialized the persister has a chance to invoke the method so that the object can build further data structures.
      Returns:
      this returns the commit method for the schema class
    • getValidate

      public Function getValidate()
      This method is used to retrieve the schema class validation method during the deserialization process. The validation method must be marked with the Validate annotation so that when the object is deserialized the persister has a chance to invoke that method so that object can validate its field values.
      Returns:
      this returns the validate method for the schema class
    • getPersist

      public Function getPersist()
      This method is used to retrieve the schema class persistence method. This is invoked during the serialization process to get the object a chance to perform an necessary preparation before the serialization of the object proceeds. The persist method must be marked with the Persist annotation.
      Returns:
      this returns the persist method for the schema class
    • getComplete

      public Function getComplete()
      This method is used to retrieve the schema class completion method. This is invoked after the serialization process has completed and gives the object a chance to restore its state if the persist method required some alteration or locking. This is marked with the Complete annotation.
      Returns:
      returns the complete method for the schema class
    • getReplace

      public Function getReplace()
      This method is used to retrieve the schema class replacement method. The replacement method is used to substitute an object that has been deserialized with another object. This allows a seamless delegation mechanism to be implemented. This is marked with the Replace annotation.
      Returns:
      returns the replace method for the schema class
    • getResolve

      public Function getResolve()
      This method is used to retrieve the schema class replacement method. The replacement method is used to substitute an object that has been deserialized with another object. This allows a seamless delegation mechanism to be implemented. This is marked with the Replace annotation.
      Returns:
      returns the replace method for the schema class
    • scan

      private void scan(Detail detail) throws Exception
      Scan the fields and methods such that the given class is scanned first then all super classes up to the root Object. All fields and methods from the most specialized classes override fields and methods from higher up the inheritance hierarchy. This means that annotated details can be overridden.
      Parameters:
      detail - contains the methods and fields to be examined
      Throws:
      Exception
    • definition

      private void definition(Detail detail) throws Exception
      This method is used to extract the Root annotation and the Order annotation from the detail provided. These annotation are taken from the first definition encountered from the most specialized class up through the base classes.
      Parameters:
      detail - this detail object used to acquire the annotations
      Throws:
      Exception
    • namespace

      private void namespace(Detail detail) throws Exception
      This is used to acquire the namespace annotations that apply to the scanned class. Namespace annotations are added only if they have not already been extracted from a more specialized class. When scanned all the namespace definitions are used to qualify the XML that is produced from serializing the class.
      Parameters:
      type - this is the type to extract the annotations from
      Throws:
      Exception
    • commit

      private void commit(Detail detail)
      This is used to set the primary namespace for nodes that will be decorated by the namespace decorator. If no namespace is set using this method then this decorator will leave the namespace reference unchanged and only add namespaces for scoping.
      Parameters:
      detail - the detail object that contains the namespace
    • method

      private void method(Detail detail) throws Exception
      This is used to scan the specified class for methods so that the persister callback annotations can be collected. These annotations help object implementations to validate the data that is injected into the instance during deserialization.
      Parameters:
      detail - this is a detail from within the class hierarchy
      Throws:
      Exception
    • method

      private void method(MethodDetail detail)
      Scans the provided method for a persister callback method. If the method contains an method annotated as a callback that method is stored so that it can be invoked by the persister during the serialization and deserialization process.
      Parameters:
      detail - the method to scan for callback annotations
    • replace

      private void replace(Method method)
      This method is used to check the provided method to determine if it contains the Replace annotation. If the method contains the required annotation it is stored so that it can be invoked during the deserialization process.
      Parameters:
      method - this is the method checked for the annotation
    • resolve

      private void resolve(Method method)
      This method is used to check the provided method to determine if it contains the Resolve annotation. If the method contains the required annotation it is stored so that it can be invoked during the deserialization process.
      Parameters:
      method - this is the method checked for the annotation
    • commit

      private void commit(Method method)
      This method is used to check the provided method to determine if it contains the Commit annotation. If the method contains the required annotation it is stored so that it can be invoked during the deserialization process.
      Parameters:
      method - this is the method checked for the annotation
    • validate

      private void validate(Method method)
      This method is used to check the provided method to determine if it contains the Validate annotation. If the method contains the required annotation it is stored so that it can be invoked during the deserialization process.
      Parameters:
      method - this is the method checked for the annotation
    • persist

      private void persist(Method method)
      This method is used to check the provided method to determine if it contains the Persist annotation. If the method contains the required annotation it is stored so that it can be invoked during the deserialization process.
      Parameters:
      method - this is the method checked for the annotation
    • complete

      private void complete(Method method)
      This method is used to check the provided method to determine if it contains the Complete annotation. If the method contains the required annotation it is stored so that it can be invoked during the deserialization process.
      Parameters:
      method - this is the method checked for the annotation
    • getFunction

      private Function getFunction(Method method)
      This is used to acquire a Function object for the method provided. The function returned will allow the callback method to be invoked when given the context and target object.
      Parameters:
      method - this is the method that is to be invoked
      Returns:
      this returns the function that is to be invoked
    • isContextual

      private boolean isContextual(Method method)
      This is used to determine whether the annotated method takes a contextual object. If the method takes a Map then this returns true, otherwise it returns false.
      Parameters:
      method - this is the method to check the parameters of
      Returns:
      this returns true if the method takes a map object