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
Represents element node of Xpath-tree.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final AttributeNodeHolder value for lazy creation of attribute node.private AttributeNodeThe text attribute node.private final intDepth of the node.private static final AbstractNode[]Constant for optimization.private final intRepresents index among siblings.private final AbstractNodeThe parent of the current node.private final AbstractNodeThe root node.protected static final StringString literal for text attribute. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractElementNode(AbstractNode root, AbstractNode parent, int depth, int indexAmongSiblings) Creates a newAbstractElementNodeinstance. -
Method Summary
Modifier and TypeMethodDescriptionprivate static intcompareCommonAncestorChildrenOrder(net.sf.saxon.om.GNode first, net.sf.saxon.om.GNode second) Walks up the hierarchy until a common ancestor is found.intcompareOrder(net.sf.saxon.om.GNode other) Compares current object with specified for order.protected abstract AttributeNodeCreatesAttributeNodeobject and returns it.private AttributeNodeChecks if token type supports@textattribute, extracts its value, createsAttributeNodeobject and returns it.getAttributeValue(net.sf.saxon.om.NamespaceUri namespace, String localPart) Returns attribute value.intgetDepth()Getter method for node depth.private List<AbstractNode> Returns following siblings of the current node.private net.sf.saxon.om.SequenceIteratorReturns following sibling axis iterator.intReturns type of the node.net.sf.saxon.om.NodeInfoReturns parent.private List<AbstractNode> Returns preceding siblings of the current node.private net.sf.saxon.om.SequenceIteratorReturns preceding sibling axis iterator.getRoot()Returns root.net.sf.saxon.om.SequenceIteratoriterateAttributeAxis(net.sf.saxon.pattern.nodetest.NodePredicate predicate) Returns attribute axis iterator.net.sf.saxon.om.SequenceIteratoriterateChildAxis(net.sf.saxon.pattern.nodetest.NodePredicate predicate) Returns child axis iterator.net.sf.saxon.om.SequenceIteratoriterateDescendantAxis(net.sf.saxon.pattern.nodetest.NodePredicate predicate) Returns descendant axis iterator.net.sf.saxon.om.SequenceIteratoriterateDescendantOrSelfAxis(net.sf.saxon.pattern.nodetest.NodePredicate predicate) Returns descendant-or-self axis iterator.net.sf.saxon.om.SequenceIteratoriterateFollowingAxis(net.sf.saxon.pattern.nodetest.NodePredicate predicate) Returns following axis iterator.net.sf.saxon.om.SequenceIteratoriterateFollowingSiblingAxis(net.sf.saxon.pattern.nodetest.NodePredicate predicate) Returns following-sibling axis iterator.net.sf.saxon.om.SequenceIteratoriterateNamespaceAxis(net.sf.saxon.pattern.nodetest.NodePredicate predicate) Namespace axis is not supported for element nodes.net.sf.saxon.om.SequenceIteratoriteratePrecedingAxis(net.sf.saxon.pattern.nodetest.NodePredicate predicate) Returns preceding axis iterator.net.sf.saxon.om.SequenceIteratoriteratePrecedingSiblingAxis(net.sf.saxon.pattern.nodetest.NodePredicate predicate) Returns preceding-sibling axis iterator.Methods inherited from class com.puppycrawl.tools.checkstyle.xpath.AbstractNode
atomize, copy, createChildren, filter, generateId, getAllNamespaces, getBaseURI, getChildren, getConfiguration, getDeclaredNamespaces, getDisplayName, getFingerprint, getNamespaceUri, getPrefix, getPublicId, getSchemaType, getStringValue, getSystemId, getTokenType, getTreeInfo, getUnderlyingNode, getUnicodeStringValue, getURI, hasFingerprint, isId, isIdref, isNilled, isSameNodeInfo, isStreamed, saveLocation, setSystemIdMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.sf.saxon.om.GNode
iterateAncestorAxis, iterateAncestorOrSelfAxis, iterateFollowingOrSelfAxis, iterateFollowingSiblingOrSelfAxis, iterateParentAxis, iteratePrecedingOrSelfAxis, iteratePrecedingSiblingOrSelfAxis, iterateSelfAxisMethods inherited from interface net.sf.saxon.om.GroundedValue
asIterable, concatenate, containsNode, effectiveBooleanValue, materializeMethods inherited from interface net.sf.saxon.om.Item
getLabel, getLength, head, itemAt, iterate, reduce, subsequenceMethods inherited from interface net.sf.saxon.om.NodeInfo
asActiveSource, attributes, children, children, deliver, equals, getColumnNumber, getGenre, getLineNumber, getLocalPart, getQName, hasChildNodes, hashCode, toShortStringMethods inherited from interface net.sf.saxon.om.Sequence
makeRepeatable
-
Field Details
-
TEXT_ATTRIBUTE_NAME
String literal for text attribute.- See Also:
-
EMPTY_ABSTRACT_NODE_ARRAY
Constant for optimization. -
ATTRIBUTE_NODE_UNINITIALIZED
Holder value for lazy creation of attribute node. -
root
The root node. -
parent
The parent of the current node. -
depth
Depth of the node. -
indexAmongSiblings
Represents index among siblings. -
attributeNode
The text attribute node.
-
-
Constructor Details
-
AbstractElementNode
protected AbstractElementNode(AbstractNode root, AbstractNode parent, int depth, int indexAmongSiblings) Creates a newAbstractElementNodeinstance.- Parameters:
root-Noderoot of the treeparent-Nodeparent of the current nodedepth- the current node depth in the hierarchyindexAmongSiblings- the current node index among the parent children nodes
-
-
Method Details
-
createAttributeNode
CreatesAttributeNodeobject and returns it.- Returns:
- attribute node if possible, otherwise the
nullvalue
-
compareOrder
Compares current object with specified for order.- Parameters:
other- anotherGNodeobject- 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-GNodeto comparesecond-GNodeto compare- Returns:
- the value
0iffirst == second; a value less than0iffirstshould be first; a value greater than0ifsecondshould be first.
-
getDepth
Getter method for node depth.- Specified by:
getDepthin classAbstractNode- Returns:
- depth
-
getAttributeValue
Returns attribute value.- Parameters:
namespace- namespacelocalPart- actual name of the attribute- Returns:
- attribute value or null if the attribute was not found
-
getNodeKind
Returns type of the node.- Returns:
- node kind
-
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
@textattribute 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
Returns preceding sibling axis iterator.- Returns:
- iterator
-
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@textattribute, extracts its value, createsAttributeNodeobject and returns it. Value can be accessed using@textattribute.- Returns:
- attribute node if possible, otherwise the
nullvalue
-
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
-