@Override public AxisIterator iterateAxis(byte axisNumber) { switch (axisNumber) { case Axis.DESCENDANT: return new Navigator.DescendantEnumeration(this, false, true); case Axis.DESCENDANT_OR_SELF: return new Navigator.DescendantEnumeration(this, true, true); case Axis.CHILD: return SingleNodeIterator.makeIterator(rootNode); default: return super.iterateAxis(axisNumber); } } }
switch (axisNumber) { case Axis.ANCESTOR: return new Navigator.AncestorEnumeration(this, false); case Axis.ANCESTOR_OR_SELF: return new Navigator.AncestorEnumeration(this, true); case Axis.ATTRIBUTE: return new AttributeAxisIterator(this); case Axis.CHILD: if (children == null) { return EmptyIterator.getInstance(); } else { return new NodeArrayIterator(children); return new Navigator.DescendantEnumeration(this, false, true); case Axis.DESCENDANT_OR_SELF: return new Navigator.DescendantEnumeration(this, true, true); case Axis.FOLLOWING: return new Navigator.FollowingEnumeration(this); case Axis.FOLLOWING_SIBLING: if (parent == null || siblingPosition == parent.children.length - 1) { return EmptyIterator.getInstance(); } else { return new NodeArrayIterator(parent.children, siblingPosition + 1, parent.children.length); return SingleNodeIterator.makeIterator(parent); case Axis.PRECEDING: return new Navigator.PrecedingEnumeration(this, false); case Axis.PRECEDING_SIBLING: if (parent == null || siblingPosition == 0) {
/** * Compares current object with specified for order. * @param nodeInfo another {@code NodeInfo} object * @return number representing order of current object to specified one */ @Override public int compareOrder(NodeInfo nodeInfo) { return getLocalPart().compareTo(nodeInfo.getLocalPart()); }
/** * Test whether the NameTest matches a given QName * * @param qname the QName to be matched * @return true if the name matches */ public boolean matches(StructuredQName qname) { return NameOfNode.makeName(origin).getStructuredQName().equals(qname); }
/** * Get the name as a string. * @return a string typically in the form "template p:my-template" or "function f:my-function#2" */ public String toString() { //noinspection UnnecessaryParentheses return StandardNames.getLocalName(kind) + " " + name.getDisplayName(); }
private void computeUriAndLocal() { if (uri == null || localName == null) { StructuredQName name = namePool.getUnprefixedQName(fingerprint); uri = name.getURI(); localName = name.getLocalPart(); } }
/** * Get the display form of a name (the QName), given its name code or fingerprint * * @param nameCode the integer name code or fingerprint of a name in the name pool * @return the corresponding lexical QName (if a fingerprint was supplied, this will * simply be the local name) */ public String getDisplayName(int nameCode) { return getStructuredQName(nameCode).getDisplayName(); }
/** * Get the Clark form of a name, given its name code or fingerprint * * @param nameCode the integer name code or fingerprint of a name in the name pool * @return the local name if the name is in the null namespace, or "{uri}local" * otherwise. The name is always interned. */ public String getClarkName(int nameCode) { return getUnprefixedQName(nameCode).getClarkName(); }
@Test public void testGetDeclaredNamespaces() { try { rootNode.getDeclaredNamespaces( new NamespaceBinding[] {new NamespaceBinding("prefix", "uri")}); fail("Exception is excepted"); } catch (UnsupportedOperationException ex) { assertEquals( "Invalid exception message", "Operation is not supported", ex.getMessage()); } }
@Test public void testGetParent() throws Exception { final String xpath = "//OBJBLOCK"; final List<NodeInfo> nodes = getXpathItems(xpath, rootNode); assertEquals("Invalid number of nodes", 1, nodes.size()); final AbstractNode parent = (AbstractNode) nodes.get(0).getParent(); assertEquals("Invalid token type", TokenTypes.CLASS_DEF, parent.getTokenType()); }
/** * Get the fingerprint of this name, allocating a new code from the namepool if necessary * * @param pool the NamePool used to allocate the name * @return a fingerprint for this name, newly allocated if necessary */ public int obtainFingerprint(NamePool pool) { if (fingerprint == -1) { fingerprint = pool.allocateFingerprint(getURI(), getLocalPart()); } return fingerprint; }
@Test public void testRootOfElementNode() throws Exception { final String xpath = "//OBJBLOCK"; final List<NodeInfo> nodes = getXpathItems(xpath, rootNode); assertEquals("Invalid number of nodes", 1, nodes.size()); final AbstractNode root = (AbstractNode) nodes.get(0).getRoot(); assertEquals("Invalid token type", TokenTypes.EOF, root.getTokenType()); assertTrue("Should return true, because selected node is RootNode", root instanceof RootNode); }
/** * Get a {@link net.sf.saxon.om.NamespaceBinding} whose (prefix, uri) pair are the prefix and URI of this * node name * * @return the corresponding NamespaceBinding */ public NamespaceBinding getNamespaceBinding() { return NamespaceBinding.makeNamespaceBinding(getPrefix(), getURI()); }
/** * Attempt to create a dynamic context on which to evaluate the {@link #xpathExpression}. * * @param elementNode the node on which to create the context; generally this node is the root node of the Saxon * Tree * @return the dynamic context on which to run the query * @throws XPathException if the supplied value does not conform to the required type of the * variable, when setting up the dynamic context; or if the supplied value contains a node that does not belong to * this Configuration (or another Configuration that shares the same namePool) */ private XPathDynamicContext createDynamicContext(final ElementNode elementNode) throws XPathException { final XPathDynamicContext dynamicContext = xpathExpression.createDynamicContext(elementNode); // Set variable values on the dynamic context for (final XPathVariable xpathVariable : xpathVariables) { final String variableName = xpathVariable.getVariableQName().getLocalName(); for (final Map.Entry<PropertyDescriptor<?>, Object> entry : super.properties.entrySet()) { if (variableName.equals(entry.getKey().name())) { final ValueRepresentation valueRepresentation = getRepresentation(entry.getKey(), entry.getValue()); dynamicContext.setVariable(xpathVariable, valueRepresentation); } } } return dynamicContext; }
var Raphael= function(listIterator) { listIterator.method(); }(new ListIterator());
/** * This implementation calls {@link #iterateAxis(byte)} to get an * {@link AxisIterator} which is then optionally filtered using * {@link AxisFilter}. * * {@inheritDoc} */ @Override public AxisIterator iterateAxis(byte axisNumber, NodeTest nodeTest) { AxisIterator axisIterator = iterateAxis(axisNumber); if (nodeTest != null) { axisIterator = new AxisFilter(axisIterator, nodeTest); } return axisIterator; }
/** * Convenience method to get the Configuration. Always returns the same result as {@code getTreeInfo().getConfiguration()} * @return the Configuration to which the tree belongs. The default implementation invokes * {@code getTreeInfo().getConfiguration()}. * @since 8.4 */ default Configuration getConfiguration() { return getTreeInfo().getConfiguration(); }
/** * Creates a new {@code RootNode} instance. * * @param detailAst reference to {@code DetailAST} */ public RootNode(DetailAST detailAst) { super(new GenericTreeInfo(Configuration.newConfiguration())); this.detailAst = detailAst; if (detailAst != null) { createChildren(); } }
@Override public void advance() { if (this.iterator.hasNext()) { Attribute attribute = this.iterator.next(); super.current = new AttributeNode(attribute, super.position()); } else { super.current = null; } } }