Class ElementNode
- java.lang.Object
-
- com.puppycrawl.tools.checkstyle.xpath.AbstractNode
-
- com.puppycrawl.tools.checkstyle.xpath.ElementNode
-
- All Implemented Interfaces:
javax.xml.transform.Source,javax.xml.transform.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,org.xml.sax.Locator
public class ElementNode extends AbstractNode
Represents element node of Xpath-tree.
-
-
Field Summary
Fields Modifier and Type Field Description private static AttributeNodeATTRIBUTE_NODE_UNINITIALIZEDHolder value for lazy creation of attribute node.private AttributeNodeattributeNodeThe text attribute node.private intdepthDepth of the node.private DetailASTdetailAstThe ast node.private static AbstractNode[]EMPTY_ABSTRACT_NODE_ARRAYConstant for optimization.private intindexAmongSiblingsRepresents index among siblings.private AbstractNodeparentThe parent of the current node.private AbstractNoderootThe root node.private static java.lang.StringTEXT_ATTRIBUTE_NAMEString literal for text attribute.
-
Constructor Summary
Constructors Constructor Description ElementNode(AbstractNode root, AbstractNode parent, DetailAST detailAst, int depth, int indexAmongSiblings)Creates a newElementNodeinstance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static intcompareCommonAncestorChildrenOrder(net.sf.saxon.om.NodeInfo first, net.sf.saxon.om.NodeInfo second)Walks up the hierarchy until a common ancestor is found.intcompareOrder(net.sf.saxon.om.NodeInfo other)Compares current object with specified for order.protected java.util.List<AbstractNode>createChildren()Iterates children of the current node and recursively creates new Xpath-nodes.private AttributeNodegetAttributeNode()Checks if token type supports@textattribute, extracts its value, createsAttributeNodeobject and returns it.java.lang.StringgetAttributeValue(java.lang.String namespace, java.lang.String localPart)Returns attribute value.intgetColumnNumber()Returns column number.intgetDepth()Getter method for node depth.private java.util.List<AbstractNode>getFollowingSiblings()Returns following siblings of the current node.private net.sf.saxon.tree.iter.AxisIteratorgetFollowingSiblingsIterator()Returns following sibling axis iterator.intgetLineNumber()Returns line number.java.lang.StringgetLocalPart()Returns local part.intgetNodeKind()Returns type of the node.net.sf.saxon.om.NodeInfogetParent()Returns parent.private java.util.List<AbstractNode>getPrecedingSiblings()Returns preceding siblings of the current node.private net.sf.saxon.tree.iter.AxisIteratorgetPrecedingSiblingsIterator()Returns preceding sibling axis iterator.net.sf.saxon.om.NodeInfogetRoot()Returns root.intgetTokenType()Getter method for token type.DetailASTgetUnderlyingNode()Returns underlying node.booleanhasChildNodes()Determine whether the node has any children.net.sf.saxon.tree.iter.AxisIteratoriterateAxis(int axisNumber)Determines axis iteration algorithm.private static java.lang.UnsupportedOperationExceptionthrowUnsupportedOperationException()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
-
-
-
-
Field Detail
-
TEXT_ATTRIBUTE_NAME
private static final java.lang.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
-
ElementNode
public ElementNode(AbstractNode root, AbstractNode parent, DetailAST detailAst, int depth, int indexAmongSiblings)
Creates a newElementNodeinstance.- Parameters:
root-Noderoot of the treeparent-Nodeparent of the current nodedetailAst- reference toDetailASTdepth- the current node depth in the hierarchyindexAmongSiblings- the current node index among the parent children nodes
-
-
Method Detail
-
compareOrder
public int compareOrder(net.sf.saxon.om.NodeInfo other)
Compares current object with specified for order.- Parameters:
other- anotherNodeInfoobject- 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-NodeInfoto comparesecond-NodeInfoto compare- Returns:
- the value
0iffirst == second; a value less than0iffirstshould be first; a value greater than0ifsecondshould be first.
-
getDepth
public int getDepth()
Getter method for node depth.- Specified by:
getDepthin classAbstractNode- Returns:
- depth
-
createChildren
protected java.util.List<AbstractNode> createChildren()
Iterates children of the current node and recursively creates new Xpath-nodes.- Specified by:
createChildrenin classAbstractNode- Returns:
- children list
-
hasChildNodes
public boolean hasChildNodes()
Determine whether the node has any children.- Returns:
trueis the node has any children.
-
getAttributeValue
public java.lang.String getAttributeValue(java.lang.String namespace, java.lang.String localPart)
Returns attribute value. ThrowsUnsupportedOperationExceptionin case, when name of the attribute is not equal to 'text'.- Parameters:
namespace- namespacelocalPart- actual name of the attribute- Returns:
- attribute value
-
getLocalPart
public java.lang.String 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. ThrowsUnsupportedOperationExceptionin case, when there is no axis iterator for given axisNumber.Reason of suppression for resource, IOResourceOpenedButNotSafelyClosed:
AxisIteratorimplementsCloseableinterface, but none of the subclasses of theAxisIteratorclass has non-emptyclose()method.- Parameters:
axisNumber- element fromAxisInfo- Returns:
AxisIteratorobject
-
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:
getTokenTypein classAbstractNode- Returns:
- token type
-
getUnderlyingNode
public DetailAST getUnderlyingNode()
Returns underlying node.- Specified by:
getUnderlyingNodein classAbstractNode- Returns:
- underlying node
-
getPrecedingSiblingsIterator
private net.sf.saxon.tree.iter.AxisIterator getPrecedingSiblingsIterator()
Returns preceding sibling axis iterator.Reason of suppression for resource, IOResourceOpenedButNotSafelyClosed:
AxisIteratorimplementsCloseableinterface, but none of the subclasses of theAxisIteratorclass 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:
AxisIteratorimplementsCloseableinterface, but none of the subclasses of theAxisIteratorclass has non-emptyclose()method.- Returns:
- iterator
-
getFollowingSiblings
private java.util.List<AbstractNode> getFollowingSiblings()
Returns following siblings of the current node.- Returns:
- siblings
-
getPrecedingSiblings
private java.util.List<AbstractNode> getPrecedingSiblings()
Returns preceding siblings of the current node.- Returns:
- siblings
-
getAttributeNode
private AttributeNode 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
-
throwUnsupportedOperationException
private static java.lang.UnsupportedOperationException throwUnsupportedOperationException()
Returns UnsupportedOperationException exception.- Returns:
- UnsupportedOperationException exception
-
-