Class CacheParameter

java.lang.Object
org.simpleframework.xml.core.CacheParameter
All Implemented Interfaces:
Parameter

class CacheParameter extends Object implements 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

    Fields
    Modifier and Type
    Field
    Description
    private 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

    Constructors
    Constructor
    Description
    Constructor for the CacheParameter object.
  • Method Summary

    Modifier and Type
    Method
    Description
    This 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
    This returns the index position of the parameter in the constructor.
    This is the key used to represent the parameter.
    This is used to acquire the name of the parameter that this represents.
    This is used to acquire the path of the element or attribute represented by this parameter.
    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
    This is used to determine if the parameter represents text.
    This is used to provide a textual representation of the parameter.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • annotation

      private final Annotation annotation
      This is the annotation used to represent this parameter.
    • expression

      private final Expression expression
      This is the XPath expression used to represent the parameter.
    • name

      private final String name
      This is the name of the element or attribute for the parameter.
    • path

      private final String path
      This is the path of the element or attribute for the parameter.
    • string

      private final String string
      This is the string representation of this parameter object.
    • type

      private final Class type
      This is the type within the constructor of this parameter.
    • key

      private final Object key
      This is the key that uniquely identifies this parameter.
    • index

      private final int index
      This is the index within the constructor for the parameter.
    • primitive

      private final boolean primitive
      Determines if this parameter represents a primitive value.
    • required

      private final boolean required
      This is true if this parameter is required to exist.
    • attribute

      private final boolean attribute
      This is true if this parameter represents an attribute.
    • text

      private final boolean text
      This is true if this parameter represents a text value.
  • Constructor Details

    • CacheParameter

      public CacheParameter(Parameter value, Label label) throws Exception
      Constructor for the CacheParameter 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 from
      label - this is the label to acquire the key from
      Throws:
      Exception
  • Method Details

    • getKey

      public 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.
      Specified by:
      getKey in interface Parameter
      Returns:
      this is the key used to represent the parameter
    • getType

      public 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.
      Specified by:
      getType in interface Parameter
      Returns:
      this returns the type used for 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.
      Specified by:
      getIndex in interface Parameter
      Returns:
      this returns the index for the parameter
    • getAnnotation

      public 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 the Element or Attribute annotation.
      Specified by:
      getAnnotation in interface Parameter
      Returns:
      this returns the annotation used on the 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.
      Specified by:
      getExpression in interface Parameter
      Returns:
      the XPath expression identifying the location
    • getName

      public 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.
      Specified by:
      getName in interface Parameter
      Returns:
      this returns the name of the annotated parameter
    • getPath

      public 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.
      Specified by:
      getPath in interface Parameter
      Returns:
      returns the path that is used for this 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.
      Specified by:
      isRequired in interface Parameter
      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 interface Parameter
      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 interface Parameter
      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.
      Specified by:
      isText in interface Parameter
      Returns:
      returns true if this parameter represents text
    • toString

      public 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.
      Specified by:
      toString in interface Parameter
      Overrides:
      toString in class Object
      Returns:
      this returns the string representation for this