Class Signature

java.lang.Object
org.simpleframework.xml.core.Signature
All Implemented Interfaces:
Iterable<Parameter>

class Signature extends Object implements Iterable<Parameter>
The Signature object represents a constructor of parameters iterable in declaration order. This is used so that parameters can be acquired by name for validation. It is also used to create an array of Parameter objects that can be used to acquire the correct deserialized values to use in order to instantiate the object.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final Constructor
    This is the type that the parameters are created for.
    private final ParameterMap
    This is the map of parameters that this signature uses.
    private final Class
    This is the type that the signature was created for.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructor for the Signature object.
    Signature(Constructor factory, Class type)
    Constructor for the Signature object.
    Signature(Signature signature)
    Constructor for the Signature object.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(Parameter parameter)
    This will add the provided parameter to the signature.
    boolean
    This returns true if the signature contains a parameter that is mapped to the specified key.
    This is used to build a Signature with the given context so that keys are styled.
    This is used to instantiate the object using the default no argument constructor.
    create(Object[] list)
    This is used to instantiate the object using a constructor that takes deserialized objects as arguments.
    get(int ordinal)
    This is used to acquire a Parameter using the position of that parameter within the constructor.
    get(Object key)
    This is used to acquire the parameter based on its name.
    This is used to acquire an list of Parameter objects in declaration order.
    This is the type associated with the Signature.
    boolean
    This is used to determine if there are any parameters in the signature.
    This is used to iterate over Parameter objects.
    This is used to remove a parameter from the signature.
    void
    set(Object key, Parameter parameter)
    This will add a new mapping to the signature based on the provided key.
    int
    This represents the number of parameters this signature has.
    This is used to acquire a descriptive name for the instantiator.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface java.lang.Iterable

    forEach, spliterator
  • Field Details

    • parameters

      private final ParameterMap parameters
      This is the map of parameters that this signature uses.
    • factory

      private final Constructor factory
      This is the type that the parameters are created for.
    • type

      private final Class type
      This is the type that the signature was created for.
  • Constructor Details

    • Signature

      public Signature(Signature signature)
      Constructor for the Signature object. This is used to create a hash map that can be used to acquire parameters by name. It also provides the parameters in declaration order within a for each loop.
      Parameters:
      signature - this is the signature to be copied
    • Signature

      public Signature(Constructor factory)
      Constructor for the Signature object. This is used to create a hash map that can be used to acquire parameters by name. It also provides the parameters in declaration order within a for each loop.
      Parameters:
      factory - this is the constructor this represents
    • Signature

      public Signature(Constructor factory, Class type)
      Constructor for the Signature object. This is used to create a hash map that can be used to acquire parameters by name. It also provides the parameters in declaration order within a for each loop.
      Parameters:
      factory - this is the constructor this represents
      type - this is the type the map is created for
  • Method Details

    • size

      public int size()
      This represents the number of parameters this signature has. A signature with no parameters is the default no argument constructor, anything else is a candidate for injection.
      Returns:
      this returns the number of annotated parameters
    • isEmpty

      public boolean isEmpty()
      This is used to determine if there are any parameters in the signature. If the signature contains no parameters then this will return true, if it does then this returns false.
      Returns:
      this returns true of the signature has no parameters
    • contains

      public boolean contains(Object key)
      This returns true if the signature contains a parameter that is mapped to the specified key. If no parameter exists with this key then this will return false.
      Parameters:
      key - this is the key the parameter is mapped to
      Returns:
      this returns true if there is a parameter mapping
    • iterator

      public Iterator<Parameter> iterator()
      This is used to iterate over Parameter objects. Parameters are iterated in the order that they are added to the map. This is primarily used for convenience iteration.
      Specified by:
      iterator in interface Iterable<Parameter>
      Returns:
      this returns an iterator for the parameters
    • remove

      public Parameter remove(Object key)
      This is used to remove a parameter from the signature. This returns any parameter removed if it exists, if not then this returns null. This is used when performing matching.
      Parameters:
      key - this is the key of the parameter to remove
      Returns:
      this returns the parameter that was removed
    • get

      public Parameter get(int ordinal)
      This is used to acquire a Parameter using the position of that parameter within the constructor. This allows a builder to determine which parameters to use.
      Parameters:
      ordinal - this is the position of the parameter
      Returns:
      this returns the parameter for the position
    • get

      public Parameter get(Object key)
      This is used to acquire the parameter based on its name. This is used for convenience when the parameter name needs to be matched up with an annotated field or method.
      Parameters:
      key - this is the key of the parameter to acquire
      Returns:
      this is the parameter mapped to the given name
    • getAll

      public List<Parameter> getAll()
      This is used to acquire an list of Parameter objects in declaration order. This list will help with the resolution of the correct constructor for deserialization of the XML. It also provides a faster method of iteration.
      Returns:
      this returns the parameters in declaration order
    • add

      public void add(Parameter parameter)
      This will add the provided parameter to the signature. The parameter is added to the signature mapped to the key of the parameter. If the key is null it is not added.
      Parameters:
      parameter - this is the parameter to be added
    • set

      public void set(Object key, Parameter parameter)
      This will add a new mapping to the signature based on the provided key. Adding a mapping to a parameter using something other than the key for the parameter allows for resolution of the parameter based on a path or a name if desired.
      Parameters:
      key - this is the key to map the parameter to
      parameter - this is the parameter to be mapped
    • create

      public Object create() throws Exception
      This is used to instantiate the object using the default no argument constructor. If for some reason the object can not be instantiated then this will throw an exception with the reason.
      Returns:
      this returns the object that has been instantiated
      Throws:
      Exception
    • create

      public Object create(Object[] list) throws Exception
      This is used to instantiate the object using a constructor that takes deserialized objects as arguments. The objects that have been deserialized are provided in declaration order so they can be passed to the constructor to instantiate the object.
      Parameters:
      list - this is the list of objects used for instantiation
      Returns:
      this returns the object that has been instantiated
      Throws:
      Exception
    • copy

      public Signature copy() throws Exception
      This is used to build a Signature with the given context so that keys are styled. This allows serialization to match styled element names or attributes to ensure that they can be used to acquire the parameters.
      Returns:
      this returns a signature with styled keys
      Throws:
      Exception
    • getType

      public Class getType()
      This is the type associated with the Signature. All instances returned from this creator will be of this type.
      Returns:
      this returns the type associated with the signature
    • toString

      public String toString()
      This is used to acquire a descriptive name for the instantiator. Providing a name is useful in debugging and when exceptions are thrown as it describes the constructor the instantiator represents.
      Overrides:
      toString in class Object
      Returns:
      this returns the name of the constructor to be used