/** * 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 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()); }
/** * Generate an equivalent NameTest * @return a NameTest that matches the same node kind and name */ public NameTest getEquivalentNameTest() { return new NameTest(origin.getNodeKind(), origin.getURI(), origin.getLocalPart(), origin.getConfiguration().getNamePool()); }
/** * Get the fingerprint required */ public int getFingerprint() { if (origin.hasFingerprint()) { return origin.getFingerprint(); } else { NamePool pool = origin.getConfiguration().getNamePool(); return pool.allocateFingerprint(origin.getURI(), origin.getLocalPart()); } }
/** * Returns a hash code value for the object. */ public int hashCode() { return origin.getNodeKind() << 20 ^ origin.getURI().hashCode() ^ origin.getLocalPart().hashCode(); }
public String getAttributeValue(String uri, String local) { for (Iterator iter = startElementEvent.iterateAttributes(); iter.hasNext(); ) { NodeInfo att = (NodeInfo)iter.next(); if (att.getURI().equals(uri) && att.getLocalPart().equals(local)) { return att.getStringValue(); } } return null; }
/** * Get the character data of a Text or Comment node. * DOM method. */ public String getData() { return node.getStringValue(); }
public BooleanValue call(XPathContext context, Sequence[] arguments) throws XPathException { NodeInfo val = (NodeInfo) arguments[0].head(); NodeInfo parent = val.getParent(); return BooleanValue.get( parent == null || parent.getNodeKind() == Type.DOCUMENT || val.getDeclaredNamespaces(NamespaceBinding.EMPTY_ARRAY).length > 0); }
/** * Return an iteration over the nodes reached by the given axis from this node * * @param axisNumber the axis to be used * @return a SequenceIterator that scans the nodes reached by the axis in turn. */ /*@Nullable*/ public AxisIterator iterateAxis(byte axisNumber) { return new WrappingIterator(node.iterateAxis(axisNumber), this, null); }
/** * Get the System ID for the node. * * @return the System Identifier of the entity in the source document * containing the node, or null if not known. Note this is not the * same as the base URI: the base URI can be modified by xml:base, but * the system ID cannot. */ /*@Nullable*/ public String getSystemId() { return element.getSystemId(); }
/** * Test whether this node test is satisfied by a given node. This alternative * method is used in the case of nodes where calculating the fingerprint is expensive, * for example DOM or JDOM nodes. * * @param node the node to be matched */ public boolean matchesNode(NodeInfo node) { return localName.equals(node.getLocalPart()) && nodeKind == node.getNodeKind(); }
public AttributeLocation(NodeInfo element, StructuredQName attributeName) { this.systemId = element.getSystemId(); this.lineNumber = element.getLineNumber(); this.columnNumber = element.getColumnNumber(); this.elementName = Navigator.getNodeName(element); this.attributeName = attributeName; }
public QName getAttributeName(int i) { if (currentStaxEvent != START_ELEMENT) { throw new IllegalStateException(""+currentStaxEvent); } NodeInfo att = startElementEvent.getAttribute(i); return new QName(att.getURI(), att.getLocalPart(), att.getPrefix()); }
/** * Evaluate as an expression. We rely on the fact that when these instructions * are generated by XQuery, there will always be a valueExpression to evaluate * the content */ public Item evaluateItem(XPathContext context) throws XPathException { NodeInfo node = (NodeInfo)super.evaluateItem(context); String prefix = node.getLocalPart(); String uri = node.getStringValue(); checkPrefixAndUri(prefix, uri, context); return node; }
private boolean isPreserved(NodeInfo nextRealNode) { if (nextRealNode.getNodeKind() != Type.TEXT) { return true; } NodeInfo actualParent = parent == null ? nextRealNode.getParent() : parent.node; return isPreservedNode(nextRealNode, (SpaceStrippedDocument)docWrapper, actualParent); }
/** * Get the display name of this node. For elements and attributes this is [prefix:]localname. * For unnamed nodes, it is an empty string. * * @return The display name of this node. For a node with no name, return * an empty string. */ public String getDisplayName() { return original.getDisplayName(); }
@Override public void markNamespaceNode(NodeInfo origin) { NodeInfo element = builder.getCurrentParentNode(); NamePool pool = builder.getConfiguration().getNamePool(); String prefix = origin.getLocalPart(); markedNode = element.iterateAxis( AxisInfo.NAMESPACE, new NameTest(Type.NAMESPACE, "", prefix, pool)).next(); mark = -1; }
/** * Get the base URI for the node. Default implementation for child nodes gets * the base URI of the parent node. */ public String getBaseURI() { return node.getBaseURI(); }
/** * Test whether this node test is satisfied by a given node. This alternative * method is used in the case of nodes where calculating the fingerprint is expensive, * for example DOM or JDOM nodes. * * @param node the node to be matched */ public boolean matchesNode(NodeInfo node) { return node.getNodeKind() == kind; }
/** * Create an XML resource using a specific node * * @param doc the node in question (usually but not necessarily a document node) */ public XmlResource(NodeInfo doc) { this.config = doc.getConfiguration(); this.doc = doc; }