Package org.simpleframework.xml.core
Class InstantiatorBuilder
java.lang.Object
org.simpleframework.xml.core.InstantiatorBuilder
The
InstantiatorBuilder
object is used to resolve labels
based on a provided parameter. Resolution of labels is done using
a set of mappings based on the names of the labels. Because many
labels might have the same name, this will only map a label if it
has unique name. As well as resolving by name, this can resolve
using the path of the parameter.- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate LabelMap
This is used to maintain the mappings for the attribute labels.private Comparer
This is used for validation to compare annotations used.private Detail
This is the detail the instantiator uses to create objects.private LabelMap
This is used to maintain the mappings for the element labels.private Instantiator
This is the single instance of the instantiator to be built.This is the list of creators representing an object constructor.private Scanner
This is used to acquire the signatures created for the type.private LabelMap
This is used to maintain the mappings for the text labels. -
Constructor Summary
ConstructorsConstructorDescriptionInstantiatorBuilder
(Scanner scanner, Detail detail) Constructor for theInstantiatorBuilder
object. -
Method Summary
Modifier and TypeMethodDescriptionbuild()
This is used to build theInstantiator
object that will be used to instantiate objects.private Instantiator
This is used to build theInstantiator
object that will be used to instantiate objects.private boolean
This is used to determine if a value exists within an array.private Instantiator
This is used to create theInstantiator
object that will be used to instantiate objects.private Parameter
This is used to create aParameter
based on the currently registered labels.private Creator
This is used to create a newCreator
object from the provided signature.private void
This used to populate replace the parameters extracted from the scanning process with ones matched with registered labels.private void
This used to populate replace the parameters extracted from the scanning process with ones matched with registered labels.void
Thisregister
method is used to register a label based on its name and path.private void
Thisregister
method is used to register a label based on its name and path.private Label
Thisresolve
method is used to find a label based on the name and path of the provided parameter.private Label
Thisresolve
method is used to find a label based on the name and path of the provided parameter.private void
This is used to ensure that for each parameter in the builder there is a matching method or field.private void
validateAnnotations
(Label label, Parameter parameter) This is used to validate the annotations associated with a field and a matching constructor parameter.private void
validateConstructor
(Label label, List<Creator> list) This is used to ensure that final methods and fields have a constructor parameter that allows the value to be injected in to.private void
This is used to ensure that final methods and fields have a constructor parameter that allows the value to be injected in to.private void
This is used when there are only default constructors.private void
validateConstructors
(LabelMap map, List<Creator> list) This is used to ensure that final methods and fields have a constructor parameter that allows the value to be injected in to.private void
validateNames
(Label label, Parameter parameter) This is used to validate the names associated with the parameters.private void
validateParameter
(Label label, Parameter parameter) This is used to validate theParameter
object that exist in the constructors.
-
Field Details
-
options
This is the list of creators representing an object constructor. -
factory
This is the single instance of the instantiator to be built. -
attributes
This is used to maintain the mappings for the attribute labels. -
elements
This is used to maintain the mappings for the element labels. -
texts
This is used to maintain the mappings for the text labels. -
comparer
This is used for validation to compare annotations used. -
scanner
This is used to acquire the signatures created for the type. -
detail
This is the detail the instantiator uses to create objects.
-
-
Constructor Details
-
InstantiatorBuilder
Constructor for theInstantiatorBuilder
object. This is used to create an object that can resolve a label using a parameter. Resolution is performed using either the name of the parameter or the path of the parameter.- Parameters:
scanner
- this is the scanner to acquire signatures fromdetail
- contains the details instantiators are built with
-
-
Method Details
-
build
This is used to build theInstantiator
object that will be used to instantiate objects. Validation is performed on all of the parameters as well as theCreator
objects associated with the type. This validation ensures that the labels and constructor parameters match based on annotations.- Returns:
- this returns the instance that has been built
- Throws:
Exception
-
build
This is used to build theInstantiator
object that will be used to instantiate objects. Validation is performed on all of the parameters as well as theCreator
objects associated with the type. This validation ensures that the labels and constructor parameters match based on annotations.- Parameters:
detail
- contains the details instantiators are built with- Throws:
Exception
-
create
This is used to create theInstantiator
object that will be used to instantiate objects. Validation is performed on all of the parameters as well as theCreator
objects associated with the type. This validation ensures that the labels and constructor parameters match based on annotations.- Parameters:
detail
- contains the details instantiators are built with- Returns:
- this returns the instance that has been created
- Throws:
Exception
-
create
This is used to create a newCreator
object from the provided signature. Once created the instance is added to the list of available creators which can be used to instantiate an object instance.- Parameters:
signature
- this is the signature that is to be used- Returns:
- this returns the creator associated with this builder
-
create
This is used to create aParameter
based on the currently registered labels. Creating a replacement in this way ensures that all parameters are keyed in the exact same way that the label is, making it easier and quicker to match them.- Parameters:
original
- this is the original parameter to replace- Returns:
- this returns the replacement parameter object
- Throws:
Exception
-
populate
This used to populate replace the parameters extracted from the scanning process with ones matched with registered labels. By replacing parameters in this way the parameters can be better matched with the associated labels using the label keys.- Parameters:
detail
- contains the details instantiators are built with- Throws:
Exception
-
populate
This used to populate replace the parameters extracted from the scanning process with ones matched with registered labels. By replacing parameters in this way the parameters can be better matched with the associated labels using the label keys.- Parameters:
signature
- this is the signature used for a creator- Throws:
Exception
-
validate
This is used to ensure that for each parameter in the builder there is a matching method or field. This ensures that the class schema is fully readable and writable. If not method or field annotation exists for the parameter validation fails.- Parameters:
detail
- contains the details instantiators are built with- Throws:
Exception
-
validateParameter
This is used to validate theParameter
object that exist in the constructors. Validation is performed against the annotated methods and fields to ensure that they match up.- Parameters:
label
- this is the annotated method or field to validateparameter
- this is the parameter to validate with- Throws:
Exception
-
validateNames
This is used to validate the names associated with the parameters. Validation is performed by checking that the parameter name is present in the list of names the label is known by. This is used to ensure that the if the label is a union the parameter is one of the names declared within the union.- Parameters:
label
- this is the label to validate the parameter againstparameter
- this is the parameter that is to be validated- Throws:
Exception
-
validateAnnotations
This is used to validate the annotations associated with a field and a matching constructor parameter. Each constructor parameter paired with an annotated field or method must be the same annotation type and must also contain the same name.- Parameters:
label
- this is the label associated with the parameterparameter
- this is the constructor parameter to use- Throws:
Exception
-
validateConstructors
This is used to ensure that final methods and fields have a constructor parameter that allows the value to be injected in to. Validating the constructor in this manner ensures that the class schema remains fully serializable and deserializable.- Throws:
Exception
-
validateConstructors
This is used when there are only default constructors. It will check to see if any of the annotated fields or methods is read only. If a read only method or field is found then this will throw an exception to indicate that it is not valid.- Parameters:
map
- this is the map of values that is to be validated- Throws:
Exception
-
validateConstructors
This is used to ensure that final methods and fields have a constructor parameter that allows the value to be injected in to. Validating the constructor in this manner ensures that the class schema remains fully serializable and deserializable.- Parameters:
map
- this is the map that contains the labels to validatelist
- this is the list of builders to validate- Throws:
Exception
-
validateConstructor
This is used to ensure that final methods and fields have a constructor parameter that allows the value to be injected in to. Validating the constructor in this manner ensures that the class schema remains fully serializable and deserializable.- Parameters:
label
- this is the variable to check in constructorslist
- this is the list of builders to validate- Throws:
Exception
-
register
Thisregister
method is used to register a label based on its name and path. Registration like this is done to ensure that the label can be resolved based on a parameter name or path.- Parameters:
label
- this is the label that is to be registered- Throws:
Exception
-
register
Thisregister
method is used to register a label based on its name and path. Registration like this is done to ensure that the label can be resolved based on a parameter name or path.Registration here ensures a parameter can be resolved on both name and path. However, because we want these mappings to be unique we do not allow multiple names to be mapped to the same label. For example, say we have 'x/@a' and 'y/@a', these both have the same name 'a' even though the point/put( to different things. Here we would not allow a mapping from 'a' and keep only mappings based on the full path. This means that any parameters specified must declare the full path also.
- Parameters:
label
- this is the label that is to be registeredmap
- this is the map that the label is registered with- Throws:
Exception
-
resolve
Thisresolve
method is used to find a label based on the name and path of the provided parameter. If it can not be found then this will return null.- Parameters:
parameter
- this is the parameter used for resolution- Returns:
- the label that has been resolved, or null
- Throws:
Exception
-
resolve
Thisresolve
method is used to find a label based on the name and path of the provided parameter. If it can not be found then this will return null.- Parameters:
parameter
- this is the parameter used for resolutionmap
- this is the map that is used for resolution- Returns:
- the label that has been resolved, or null
- Throws:
Exception
-
contains
This is used to determine if a value exists within an array. Searching the array like this is required when no collections are available to use on the list of attributes.- Parameters:
list
- this is the list to begin searching for a valuevalue
- this is the value to be searched for- Returns:
- true if the list contains the specified value
- Throws:
Exception
-