Package org.simpleframework.xml.core
Class SignatureBuilder
java.lang.Object
org.simpleframework.xml.core.SignatureBuilder
The
SignatureBuilder
is used to build all permutations
of signatures a constructor contains. Permutations are calculated
by determining the number of annotations a parameter contains and
ensuring a signature is created with one of each. This is useful
when a constructor is annotated with a union annotation.- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class
TheParameterList
object is used to represent a column of parameters within a table.private static class
TheParameterTable
is used to build a table of parameters to represent a constructor. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Constructor
this is the constructor that this signature builder is for.private final SignatureBuilder.ParameterTable
This contains each parameter and annotation pair found. -
Constructor Summary
ConstructorsConstructorDescriptionSignatureBuilder
(Constructor factory) Constructor for theSignatureBuilder
object. -
Method Summary
Modifier and TypeMethodDescriptionbuild()
This method will build all the signatures for the constructor.build
(SignatureBuilder.ParameterTable matrix) This method will build all the signatures for the constructor.private void
build
(SignatureBuilder.ParameterTable matrix, int index) This is used to build all permutations of parameters that exist within the constructor.private void
build
(SignatureBuilder.ParameterTable matrix, SignatureBuilder.ParameterList signature, int index) This is used to build all permutations of parameters that exist within the constructor.create()
This is used to create a list of signatures that represent the permutations of parameter and annotation pairs that exist for a single constructor.This is used to create a list of signatures that represent the permutations of parameter and annotation pairs that exist.void
This will add a a parameter at the specified column in the table.boolean
isValid()
This validates the builder by checking that the width of the table is the same as the count of parameters in the constructor.private void
populate
(SignatureBuilder.ParameterTable matrix, SignatureBuilder.ParameterList signature, int index) This is the final leg of building a permutation where a signature is given to permutate on the last column.
-
Field Details
-
table
This contains each parameter and annotation pair found. -
factory
this is the constructor that this signature builder is for.
-
-
Constructor Details
-
SignatureBuilder
Constructor for theSignatureBuilder
object. This requires the constructor that the signatures will be built for. If the constructor contains no annotations then no signatures will be built, unless this is the default no-arg constructor.- Parameters:
factory
- this is the constructor to build for
-
-
Method Details
-
isValid
public boolean isValid()This validates the builder by checking that the width of the table is the same as the count of parameters in the constructor. If there table width and parameter count does not match then this means the constructor is not fully annotated.- Returns:
- true if the constructor has been properly annotated
-
insert
This will add a a parameter at the specified column in the table. The parameter is typically added to the table at an index mirroring the index it appears within the constructor.- Parameters:
value
- this is the parameter to be added in the tableindex
- this is the index to added the parameter to
-
build
This method will build all the signatures for the constructor. If a union annotation was used this may result in several signatures being created. Also if this builder represents the default constructor then this returns a single value.- Returns:
- this returns the list of signatures to be built
- Throws:
Exception
-
build
This method will build all the signatures for the constructor. If a union annotation was used this may result in several signatures being created. Also if this builder represents the default constructor then this returns a single value.- Parameters:
matrix
- this is the matrix of parameters to collect- Returns:
- this returns the list of signatures to be built
- Throws:
Exception
-
create
This is used to create a list of signatures that represent the permutations of parameter and annotation pairs that exist for a single constructor. The list may be empty.- Returns:
- this returns the list of signatures that exist
- Throws:
Exception
-
create
This is used to create a list of signatures that represent the permutations of parameter and annotation pairs that exist. All permutations are taken from the provided matrix. When building the list of signature the parameter paths are validated.- Parameters:
matrix
- this contains the permutations of parameters- Returns:
- this returns the list of signatures for a constructor
- Throws:
Exception
-
build
This is used to build all permutations of parameters that exist within the constructor. By building a matrix of the permutations all possible signatures can be created allowing for a better way to perform dependency injection for the objects.- Parameters:
matrix
- this is the matrix to hold the permutationsindex
- this is the particular index to evaluate
-
build
private void build(SignatureBuilder.ParameterTable matrix, SignatureBuilder.ParameterList signature, int index) This is used to build all permutations of parameters that exist within the constructor. By building a matrix of the permutations all possible signatures can be created allowing for a better way to perform dependency injection for the objects.- Parameters:
matrix
- this is the matrix to hold the permutationssignature
- the row to perform a permutation withindex
- this is the particular index to evaluate
-
populate
private void populate(SignatureBuilder.ParameterTable matrix, SignatureBuilder.ParameterList signature, int index) This is the final leg of building a permutation where a signature is given to permutate on the last column. Once finished the matrix will have a new row of parameters added which represents a new set of permutations to create signatures from.- Parameters:
matrix
- this is the matrix to hold the permutationssignature
- the row to perform a permutation withindex
- this is the particular index to evaluate
-