Package org.simpleframework.xml.core
Class Signature
java.lang.Object
org.simpleframework.xml.core.Signature
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
FieldsModifier and TypeFieldDescriptionprivate 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
ConstructorsConstructorDescriptionSignature
(Constructor factory) Constructor for theSignature
object.Signature
(Constructor factory, Class type) Constructor for theSignature
object.Constructor for theSignature
object. -
Method Summary
Modifier and TypeMethodDescriptionvoid
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.copy()
This is used to build aSignature
with the given context so that keys are styled.create()
This is used to instantiate the object using the default no argument constructor.This is used to instantiate the object using a constructor that takes deserialized objects as arguments.get
(int ordinal) This is used to acquire aParameter
using the position of that parameter within the constructor.This is used to acquire the parameter based on its name.getAll()
This is used to acquire an list ofParameter
objects in declaration order.getType()
This is the type associated with theSignature
.boolean
isEmpty()
This is used to determine if there are any parameters in the signature.iterator()
This is used to iterate overParameter
objects.This is used to remove a parameter from the signature.void
This will add a new mapping to the signature based on the provided key.int
size()
This represents the number of parameters this signature has.toString()
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
This is the map of parameters that this signature uses. -
factory
This is the type that the parameters are created for. -
type
This is the type that the signature was created for.
-
-
Constructor Details
-
Signature
Constructor for theSignature
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
Constructor for theSignature
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
Constructor for theSignature
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 representstype
- 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
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
This is used to iterate overParameter
objects. Parameters are iterated in the order that they are added to the map. This is primarily used for convenience iteration. -
remove
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
This is used to acquire aParameter
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
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
This is used to acquire an list ofParameter
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
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
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 toparameter
- this is the parameter to be mapped
-
create
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
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
This is used to build aSignature
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
This is the type associated with theSignature
. All instances returned from this creator will be of this type.- Returns:
- this returns the type associated with the signature
-
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.
-