@Override protected NodeIterator getElementNodeIterator(NodePointer elementPointer) { return elementPointer.childIterator(test, false, null); } }
/** * Returns the object the pointer points to; does not convert it * to a "canonical" type. * @return Object node value * @deprecated 1.1 Please use getNode() */ public Object getNodeValue() { return getNode(); }
@Override protected NodeIterator getElementNodeIterator(NodePointer elementPointer) { return elementPointer.attributeIterator(name); } }
/** * Returns a NodeIterator that iterates over all attributes of the current * node matching the supplied node name (could have a wildcard). * May return null if the object does not support the attributes. * @param qname the attribute name to test * @return NodeIterator */ public NodeIterator attributeIterator(QName qname) { NodePointer valuePointer = getValuePointer(); return valuePointer == null || valuePointer == this ? null : valuePointer.attributeIterator(qname); }
/** * By default, returns <code>getNode()</code>, can be overridden to * return a "canonical" value, like for instance a DOM element should * return its string value. * @return Object value */ public Object getValue() { NodePointer valuePointer = getValuePointer(); if (valuePointer != this) { return valuePointer.getValue(); } // Default behavior is to return the same as getNode() return getNode(); }
/** * Allocates a PropertyIterator. */ private void prepare() { NodePointer parent = parentContext.getCurrentNodePointer(); if (parent == null) { return; } NodePointer useParent = startFromParentLocation ? parent.getParent() : parent; iterator = useParent.childIterator(nodeTest, reverse, startFromParentLocation ? parent : null); } }
@Override public NodePointer createPath(JXPathContext context, Object value) { NodePointer newParent = parent.createPath(context); if (isAttribute()) { NodePointer pointer = newParent.createAttribute(context, getName()); pointer.setValue(value); return pointer; } if (parent instanceof NullPointer && parent.equals(newParent)) { throw createBadFactoryException(context.getFactory()); } if (newParent instanceof EStructuralFeatureOwnerPointer) { EStructuralFeatureOwnerPointer pop = (EStructuralFeatureOwnerPointer) newParent; newParent = pop.getPropertyPointer(); } return newParent.createChild(context, getName(), index, value); }
/** * Tests if this node matches the given test. Configuration nodes are text * nodes, too because they can contain a value. * * @param test the test object * @return a flag if this node corresponds to the test */ @Override public boolean testNode(final NodeTest test) { if (test instanceof NodeTypeTest && ((NodeTypeTest) test).getNodeType() == Compiler.NODE_TYPE_TEXT) { return true; } return super.testNode(test); }
public String asPath() { return parent == null ? "/" : parent.asPath(); } }
public NodePointer createPath(JXPathContext context) { NodePointer newParent = parent.createPath(context); if (isAttribute()) { return newParent.createAttribute(context, getName()); } if (parent instanceof NullPointer && parent.equals(newParent)) { throw createBadFactoryException(context.getFactory()); } // Consider these two use cases: // 1. The parent pointer of NullPropertyPointer is // a PropertyOwnerPointer other than NullPointer. When we call // createPath on it, it most likely returns itself. We then // take a PropertyPointer from it and get the PropertyPointer // to expand the collection for the corresponding property. // // 2. The parent pointer of NullPropertyPointer is a NullPointer. // When we call createPath, it may return a PropertyOwnerPointer // or it may return anything else, like a DOMNodePointer. // In the former case we need to do exactly what we did in use // case 1. In the latter case, we simply request that the // non-property pointer expand the collection by itself. if (newParent instanceof PropertyOwnerPointer) { PropertyOwnerPointer pop = (PropertyOwnerPointer) newParent; newParent = pop.getPropertyPointer(); } return newParent.createChild(context, getName(), getIndex()); }
public boolean nextNode() { // Each set contains exactly one node: the parent if (setStarted) { return false; } setStarted = true; NodePointer thisLocation = parentContext.getCurrentNodePointer(); currentNodePointer = thisLocation.getImmediateParentPointer(); while (currentNodePointer != null && currentNodePointer.isContainer()) { currentNodePointer = currentNodePointer.getImmediateParentPointer(); } if (currentNodePointer != null && currentNodePointer.testNode(nodeTest)) { position++; return true; } return false; } }
/** * Called directly by JXPathContext. Must create path and * set value. * @param context the owning JXPathContext * @param value the new value to set * @return created NodePointer */ public NodePointer createPath(JXPathContext context, Object value) { setValue(value); return this; }
/** * Compares two child node pointers. * * @param pointer1 one pointer * @param pointer2 another pointer * @return a flag, which pointer should be sorted first */ @Override public int compareChildNodePointers(final NodePointer pointer1, final NodePointer pointer2) { final Object node1 = pointer1.getBaseValue(); final Object node2 = pointer2.getBaseValue(); // sort based on the occurrence in the sub node list for (final T child : getNodeHandler().getChildren(node)) { if (child == node1) { return -1; } else if (child == node2) { return 1; } } return 0; // should not happen }
public boolean nextNode() { if (!setStarted) { setStarted = true; currentNodePointer = parentContext.getCurrentNodePointer(); if (includeSelf && currentNodePointer.testNode(nodeTest)) { position++; return true; } } while (true) { currentNodePointer = currentNodePointer.getImmediateParentPointer(); if (currentNodePointer == null) { return false; } if (currentNodePointer.testNode(nodeTest)) { position++; return true; } } } }
@Override public NodePointer createPath(JXPathContext context) { return parent.createChild(context, null, index); }
/** * Returns true if the pointer has an attribute called "name" and * its value is equal to the supplied string. * @param pointer input pointer * @param name name to check * @return boolean */ private static boolean isNameAttributeEqual( NodePointer pointer, String name) { NodeIterator it = pointer.attributeIterator(QNAME_NAME); return it != null && it.setPosition(1) && name.equals(it.getNodePointer().getValue()); }
int depth2) { if (depth1 < depth2) { int r = compareNodePointers(p1, depth1, p2.parent, depth2 - 1); return r == 0 ? -1 : r; int r = compareNodePointers(p1.parent, depth1 - 1, p2, depth2); return r == 0 ? 1 : r; + p1 + "' and '" + p2 + "'"); int r = compareNodePointers(p1.parent, depth1 - 1, p2.parent, depth2 - 1); return r == 0 ? p1.parent.compareChildNodePointers(p1, p2) : r;
@Override public int compareChildNodePointers( NodePointer pointer1, NodePointer pointer2) { return getValuePointer().compareChildNodePointers(pointer1, pointer2); }
public NodePointer createAttribute(JXPathContext context, QName name) { if (!(node instanceof Element)) { return super.createAttribute(context, name); } Element element = (Element) node; String prefix = name.getPrefix(); if (prefix != null) { String ns = null; NamespaceResolver nsr = getNamespaceResolver(); if (nsr != null) { ns = nsr.getNamespaceURI(prefix); } if (ns == null) { throw new JXPathException( "Unknown namespace prefix: " + prefix); } element.setAttributeNS(ns, name.toString(), ""); } else { if (!element.hasAttribute(name.getName())) { element.setAttribute(name.getName(), ""); } } NodeIterator it = attributeIterator(name); it.setPosition(1); return it.getNodePointer(); }
public NodePointer createPath(JXPathContext context, Object value) { NodePointer newParent = parent.createPath(context); if (isAttribute()) { NodePointer pointer = newParent.createAttribute(context, getName()); pointer.setValue(value); return pointer; } if (parent instanceof NullPointer && parent.equals(newParent)) { throw createBadFactoryException(context.getFactory()); } if (newParent instanceof PropertyOwnerPointer) { PropertyOwnerPointer pop = (PropertyOwnerPointer) newParent; newParent = pop.getPropertyPointer(); } return newParent.createChild(context, getName(), index, value); }