Class SignatureBuilder

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

class SignatureBuilder extends Object
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:
  • Field Details

    • table

      private final SignatureBuilder.ParameterTable table
      This contains each parameter and annotation pair found.
    • factory

      private final Constructor factory
      this is the constructor that this signature builder is for.
  • Constructor Details

    • SignatureBuilder

      public SignatureBuilder(Constructor factory)
      Constructor for the SignatureBuilder 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

      public void insert(Parameter value, int index)
      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 table
      index - this is the index to added the parameter to
    • build

      public List<Signature> build() throws Exception
      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

      private List<Signature> build(SignatureBuilder.ParameterTable matrix) throws Exception
      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

      private List<Signature> create() throws Exception
      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

      private List<Signature> create(SignatureBuilder.ParameterTable matrix) throws Exception
      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

      private void build(SignatureBuilder.ParameterTable matrix, 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 permutations
      index - 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 permutations
      signature - the row to perform a permutation with
      index - 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 permutations
      signature - the row to perform a permutation with
      index - this is the particular index to evaluate