Class ElementNode
java.lang.Object
com.puppycrawl.tools.checkstyle.xpath.AbstractNode
com.puppycrawl.tools.checkstyle.xpath.ElementNode
- All Implemented Interfaces:
Source
,SourceLocator
,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
Represents element node of Xpath-tree.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final AttributeNode
Holder value for lazy creation of attribute node.private AttributeNode
The text attribute node.private final int
Depth of the node.private final DetailAST
The ast node.private static final AbstractNode[]
Constant for optimization.private final int
Represents index among siblings.private final AbstractNode
The parent of the current node.private final AbstractNode
The root node.private static final String
String literal for text attribute.Fields inherited from interface net.sf.saxon.om.NodeInfo
IS_DTD_TYPE, IS_NILLED
-
Constructor Summary
ConstructorsConstructorDescriptionElementNode
(AbstractNode root, AbstractNode parent, DetailAST detailAst, int depth, int indexAmongSiblings) Creates a newElementNode
instance. -
Method Summary
Modifier and TypeMethodDescriptionprivate 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 List
<AbstractNode> Iterates children of the current node and recursively creates new Xpath-nodes.private AttributeNode
Checks if token type supports@text
attribute, extracts its value, createsAttributeNode
object and returns it.getAttributeValue
(String namespace, String localPart) Returns attribute value.int
Returns column number.int
getDepth()
Getter method for node depth.private List
<AbstractNode> Returns following siblings of the current node.private net.sf.saxon.tree.iter.AxisIterator
Returns following sibling axis iterator.int
Returns line number.Returns local part.int
Returns type of the node.net.sf.saxon.om.NodeInfo
Returns parent.private List
<AbstractNode> Returns preceding siblings of the current node.private net.sf.saxon.tree.iter.AxisIterator
Returns preceding sibling axis iterator.net.sf.saxon.om.NodeInfo
getRoot()
Returns root.int
Getter method for token type.Returns underlying node.boolean
Determine whether the node has any children.net.sf.saxon.tree.iter.AxisIterator
iterateAxis
(int axisNumber) Determines axis iteration algorithm.private static UnsupportedOperationException
Returns UnsupportedOperationException exception.Methods inherited from class com.puppycrawl.tools.checkstyle.xpath.AbstractNode
atomize, copy, generateId, getAllNamespaces, getBaseURI, getChildren, getConfiguration, getDeclaredNamespaces, getDisplayName, getFingerprint, getPrefix, getPublicId, getSchemaType, getStringValue, getStringValueCS, getSystemId, getTreeInfo, 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
Methods inherited from interface net.sf.saxon.om.NodeInfo
attributes, children, children, equals, getGenre, hashCode, toShortString
Methods 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. -
detailAst
The ast node. -
depth
private final int depthDepth of the node. -
indexAmongSiblings
private final int indexAmongSiblingsRepresents index among siblings. -
attributeNode
The text attribute node.
-
-
Constructor Details
-
ElementNode
public ElementNode(AbstractNode root, AbstractNode parent, DetailAST detailAst, int depth, int indexAmongSiblings) Creates a newElementNode
instance.- Parameters:
root
-Node
root of the treeparent
-Node
parent of the current nodedetailAst
- reference toDetailAST
depth
- the current node depth in the hierarchyindexAmongSiblings
- the current node index among the parent children nodes
-
-
Method Details
-
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
-
createChildren
Iterates children of the current node and recursively creates new Xpath-nodes.- Specified by:
createChildren
in classAbstractNode
- Returns:
- children list
-
hasChildNodes
public boolean hasChildNodes()Determine whether the node has any children.- Returns:
true
is the node has any children.
-
getAttributeValue
Returns attribute value. ThrowsUnsupportedOperationException
in case, when name of the attribute is not equal to 'text'.- Parameters:
namespace
- namespacelocalPart
- actual name of the attribute- Returns:
- attribute value
-
getLocalPart
Returns local part.- Returns:
- local part
-
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 net.sf.saxon.om.NodeInfo 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
-
getLineNumber
public int getLineNumber()Returns line number.- Returns:
- line number
-
getColumnNumber
public int getColumnNumber()Returns column number.- Returns:
- column number
-
getTokenType
public int getTokenType()Getter method for token type.- Specified by:
getTokenType
in classAbstractNode
- Returns:
- token type
-
getUnderlyingNode
Returns underlying node.- Specified by:
getUnderlyingNode
in classAbstractNode
- Returns:
- underlying node
-
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
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, createsAttributeNode
object and returns it. Value can be accessed using@text
attribute.- Returns:
- attribute node if possible, otherwise the
null
value
-
throwUnsupportedOperationException
Returns UnsupportedOperationException exception.- Returns:
- UnsupportedOperationException exception
-