Class SignatureScanner


  • class SignatureScanner
    extends java.lang.Object
    The SignatureScanner object is used to scan each of the parameters within a constructor for annotations. When each of the annotations has been extracted it is used to build a parameter which is then used to build a grid of parameter annotation pairs. A single constructor can result in multiple signatures and if a union annotation is used like ElementUnion then this can result is several annotations being declared.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private SignatureBuilder builder
      This is used to build permutations of parameters extracted.
      private java.lang.reflect.Constructor constructor
      This is the constructor that is scanned for the parameters.
      private ParameterFactory factory
      This factory is used to creating annotated parameter objects.
      private ParameterMap registry
      This is used to collect all the parameters that are extracted.
      private java.lang.Class type
      This is the declaring class for the constructor scanned.
    • Constructor Summary

      Constructors 
      Constructor Description
      SignatureScanner​(java.lang.reflect.Constructor constructor, ParameterMap registry, Support support)
      Constructor for the SignatureScanner object.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private java.util.List<Parameter> create​(java.lang.annotation.Annotation label, int ordinal)
      This is used to create a Parameter object which is used to represent a parameter to a constructor.
      private java.lang.annotation.Annotation[] extract​(java.lang.annotation.Annotation label)
      This is used to extract the individual annotations associated with the union annotation provided.
      java.util.List<Signature> getSignatures()
      This is used to acquire the signature permutations for the constructor.
      boolean isValid()
      This is used to determine if this scanner is valid.
      private java.util.List<Parameter> process​(java.lang.annotation.Annotation label, int ordinal)
      This is used to create Parameter objects which are used to represent the parameters in a constructor.
      private void register​(Parameter parameter)
      This is used to register the provided parameter using the given path.
      private void scan​(java.lang.Class type)
      This is used to scan the specified constructor for annotations that it contains.
      private void scan​(java.lang.Class type, int index)
      This is used to scan the specified constructor for annotations that it contains.
      private java.util.List<Parameter> union​(java.lang.annotation.Annotation label, int ordinal)
      This is used to create a Parameter object which is used to represent a parameter to a constructor.
      private void validate​(Parameter parameter, java.lang.Object key)
      This is used to validate the parameter against all the other parameters for the class.
      • Methods inherited from class java.lang.Object

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

      • builder

        private final SignatureBuilder builder
        This is used to build permutations of parameters extracted.
      • factory

        private final ParameterFactory factory
        This factory is used to creating annotated parameter objects.
      • registry

        private final ParameterMap registry
        This is used to collect all the parameters that are extracted.
      • constructor

        private final java.lang.reflect.Constructor constructor
        This is the constructor that is scanned for the parameters.
      • type

        private final java.lang.Class type
        This is the declaring class for the constructor scanned.
    • Constructor Detail

      • SignatureScanner

        public SignatureScanner​(java.lang.reflect.Constructor constructor,
                                ParameterMap registry,
                                Support support)
                         throws java.lang.Exception
        Constructor for the SignatureScanner object. This creates a scanner for a single constructor. As well as scanning for parameters within the constructor this will collect each of the scanned parameters in a registry so it can be validated.
        Parameters:
        constructor - this is the constructor that will be scanned
        registry - this is the registry used to collect parameters
        format - this is the format used to style parameters
        Throws:
        java.lang.Exception
    • Method Detail

      • isValid

        public boolean isValid()
        This is used to determine if this scanner is valid. The scanner may not be valid for various reasons. Currently this method determines if a scanner is valid by checking the constructor to see if the object can be instantiated.
        Returns:
        this returns true if this scanner is valid
      • getSignatures

        public java.util.List<Signature> getSignatures()
                                                throws java.lang.Exception
        This is used to acquire the signature permutations for the constructor. Typically this will return a single signature. If the constructor parameters are annotated with unions then this will return several signatures representing each permutation.
        Returns:
        this signatures that have been extracted from this
        Throws:
        java.lang.Exception
      • scan

        private void scan​(java.lang.Class type)
                   throws java.lang.Exception
        This is used to scan the specified constructor for annotations that it contains. Each parameter annotation is evaluated and if it is an XML annotation it is considered to be a valid parameter and is added to the signature builder.
        Parameters:
        type - this is the constructor that is to be scanned
        Throws:
        java.lang.Exception
      • scan

        private void scan​(java.lang.Class type,
                          int index)
                   throws java.lang.Exception
        This is used to scan the specified constructor for annotations that it contains. Each parameter annotation is evaluated and if it is an XML annotation it is considered to be a valid parameter and is added to the signature builder.
        Parameters:
        type - this is the parameter type to be evaluated
        index - this is the index of the parameter to scan
        Throws:
        java.lang.Exception
      • process

        private java.util.List<Parameter> process​(java.lang.annotation.Annotation label,
                                                  int ordinal)
                                           throws java.lang.Exception
        This is used to create Parameter objects which are used to represent the parameters in a constructor. Each parameter contains an annotation an the index it appears in.
        Parameters:
        label - this is the annotation used for the parameter
        ordinal - this is the position the parameter appears at
        Returns:
        this returns the parameters for the constructor
        Throws:
        java.lang.Exception
      • union

        private java.util.List<Parameter> union​(java.lang.annotation.Annotation label,
                                                int ordinal)
                                         throws java.lang.Exception
        This is used to create a Parameter object which is used to represent a parameter to a constructor. Each parameter contains an annotation an the index it appears in.
        Parameters:
        label - this is the annotation used for the parameter
        ordinal - this is the position the parameter appears at
        Returns:
        this returns the parameter for the constructor
        Throws:
        java.lang.Exception
      • create

        private java.util.List<Parameter> create​(java.lang.annotation.Annotation label,
                                                 int ordinal)
                                          throws java.lang.Exception
        This is used to create a Parameter object which is used to represent a parameter to a constructor. Each parameter contains an annotation an the index it appears in.
        Parameters:
        label - this is the annotation used for the parameter
        ordinal - this is the position the parameter appears at
        Returns:
        this returns the parameter for the constructor
        Throws:
        java.lang.Exception
      • extract

        private java.lang.annotation.Annotation[] extract​(java.lang.annotation.Annotation label)
                                                   throws java.lang.Exception
        This is used to extract the individual annotations associated with the union annotation provided. If the annotation does not represent a union then this will return null.
        Parameters:
        label - this is the annotation to extract from
        Returns:
        this returns an array of annotations from the union
        Throws:
        java.lang.Exception
      • register

        private void register​(Parameter parameter)
                       throws java.lang.Exception
        This is used to register the provided parameter using the given path. If this parameter has already existed then this will validate the parameter against the existing one. All registered parameters are registered in to a single table.
        Parameters:
        parameter - this is the parameter to be registered
        Throws:
        java.lang.Exception
      • validate

        private void validate​(Parameter parameter,
                              java.lang.Object key)
                       throws java.lang.Exception
        This is used to validate the parameter against all the other parameters for the class. Validating each of the parameters ensures that the annotations for the parameters remain consistent throughout the class.
        Parameters:
        parameter - this is the parameter to be validated
        key - this is the key of the parameter to validate
        Throws:
        java.lang.Exception