/** * 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) { int nodeKind = node.getNodeKind(); return (nodeKindMask & (1<<nodeKind)) != 0; }
/** * Determine the types of nodes to which this pattern applies. Used for optimisation. * For patterns that match nodes of several types, return Type.NODE * * @return the type of node matched by this pattern. e.g. Type.ELEMENT or Type.TEXT */ public int getPrimitiveType() { return origin.getNodeKind(); }
/** * 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; }
/** * Return the type of node. * * @return one of the values Node.ELEMENT, Node.TEXT, Node.ATTRIBUTE, etc. */ public int getNodeKind() { return node.getNodeKind(); }
/** * 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 matches(NodeInfo node) { return node.getNodeKind() == kind; }
/** * Get the kind of node. This will be a value such as Type.ELEMENT or Type.ATTRIBUTE * * @return an integer identifying the kind of node. These integer values are the * same as those used in the DOM * @see net.sf.saxon.type.Type */ public int getNodeKind() { return original.getNodeKind(); }
/** * Create a DocumentSender, which takes an input document tree and generates * a stream of events for a Receiver * @param top the document or element node to be turned into a stream of events */ public DocumentSender(NodeInfo top) { this.top = top; int kind = top.getNodeKind(); if (kind != Type.DOCUMENT && kind != Type.ELEMENT) { throw new IllegalArgumentException("DocumentSender can only handle document or element nodes"); } }
/** * 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 == origin || (node.getNodeKind() == origin.getNodeKind() && Navigator.haveSameName(node, origin)); }
public DocumentInfo(NodeInfo node) { if (node.getNodeKind() != Type.DOCUMENT) { throw new IllegalArgumentException("DocumentInfo must only be used for document nodes"); } this.node = node; this.parent = null; this.docWrapper = node.getTreeInfo(); }
/** * Get the corresponding {@link net.sf.saxon.type.UType}. A UType is a union of primitive item * types. * * @return the smallest UType that subsumes this item type */ public UType getUType() { return UType.fromTypeCode(origin.getNodeKind()); }
/** * Returns a hash code value for the object. */ public int hashCode() { return origin.getNodeKind() << 20 ^ origin.getURI().hashCode() ^ origin.getLocalPart().hashCode(); }
public NodeInfo next() { while (true) { NodeInfo next = base.next(); if (next == null) { return null; } if (!(next.getNodeKind() == Type.TEXT && next.getStringValueCS().length() == 0)) { return next; } } }
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); }
private static Predicate<? super XdmNode> expandedNamePredicate(String ns, String local) { return item -> { NodeInfo node = item.getUnderlyingNode(); return node.getNodeKind() == Type.ELEMENT && node.getLocalPart().equals(local) && node.getURI().equals(ns); }; }
private static boolean isIgnorable(NodeInfo node, int flags) { final int kind = node.getNodeKind(); if (kind == Type.COMMENT) { return (flags & INCLUDE_COMMENTS) == 0; } else if (kind == Type.PROCESSING_INSTRUCTION) { return (flags & INCLUDE_PROCESSING_INSTRUCTIONS) == 0; } else if (kind == Type.TEXT) { return ((flags & EXCLUDE_WHITESPACE_TEXT_NODES) != 0) && Whitespace.isWhite(node.getStringValueCS()); } return false; }
private static String showKind(Item item) { if (item instanceof NodeInfo && ((NodeInfo) item).getNodeKind() == Type.TEXT && Whitespace.isWhite(item.getStringValueCS())) { return "whitespace text() node"; } else { return Type.displayTypeName(item); } }
/** * 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. The default implementation calls the method * {@link #matches(int, NodeName, SchemaType)} * * @param node the node to be matched * @return true if the node test is satisfied by the supplied node, false otherwise */ public boolean matchesNode(/*@NotNull*/ NodeInfo node) { return matches(node.getNodeKind(), NameOfNode.makeName(node), node.getSchemaType()); }
/** * 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. The default implementation calls the method * {@link #matches(int, int, int)} * @param node the node to be matched */ public boolean matches(NodeInfo node) { return matches(node.getNodeKind(), node.getFingerprint(), node.getTypeAnnotation()); }
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); }
@Override protected boolean isIncludedInCopy(NodeInfo sourceNode) { switch (sourceNode.getNodeKind()) { case Type.ATTRIBUTE: case Type.NAMESPACE: return isIncludedInCopy(sourceNode.getParent()); default: return Navigator.isAncestorOrSelf(pivot, sourceNode) || Navigator.isAncestorOrSelf(sourceNode, pivot); } }