Class AttributeParameter

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

class AttributeParameter extends TemplateParameter
The AttributeParameter 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 
    The Contact 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
    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

    Constructors
    Constructor
    Description
    AttributeParameter(Constructor factory, Attribute value, Format format, int index)
    Constructor for the AttributeParameter 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.
    This is used to provide a textual representation of the parameter.

    Methods inherited from class org.simpleframework.xml.core.TemplateParameter

    isText

    Methods inherited from class java.lang.Object

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

    • expression

      private final Expression expression
      This is the expression used to represent this parameter.
    • contact

      private final AttributeParameter.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 String path
      This is the fully qualified path used for this parameter.
    • name

      private final String name
      This is the actual name that has been determined.
    • type

      private final Class type
      This is the type of the label represented by this.
    • key

      private final 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 Details

    • AttributeParameter

      public AttributeParameter(Constructor factory, Attribute value, Format format, int index) throws Exception
      Constructor for the AttributeParameter 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 in
      value - this is the annotation used for the parameter
      format - this is the format used to style the paths
      index - this is the index the parameter appears at
      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.
      Returns:
      this is the key used to represent the 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.
      Returns:
      returns the path that is used for this parameter
    • 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.
      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 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 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.
      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
    • 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
      Overrides:
      isAttribute in class TemplateParameter
      Returns:
      this is used to determine if this is an attribute
    • 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