Package org.simpleframework.xml.core
Class TextParameter
java.lang.Object
org.simpleframework.xml.core.TemplateParameter
org.simpleframework.xml.core.TextParameter
- All Implemented Interfaces:
Parameter
The
TextParameter
represents a constructor
parameter. It contains the XML annotation used on the parameter
as well as the name of the parameter and its position index.
A parameter is used to validate against the annotated methods
and fields and also to determine the deserialized values that
should be injected in to the constructor to instantiate it.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class
TheContact
represents a contact object that is to be used for a label in order to extract a parameter name. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final TextParameter.Contact
This is the contact used to determine the parameter name.private final Expression
This is the expression used to represent this parameter.private final int
This is the index that the parameter was declared at.private final Object
This is the key used to represent this parameter object.private final Label
This is the label that will create the parameter name.private final String
This is the actual name that has been determined.private final String
This is the fully qualified path used for this parameter.private final Class
This is the type of the label represented by this. -
Constructor Summary
ConstructorsConstructorDescriptionTextParameter
(Constructor factory, Text value, Format format, int index) Constructor for theTextParameter
object. -
Method Summary
Modifier and TypeMethodDescriptionThis is used to acquire the annotation that is used for the parameter.This method is used to return an XPath expression that is used to represent the position of this parameter.int
getIndex()
This returns the index position of the parameter in the constructor.getKey()
This is the key used to represent the parameter.getName()
This is used to acquire the name of the parameter that this represents.This is used to acquire the name of the parameter that this represents.getPath()
This is used to acquire the path of the element or attribute represented by this parameter.This is used to acquire the path of the element or attribute represented by this parameter.getType()
This is used to acquire the annotated type class.boolean
This is used to determine if the parameter is primitive.boolean
This is used to determine if the parameter is required.boolean
isText()
This is used to determine if the parameter represents text.toString()
This is used to provide a textual representation of the parameter.Methods inherited from class org.simpleframework.xml.core.TemplateParameter
isAttribute
-
Field Details
-
expression
This is the expression used to represent this parameter. -
contact
This is the contact used to determine the parameter name. -
label
This is the label that will create the parameter name. -
path
This is the fully qualified path used for this parameter. -
name
This is the actual name that has been determined. -
type
This is the type of the label represented by this. -
key
This is the key used to represent this parameter object. -
index
private final int indexThis is the index that the parameter was declared at.
-
-
Constructor Details
-
TextParameter
Constructor for theTextParameter
object. This is used to create a parameter that can be used to determine a consistent name using the provided XML annotation.- Parameters:
factory
- this is the constructor the parameter is invalue
- this is the annotation used for the parameterformat
- this is the format used for this parameterindex
- this is the index the parameter appears at- Throws:
Exception
-
-
Method Details
-
getKey
This is the key used to represent the parameter. The key is used to store the parameter in hash containers. Unlike the path is not necessarily the path for the parameter.- Returns:
- this is the key used to represent the parameter
-
getPath
This is used to acquire the path of the element or attribute represented by this parameter. The path is determined by acquiring the XPath expression and appending the name of the label to form a fully qualified path.- Returns:
- returns the path that is used for this parameter
-
getName
This is used to acquire the name of the parameter that this represents. The name is determined using annotation and the name attribute of that annotation, if one is provided.- Returns:
- this returns the name of the annotated parameter
-
getExpression
This method is used to return an XPath expression that is used to represent the position of this parameter. If there is no XPath expression associated with this then an empty path is returned. This will never return a null expression.- Returns:
- the XPath expression identifying the location
-
getPath
This is used to acquire the path of the element or attribute represented by this parameter. The path is determined by acquiring the XPath expression and appending the name of the label to form a fully qualified styled path.- Parameters:
context
- this is the context used to style the path- Returns:
- returns the path that is used for this parameter
-
getName
This is used to acquire the name of the parameter that this represents. The name is determined using annotation and the name attribute of that annotation, if one is provided.- Parameters:
context
- this is the context used to style the name- Returns:
- this returns the name of the annotated parameter
-
getType
This is used to acquire the annotated type class. The class is the type that is to be deserialized from the XML. This is used to validate against annotated fields and methods.- Returns:
- this returns the type used for the parameter
-
getAnnotation
This is used to acquire the annotation that is used for the parameter. The annotation provided will be an XML annotation such as theElement
orAttribute
annotation.- Returns:
- this returns the annotation used on the parameter
-
getIndex
public int getIndex()This returns the index position of the parameter in the constructor. This is used to determine the order of values that are to be injected in to the constructor.- Returns:
- this returns the index for the parameter
-
isRequired
public boolean isRequired()This is used to determine if the parameter is required. If an attribute is not required then it can be null. Which means that we can inject a null value. Also, this means we can match constructors in a more flexible manner.- Returns:
- this returns true if the parameter is required
-
isPrimitive
public boolean isPrimitive()This is used to determine if the parameter is primitive. A primitive parameter must not be null. As there is no way to provide the value to the constructor. A default value is not a good solution as it affects the constructor score.- Returns:
- this returns true if the parameter is primitive
-
isText
public boolean isText()This is used to determine if the parameter represents text. If this represents text it typically does not have a name, instead the empty string represents the name. Also text parameters can not exist with other text parameters.- Specified by:
isText
in interfaceParameter
- Overrides:
isText
in classTemplateParameter
- Returns:
- returns true if this parameter represents text
-
toString
This is used to provide a textual representation of the parameter. Providing a string describing the parameter is useful for debugging and for exception messages.
-