Class InputAttribute

  • All Implemented Interfaces:
    InputNode, Node

    class InputAttribute
    extends java.lang.Object
    implements InputNode
    The InputAttribute is used to represent an attribute within an element. Rather than representing an attribute as a name value pair of strings, an attribute is instead represented as an input node, in the same manner as an element. The reason for representing an attribute in this way is such that a uniform means of extracting and parsing values can be used for inputs.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.lang.String name
      Represents the name of this input attribute instance.
      private InputNode parent
      This is the parent node to this attribute instance.
      private java.lang.String prefix
      This is the prefix associated with this attribute node.
      private java.lang.String reference
      This is the reference associated with this attribute node.
      private java.lang.Object source
      This is the source associated with this input attribute.
      private java.lang.String value
      Represents the value for this input attribute instance.
    • Constructor Summary

      Constructors 
      Constructor Description
      InputAttribute​(InputNode parent, java.lang.String name, java.lang.String value)
      Constructor for the InputAttribute object.
      InputAttribute​(InputNode parent, Attribute attribute)
      Constructor for the InputAttribute object.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      InputNode getAttribute​(java.lang.String name)
      Because the InputAttribute object represents an attribute this method will return null.
      NodeMap<InputNode> getAttributes()
      Because the InputAttribute object represents an attribute this method will return an empty map.
      java.lang.String getName()
      Returns the name of the node that this represents.
      InputNode getNext()
      Because the InputAttribute object represents an attribute this method will return null.
      InputNode getNext​(java.lang.String name)
      Because the InputAttribute object represents an attribute this method will return null.
      InputNode getParent()
      This is used to acquire the Node that is the parent of this node.
      Position getPosition()
      This provides the position of this node within the document.
      java.lang.String getPrefix()
      This is used to acquire the namespace prefix for the node.
      java.lang.String getReference()
      This allows the namespace reference URI to be determined.
      java.lang.Object getSource()
      This is used to return the source object for this node.
      java.lang.String getValue()
      Returns the value for the node that this represents.
      boolean isElement()
      This is used to determine if this node is an element.
      boolean isEmpty()
      This is used to determine if this input node is empty.
      boolean isRoot()
      This method is used to determine if this node is the root node for the XML document.
      void skip()
      This method is used to skip all child elements from this element.
      java.lang.String toString()
      This is the string representation of the attribute.
      • Methods inherited from class java.lang.Object

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

      • parent

        private InputNode parent
        This is the parent node to this attribute instance.
      • reference

        private java.lang.String reference
        This is the reference associated with this attribute node.
      • prefix

        private java.lang.String prefix
        This is the prefix associated with this attribute node.
      • name

        private java.lang.String name
        Represents the name of this input attribute instance.
      • value

        private java.lang.String value
        Represents the value for this input attribute instance.
      • source

        private java.lang.Object source
        This is the source associated with this input attribute.
    • Constructor Detail

      • InputAttribute

        public InputAttribute​(InputNode parent,
                              java.lang.String name,
                              java.lang.String value)
        Constructor for the InputAttribute object. This is used to create an input attribute using the provided name and value, all other values for this input node will be null.
        Parameters:
        parent - this is the parent node to this attribute
        name - this is the name for this attribute object
        value - this is the value for this attribute object
      • InputAttribute

        public InputAttribute​(InputNode parent,
                              Attribute attribute)
        Constructor for the InputAttribute object. This is used to create an input attribute using the provided name and value, all other values for this input node will be null.
        Parameters:
        parent - this is the parent node to this attribute
        attribute - this is the attribute containing the details
    • Method Detail

      • getSource

        public java.lang.Object getSource()
        This is used to return the source object for this node. This is used primarily as a means to determine which XML provider is parsing the source document and producing the nodes. It is useful to be able to determine the XML provider like this.
        Specified by:
        getSource in interface InputNode
        Returns:
        this returns the source of this input node
      • getParent

        public InputNode getParent()
        This is used to acquire the Node that is the parent of this node. This will return the node that is the direct parent of this node and allows for siblings to make use of nodes with their parents if required.
        Specified by:
        getParent in interface InputNode
        Specified by:
        getParent in interface Node
        Returns:
        this returns the parent node for this node
      • getPosition

        public Position getPosition()
        This provides the position of this node within the document. This allows the user of this node to report problems with the location within the document, allowing the XML to be debugged if it does not match the class schema.
        Specified by:
        getPosition in interface InputNode
        Returns:
        this returns the position of the XML read cursor
      • getName

        public java.lang.String getName()
        Returns the name of the node that this represents. This is an immutable property and will not change for this node.
        Specified by:
        getName in interface Node
        Returns:
        returns the name of the node that this represents
      • getPrefix

        public java.lang.String getPrefix()
        This is used to acquire the namespace prefix for the node. If there is no namespace prefix for the node then this will return null. Acquiring the prefix enables the qualification of the node to be determined. It also allows nodes to be grouped by its prefix and allows group operations.
        Specified by:
        getPrefix in interface InputNode
        Returns:
        this returns the prefix associated with this node
      • getReference

        public java.lang.String getReference()
        This allows the namespace reference URI to be determined. A reference is a globally unique string that allows the node to be identified. Typically the reference will be a URI but it can be any unique string used to identify the node. This allows the node to be identified within the namespace.
        Specified by:
        getReference in interface InputNode
        Returns:
        this returns the associated namespace reference URI
      • getValue

        public java.lang.String getValue()
        Returns the value for the node that this represents. This is an immutable value for the node and cannot be changed.
        Specified by:
        getValue in interface Node
        Returns:
        the name of the value for this node instance
      • isRoot

        public boolean isRoot()
        This method is used to determine if this node is the root node for the XML document. This will return false as this node can never be the root node because it is an attribute.
        Specified by:
        isRoot in interface InputNode
        Returns:
        this will always return false for attribute nodes
      • isElement

        public boolean isElement()
        This is used to determine if this node is an element. This node instance can not be an element so this method returns false. Returning null tells the users of this node that any attributes added to the node map will be permenantly lost.
        Specified by:
        isElement in interface InputNode
        Returns:
        this returns false as this is an attribute node
      • getAttribute

        public InputNode getAttribute​(java.lang.String name)
        Because the InputAttribute object represents an attribute this method will return null. If nodes are added to the node map the values will not be available here.
        Specified by:
        getAttribute in interface InputNode
        Parameters:
        name - this is the name of the attribute to retrieve
        Returns:
        this always returns null for a requested attribute
      • getAttributes

        public NodeMap<InputNode> getAttributes()
        Because the InputAttribute object represents an attribute this method will return an empty map. If nodes are added to the node map the values will not be maintained.
        Specified by:
        getAttributes in interface InputNode
        Returns:
        this always returns an empty node map of attributes
      • getNext

        public InputNode getNext()
        Because the InputAttribute object represents an attribute this method will return null. An attribute is a simple name value pair an so can not contain any child nodes.
        Specified by:
        getNext in interface InputNode
        Returns:
        this always returns null for a requested child node
      • getNext

        public InputNode getNext​(java.lang.String name)
        Because the InputAttribute object represents an attribute this method will return null. An attribute is a simple name value pair an so can not contain any child nodes.
        Specified by:
        getNext in interface InputNode
        Parameters:
        name - this is the name of the next expected element
        Returns:
        this always returns null for a requested child node
      • skip

        public void skip()
        This method is used to skip all child elements from this element. This allows elements to be effectively skipped such that when parsing a document if an element is not required then that element can be completely removed from the XML.
        Specified by:
        skip in interface InputNode
      • isEmpty

        public boolean isEmpty()
        This is used to determine if this input node is empty. An empty node is one with no attributes or children. This can be used to determine if a given node represents an empty entity, with which no extra data can be extracted.
        Specified by:
        isEmpty in interface InputNode
        Returns:
        this will always return false as it has a value
      • toString

        public java.lang.String toString()
        This is the string representation of the attribute. It is used for debugging purposes. When evaluating the attribute the to string can be used to print out the attribute name.
        Overrides:
        toString in class java.lang.Object
        Returns:
        this returns a text description of the attribute