Package org.simpleframework.xml.core
Class SignatureScanner
java.lang.Object
org.simpleframework.xml.core.SignatureScanner
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
FieldsModifier and TypeFieldDescriptionprivate 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
ConstructorsConstructorDescriptionSignatureScanner
(Constructor constructor, ParameterMap registry, Support support) Constructor for theSignatureScanner
object. -
Method Summary
Modifier and TypeMethodDescriptioncreate
(Annotation label, int ordinal) This is used to create aParameter
object which is used to represent a parameter to a constructor.private Annotation[]
extract
(Annotation label) 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
isValid()
This is used to determine if this scanner is valid.process
(Annotation label, int ordinal) This is used to createParameter
objects which are used to represent the parameters in a constructor.private void
This is used to register the provided parameter using the given path.private void
This is used to scan the specified constructor for annotations that it contains.private void
This is used to scan the specified constructor for annotations that it contains.union
(Annotation label, int ordinal) This is used to create aParameter
object which is used to represent a parameter to a constructor.private void
This is used to validate the parameter against all the other parameters for the class.
-
Field Details
-
builder
This is used to build permutations of parameters extracted. -
factory
This factory is used to creating annotated parameter objects. -
registry
This is used to collect all the parameters that are extracted. -
constructor
This is the constructor that is scanned for the parameters. -
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 theSignatureScanner
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 scannedregistry
- this is the registry used to collect parametersformat
- 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
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
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
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 evaluatedindex
- this is the index of the parameter to scan- Throws:
Exception
-
process
This is used to createParameter
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 parameterordinal
- this is the position the parameter appears at- Returns:
- this returns the parameters for the constructor
- Throws:
Exception
-
union
This is used to create aParameter
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 parameterordinal
- this is the position the parameter appears at- Returns:
- this returns the parameter for the constructor
- Throws:
Exception
-
create
This is used to create aParameter
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 parameterordinal
- this is the position the parameter appears at- Returns:
- this returns the parameter for the constructor
- Throws:
Exception
-
extract
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
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
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 validatedkey
- this is the key of the parameter to validate- Throws:
Exception
-