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.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 Summary
Fields Modifier and Type Field Description private static AttributeNode
ATTRIBUTE_NODE_UNINITIALIZED
Holder value for lazy creation of attribute node.private AttributeNode
attributeNode
The text attribute node.private int
depth
Depth of the node.private static AbstractNode[]
EMPTY_ABSTRACT_NODE_ARRAY
Constant for optimization.private int
indexAmongSiblings
Represents index among siblings.private AbstractNode
parent
The parent of the current node.private AbstractNode
root
The root node.protected static String
TEXT_ATTRIBUTE_NAME
String literal for text attribute.
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractElementNode(AbstractNode root, AbstractNode parent, int depth, int indexAmongSiblings)
Creates a newAbstractElementNode
instance.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description private static int
compareCommonAncestorChildrenOrder(net.sf.saxon.om.NodeInfo first, net.sf.saxon.om.NodeInfo second)
Walks up the hierarchy until a common ancestor is found.int
compareOrder(net.sf.saxon.om.NodeInfo other)
Compares current object with specified for order.protected abstract AttributeNode
createAttributeNode()
CreatesAttributeNode
object and returns it.private AttributeNode
getAttributeNode()
Checks if token type supports@text
attribute, extracts its value, createsAttributeNode
object and returns it.String
getAttributeValue(net.sf.saxon.om.NamespaceUri namespace, String localPart)
Returns attribute value.int
getDepth()
Getter method for node depth.private List<AbstractNode>
getFollowingSiblings()
Returns following siblings of the current node.private net.sf.saxon.tree.iter.AxisIterator
getFollowingSiblingsIterator()
Returns following sibling axis iterator.int
getNodeKind()
Returns type of the node.net.sf.saxon.om.NodeInfo
getParent()
Returns parent.private List<AbstractNode>
getPrecedingSiblings()
Returns preceding siblings of the current node.private net.sf.saxon.tree.iter.AxisIterator
getPrecedingSiblingsIterator()
Returns preceding sibling axis iterator.AbstractNode
getRoot()
Returns root.net.sf.saxon.tree.iter.AxisIterator
iterateAxis(int axisNumber)
Determines axis iteration algorithm.private static UnsupportedOperationException
throwUnsupportedOperationException()
Returns UnsupportedOperationException exception.-
Methods inherited from class com.puppycrawl.tools.checkstyle.xpath.AbstractNode
atomize, copy, createChildren, 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, iterateAxis, saveLocation, setSystemId
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.sf.saxon.om.GroundedValue
asIterable, concatenate, containsNode, effectiveBooleanValue, materialize
-
Methods inherited from interface net.sf.saxon.om.Item
getLength, head, itemAt, iterate, reduce, subsequence
-
-
-
-
Field Detail
-
TEXT_ATTRIBUTE_NAME
protected static final String TEXT_ATTRIBUTE_NAME
String literal for text attribute.- See Also:
- Constant Field Values
-
EMPTY_ABSTRACT_NODE_ARRAY
private static final AbstractNode[] EMPTY_ABSTRACT_NODE_ARRAY
Constant for optimization.
-
ATTRIBUTE_NODE_UNINITIALIZED
private static final AttributeNode ATTRIBUTE_NODE_UNINITIALIZED
Holder value for lazy creation of attribute node.
-
root
private final AbstractNode root
The root node.
-
parent
private final AbstractNode parent
The parent of the current node.
-
depth
private final int depth
Depth of the node.
-
indexAmongSiblings
private final int indexAmongSiblings
Represents index among siblings.
-
attributeNode
private AttributeNode attributeNode
The text attribute node.
-
-
Constructor Detail
-
AbstractElementNode
protected AbstractElementNode(AbstractNode root, AbstractNode parent, int depth, int indexAmongSiblings)
Creates a newAbstractElementNode
instance.- Parameters:
root
-Node
root of the treeparent
-Node
parent of the current nodedepth
- the current node depth in the hierarchyindexAmongSiblings
- the current node index among the parent children nodes
-
-
Method Detail
-
createAttributeNode
protected abstract AttributeNode createAttributeNode()
CreatesAttributeNode
object and returns it.- Returns:
- attribute node if possible, otherwise the
null
value
-
compareOrder
public int compareOrder(net.sf.saxon.om.NodeInfo other)
Compares current object with specified for order.- Parameters:
other
- anotherNodeInfo
object- Returns:
- number representing order of current object to specified one
-
compareCommonAncestorChildrenOrder
private static int compareCommonAncestorChildrenOrder(net.sf.saxon.om.NodeInfo first, net.sf.saxon.om.NodeInfo second)
Walks up the hierarchy until a common ancestor is found. Then compares topmost sibling nodes.- Parameters:
first
-NodeInfo
to comparesecond
-NodeInfo
to compare- Returns:
- the value
0
iffirst == second
; a value less than0
iffirst
should be first; a value greater than0
ifsecond
should be first.
-
getDepth
public int getDepth()
Getter method for node depth.- Specified by:
getDepth
in classAbstractNode
- Returns:
- depth
-
getAttributeValue
public String getAttributeValue(net.sf.saxon.om.NamespaceUri namespace, String localPart)
Returns attribute value.- Parameters:
namespace
- namespacelocalPart
- 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
public AbstractNode getRoot()
Returns root.- Returns:
- root
-
iterateAxis
public net.sf.saxon.tree.iter.AxisIterator iterateAxis(int axisNumber)
Determines axis iteration algorithm. ThrowsUnsupportedOperationException
in case, when there is no axis iterator for given axisNumber.Reason of suppression for resource, IOResourceOpenedButNotSafelyClosed:
AxisIterator
implementsCloseable
interface, but none of the subclasses of theAxisIterator
class has non-emptyclose()
method.- Parameters:
axisNumber
- element fromAxisInfo
- Returns:
AxisIterator
object
-
getPrecedingSiblingsIterator
private net.sf.saxon.tree.iter.AxisIterator getPrecedingSiblingsIterator()
Returns preceding sibling axis iterator.Reason of suppression for resource, IOResourceOpenedButNotSafelyClosed:
AxisIterator
implementsCloseable
interface, but none of the subclasses of theAxisIterator
class has non-emptyclose()
method.- Returns:
- iterator
-
getFollowingSiblingsIterator
private net.sf.saxon.tree.iter.AxisIterator getFollowingSiblingsIterator()
Returns following sibling axis iterator.Reason of suppression for resource, IOResourceOpenedButNotSafelyClosed:
AxisIterator
implementsCloseable
interface, but none of the subclasses of theAxisIterator
class has non-emptyclose()
method.- Returns:
- iterator
-
getFollowingSiblings
private List<AbstractNode> getFollowingSiblings()
Returns following siblings of the current node.- Returns:
- siblings
-
getPrecedingSiblings
private List<AbstractNode> getPrecedingSiblings()
Returns preceding siblings of the current node.- Returns:
- siblings
-
getAttributeNode
private AttributeNode getAttributeNode()
Checks if token type supports@text
attribute, extracts its value, createsAttributeNode
object and returns it. Value can be accessed using@text
attribute.- Returns:
- attribute node if possible, otherwise the
null
value
-
throwUnsupportedOperationException
private static UnsupportedOperationException throwUnsupportedOperationException()
Returns UnsupportedOperationException exception.- Returns:
- UnsupportedOperationException exception
-
-