Class AbstractElementNode

java.lang.Object
com.puppycrawl.tools.checkstyle.xpath.AbstractNode
com.puppycrawl.tools.checkstyle.xpath.AbstractElementNode
All Implemented Interfaces:
Source, SourceLocator, net.sf.saxon.lib.ActiveSource, net.sf.saxon.om.GNode, net.sf.saxon.om.GroundedValue, net.sf.saxon.om.Item, net.sf.saxon.om.NodeInfo, net.sf.saxon.om.Sequence, net.sf.saxon.s9api.Location, Locator
Direct Known Subclasses:
ElementNode

public abstract class AbstractElementNode extends AbstractNode
Represents element node of Xpath-tree.
  • Field Details

  • Constructor Details

    • AbstractElementNode

      protected AbstractElementNode(AbstractNode root, AbstractNode parent, int depth, int indexAmongSiblings)
      Creates a new AbstractElementNode instance.
      Parameters:
      root - Node root of the tree
      parent - Node parent of the current node
      depth - the current node depth in the hierarchy
      indexAmongSiblings - the current node index among the parent children nodes
  • Method Details

    • createAttributeNode

      protected abstract AttributeNode createAttributeNode()
      Creates AttributeNode object and returns it.
      Returns:
      attribute node if possible, otherwise the null value
    • compareOrder

      public int compareOrder(net.sf.saxon.om.GNode other)
      Compares current object with specified for order.
      Parameters:
      other - another GNode object
      Returns:
      number representing order of current object to specified one
    • compareCommonAncestorChildrenOrder

      private static int compareCommonAncestorChildrenOrder(net.sf.saxon.om.GNode first, net.sf.saxon.om.GNode second)
      Walks up the hierarchy until a common ancestor is found. Then compares topmost sibling nodes.
      Parameters:
      first - GNode to compare
      second - GNode to compare
      Returns:
      the value 0 if first == second; a value less than 0 if first should be first; a value greater than 0 if second should be first.
    • getDepth

      public int getDepth()
      Getter method for node depth.
      Specified by:
      getDepth in class AbstractNode
      Returns:
      depth
    • getAttributeValue

      public String getAttributeValue(net.sf.saxon.om.NamespaceUri namespace, String localPart)
      Returns attribute value.
      Parameters:
      namespace - namespace
      localPart - actual name of the attribute
      Returns:
      attribute value or null if the attribute was not found
    • getNodeKind

      public int getNodeKind()
      Returns type of the node.
      Returns:
      node kind
    • getParent

      public net.sf.saxon.om.NodeInfo getParent()
      Returns parent.
      Returns:
      parent
    • getRoot

      Returns root.
      Returns:
      root
    • iterateAttributeAxis

      public net.sf.saxon.om.SequenceIterator iterateAttributeAxis(net.sf.saxon.pattern.nodetest.NodePredicate predicate)
      Returns attribute axis iterator.
      Parameters:
      predicate - filter for the iterator, may be null
      Returns:
      iterator over the @text attribute node, or an empty iterator
    • iterateChildAxis

      public net.sf.saxon.om.SequenceIterator iterateChildAxis(net.sf.saxon.pattern.nodetest.NodePredicate predicate)
      Returns child axis iterator.
      Parameters:
      predicate - filter for the iterator, may be null
      Returns:
      iterator over the children
    • iterateDescendantAxis

      public net.sf.saxon.om.SequenceIterator iterateDescendantAxis(net.sf.saxon.pattern.nodetest.NodePredicate predicate)
      Returns descendant axis iterator.
      Parameters:
      predicate - filter for the iterator, may be null
      Returns:
      iterator over the descendants
    • iterateDescendantOrSelfAxis

      public net.sf.saxon.om.SequenceIterator iterateDescendantOrSelfAxis(net.sf.saxon.pattern.nodetest.NodePredicate predicate)
      Returns descendant-or-self axis iterator.
      Parameters:
      predicate - filter for the iterator, may be null
      Returns:
      iterator over the current node and its descendants
    • iterateFollowingSiblingAxis

      public net.sf.saxon.om.SequenceIterator iterateFollowingSiblingAxis(net.sf.saxon.pattern.nodetest.NodePredicate predicate)
      Returns following-sibling axis iterator.
      Parameters:
      predicate - filter for the iterator, may be null
      Returns:
      iterator over the following siblings
    • iteratePrecedingSiblingAxis

      public net.sf.saxon.om.SequenceIterator iteratePrecedingSiblingAxis(net.sf.saxon.pattern.nodetest.NodePredicate predicate)
      Returns preceding-sibling axis iterator.
      Parameters:
      predicate - filter for the iterator, may be null
      Returns:
      iterator over the preceding siblings
    • iterateFollowingAxis

      public net.sf.saxon.om.SequenceIterator iterateFollowingAxis(net.sf.saxon.pattern.nodetest.NodePredicate predicate)
      Returns following axis iterator.
      Parameters:
      predicate - filter for the iterator, may be null
      Returns:
      iterator over the following nodes
    • iteratePrecedingAxis

      public net.sf.saxon.om.SequenceIterator iteratePrecedingAxis(net.sf.saxon.pattern.nodetest.NodePredicate predicate)
      Returns preceding axis iterator.
      Parameters:
      predicate - filter for the iterator, may be null
      Returns:
      iterator over the preceding nodes
    • getPrecedingSiblingsIterator

      private net.sf.saxon.om.SequenceIterator getPrecedingSiblingsIterator()
      Returns preceding sibling axis iterator.
      Returns:
      iterator
    • getFollowingSiblingsIterator

      private net.sf.saxon.om.SequenceIterator getFollowingSiblingsIterator()
      Returns following sibling axis iterator.
      Returns:
      iterator
    • getFollowingSiblings

      Returns following siblings of the current node.
      Returns:
      siblings
    • getPrecedingSiblings

      Returns preceding siblings of the current node.
      Returns:
      siblings
    • getAttributeNode

      Checks if token type supports @text attribute, extracts its value, creates AttributeNode object and returns it. Value can be accessed using @text attribute.
      Returns:
      attribute node if possible, otherwise the null value
    • iterateNamespaceAxis

      public net.sf.saxon.om.SequenceIterator iterateNamespaceAxis(net.sf.saxon.pattern.nodetest.NodePredicate predicate)
      Namespace axis is not supported for element nodes.
      Parameters:
      predicate - filter for the iterator, may be null
      Returns:
      never