Class ClassScanner


  • class ClassScanner
    extends java.lang.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:
    Scanner
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private Function commit
      This function acts as a pointer to the types commit process.
      private Function complete
      This function acts as a pointer to the types complete process.
      private NamespaceDecorator decorator
      This is the namespace decorator associated with this scanner.
      private Order order
      This is the order annotation that has been scanned from the type.
      private Function persist
      This function acts as a pointer to the types persist process.
      private Function replace
      This function is used as a pointer to the replacement method.
      private Function resolve
      This function is used as a pointer to the resolution method.
      private Root root
      This is the root annotation that has been scanned from the type.
      private ConstructorScanner scanner
      This is the scanner that is used to acquire the constructors.
      private Support support
      This object contains various support functions for the class.
      private Function validate
      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

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private void commit​(java.lang.reflect.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​(java.lang.reflect.Method method)
      This method is used to check the provided method to determine if it contains the Complete annotation.
      private void definition​(Detail detail)
      This method is used to extract the Root annotation and the Order annotation from the detail provided.
      Function getCommit()
      This method is used to retrieve the schema class commit method during the deserialization process.
      Function getComplete()
      This method is used to retrieve the schema class completion method.
      Decorator getDecorator()
      This is used to acquire the Decorator for this.
      private Function getFunction​(java.lang.reflect.Method method)
      This is used to acquire a Function object for the method provided.
      Order getOrder()
      This returns the order annotation used to determine the order of serialization of attributes and elements.
      ParameterMap getParameters()
      This returns a map of all parameters that exist.
      Function getPersist()
      This method is used to retrieve the schema class persistence method.
      Function getReplace()
      This method is used to retrieve the schema class replacement method.
      Function getResolve()
      This method is used to retrieve the schema class replacement method.
      Root getRoot()
      This returns the root of the class processed by this scanner.
      Signature getSignature()
      This is used to acquire the default signature for the class.
      java.util.List<Signature> getSignatures()
      This returns the signatures for the type.
      Function getValidate()
      This method is used to retrieve the schema class validation method during the deserialization process.
      private boolean isContextual​(java.lang.reflect.Method method)
      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 method​(MethodDetail detail)
      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​(java.lang.reflect.Method method)
      This method is used to check the provided method to determine if it contains the Persist annotation.
      private void replace​(java.lang.reflect.Method method)
      This method is used to check the provided method to determine if it contains the Replace annotation.
      private void resolve​(java.lang.reflect.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​(java.lang.reflect.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 Detail

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

      • ClassScanner

        public ClassScanner​(Detail detail,
                            Support support)
                     throws java.lang.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:
        java.lang.Exception
    • Method Detail

      • 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 java.util.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 java.lang.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:
        java.lang.Exception
      • definition

        private void definition​(Detail detail)
                         throws java.lang.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:
        java.lang.Exception
      • namespace

        private void namespace​(Detail detail)
                        throws java.lang.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:
        java.lang.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 java.lang.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:
        java.lang.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​(java.lang.reflect.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​(java.lang.reflect.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​(java.lang.reflect.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​(java.lang.reflect.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​(java.lang.reflect.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​(java.lang.reflect.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​(java.lang.reflect.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​(java.lang.reflect.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