Class SignatureScanner

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

class SignatureScanner extends 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 final SignatureBuilder
    This is used to build permutations of parameters extracted.
    private final Constructor
    This is the constructor that is scanned for the parameters.
    private final ParameterFactory
    This factory is used to creating annotated parameter objects.
    private final ParameterMap
    This is used to collect all the parameters that are extracted.
    private final Class
    This is the declaring class for the constructor scanned.
  • Constructor Summary

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

    Modifier and Type
    Method
    Description
    private List<Parameter>
    create(Annotation label, int ordinal)
    This is used to create a Parameter object which is used to represent a parameter to a constructor.
    private Annotation[]
    This is used to extract the individual annotations associated with the union annotation provided.
    This is used to acquire the signature permutations for the constructor.
    boolean
    This is used to determine if this scanner is valid.
    private List<Parameter>
    process(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(Class type)
    This is used to scan the specified constructor for annotations that it contains.
    private void
    scan(Class type, int index)
    This is used to scan the specified constructor for annotations that it contains.
    private List<Parameter>
    union(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, 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 Details

    • 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 Constructor constructor
      This is the constructor that is scanned for the parameters.
    • type

      private final Class type
      This is the declaring class for the constructor scanned.
  • Constructor Details

    • SignatureScanner

      public SignatureScanner(Constructor constructor, ParameterMap registry, Support support) throws 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:
      Exception
  • Method Details

    • 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 List<Signature> getSignatures() throws 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:
      Exception
    • scan

      private void scan(Class type) throws 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:
      Exception
    • scan

      private void scan(Class type, int index) throws 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:
      Exception
    • process

      private List<Parameter> process(Annotation label, int ordinal) throws 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:
      Exception
    • union

      private List<Parameter> union(Annotation label, int ordinal) throws 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:
      Exception
    • create

      private List<Parameter> create(Annotation label, int ordinal) throws 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:
      Exception
    • extract

      private Annotation[] extract(Annotation label) throws 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:
      Exception
    • register

      private void register(Parameter parameter) throws 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:
      Exception
    • validate

      private void validate(Parameter parameter, Object key) throws 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:
      Exception