Package org.simpleframework.xml.core
Class CacheParameter
java.lang.Object
org.simpleframework.xml.core.CacheParameter
- All Implemented Interfaces:
Parameter
The
CacheParameter
object represents a parameter
which caches its values internally. As well as caching parameter
values this also caches a key from a Label
object
which ties the parameter an label together making it possible
to reference each other from hash containers.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Annotation
This is the annotation used to represent this parameter.private final boolean
This is true if this parameter represents an attribute.private final Expression
This is the XPath expression used to represent the parameter.private final int
This is the index within the constructor for the parameter.private final Object
This is the key that uniquely identifies this parameter.private final String
This is the name of the element or attribute for the parameter.private final String
This is the path of the element or attribute for the parameter.private final boolean
Determines if this parameter represents a primitive value.private final boolean
This is true if this parameter is required to exist.private final String
This is the string representation of this parameter object.private final boolean
This is true if this parameter represents a text value.private final Class
This is the type within the constructor of this parameter. -
Constructor Summary
ConstructorsConstructorDescriptionCacheParameter
(Parameter value, Label label) Constructor for theCacheParameter
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.getPath()
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 method is used to determine if the parameter represents an attribute.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.
-
Field Details
-
annotation
This is the annotation used to represent this parameter. -
expression
This is the XPath expression used to represent the parameter. -
name
This is the name of the element or attribute for the parameter. -
path
This is the path of the element or attribute for the parameter. -
string
This is the string representation of this parameter object. -
type
This is the type within the constructor of this parameter. -
key
This is the key that uniquely identifies this parameter. -
index
private final int indexThis is the index within the constructor for the parameter. -
primitive
private final boolean primitiveDetermines if this parameter represents a primitive value. -
required
private final boolean requiredThis is true if this parameter is required to exist. -
attribute
private final boolean attributeThis is true if this parameter represents an attribute. -
text
private final boolean textThis is true if this parameter represents a text value.
-
-
Constructor Details
-
CacheParameter
Constructor for theCacheParameter
object. This is used to create a parameter that internally caches all of the information of the provided parameter and also makes use of the label provided to generate a unique key.- Parameters:
value
- this is the parameter to cache values fromlabel
- this is the label to acquire the key from- 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. -
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. -
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. -
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.- Specified by:
getAnnotation
in interfaceParameter
- Returns:
- this returns the annotation used on the 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.- Specified by:
getExpression
in interfaceParameter
- Returns:
- the XPath expression identifying the location
-
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. -
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. -
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.- Specified by:
isRequired
in interfaceParameter
- 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.- Specified by:
isPrimitive
in interfaceParameter
- Returns:
- this returns true if the parameter is primitive
-
isAttribute
public boolean isAttribute()This method is used to determine if the parameter represents an attribute. This is used to style the name so that elements are styled as elements and attributes are styled as required.- Specified by:
isAttribute
in interfaceParameter
- Returns:
- this is used to determine if this is an attribute
-
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. -
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.
-