Package org.simpleframework.xml.core
Class ElementMapParameter
- java.lang.Object
-
- org.simpleframework.xml.core.TemplateParameter
-
- org.simpleframework.xml.core.ElementMapParameter
-
- All Implemented Interfaces:
Parameter
class ElementMapParameter extends TemplateParameter
TheElementMapParameter
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 Classes Modifier and Type Class Description private static class
ElementMapParameter.Contact
TheContact
represents a contact object that is to be used for a label in order to extract a parameter name.
-
Field Summary
Fields Modifier and Type Field Description private ElementMapParameter.Contact
contact
This is the contact used to determine the parameter name.private Expression
expression
This is the expression used to represent this parameter.private int
index
This is the index that the parameter was declared at.private java.lang.Object
key
This is the key used to represent this parameter object.private Label
label
This is the label that will create the parameter name.private java.lang.String
name
This is the actual name that has been determined.private java.lang.String
path
This is the fully qualified path used for this parameter.private java.lang.Class
type
This is the type of the label represented by this.
-
Constructor Summary
Constructors Constructor Description ElementMapParameter(java.lang.reflect.Constructor factory, ElementMap value, Format format, int index)
Constructor for theElementMapParameter
object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.annotation.Annotation
getAnnotation()
This is used to acquire the annotation that is used for the parameter.Expression
getExpression()
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.java.lang.Object
getKey()
This is the key used to represent the parameter.java.lang.String
getName()
This is used to acquire the name of the parameter that this represents.java.lang.String
getPath()
This is used to acquire the path of the element or attribute represented by this parameter.java.lang.Class
getType()
This is used to acquire the annotated type class.boolean
isPrimitive()
This is used to determine if the parameter is primitive.boolean
isRequired()
This is used to determine if the parameter is required.java.lang.String
toString()
This is used to provide a textual representation of the parameter.-
Methods inherited from class org.simpleframework.xml.core.TemplateParameter
isAttribute, isText
-
-
-
-
Field Detail
-
expression
private final Expression expression
This is the expression used to represent this parameter.
-
contact
private final ElementMapParameter.Contact contact
This is the contact used to determine the parameter name.
-
label
private final Label label
This is the label that will create the parameter name.
-
path
private final java.lang.String path
This is the fully qualified path used for this parameter.
-
name
private final java.lang.String name
This is the actual name that has been determined.
-
type
private final java.lang.Class type
This is the type of the label represented by this.
-
key
private final java.lang.Object key
This is the key used to represent this parameter object.
-
index
private final int index
This is the index that the parameter was declared at.
-
-
Constructor Detail
-
ElementMapParameter
public ElementMapParameter(java.lang.reflect.Constructor factory, ElementMap value, Format format, int index) throws java.lang.Exception
Constructor for theElementMapParameter
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 to style this parameterindex
- this is the index the parameter appears at- Throws:
java.lang.Exception
-
-
Method Detail
-
getKey
public java.lang.Object 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
public java.lang.String 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
public java.lang.String 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
public Expression 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
-
getType
public java.lang.Class 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
public java.lang.annotation.Annotation 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
-
toString
public java.lang.String 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.
-
-