/** * 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); }
/** * 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 NodeIterator childIterator( NodeTest test, boolean reverse, NodePointer startWith) { return getValuePointer().childIterator(test, reverse, startWith); }
public NodeIterator childIterator(NodeTest test, boolean reverse, NodePointer startWith) { if (test instanceof NodeNameTest) { NodeNameTest nodeNameTest = (NodeNameTest) test; if (!nodeNameTest.isWildcard()) { String localName = nodeNameTest.getNodeName().getName(); String nameSpace = nodeNameTest.getNamespaceURI(); if (nameSpace == null) nameSpace = getNamespaceResolver().getNamespaceURI(""); return new AttributeNodeIterator(this, Types.typeName(nameSpace, localName)); } else { return new AttributeNodeIterator(this); } } if (test instanceof NodeTypeTest) { NodeTypeTest nodeTypeTest = (NodeTypeTest) test; if (nodeTypeTest.getNodeType() == Compiler.NODE_TYPE_NODE) { return new AttributeNodeIterator(this); } } return super.childIterator(test, reverse, startWith); }
/** * 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(); }
public NodeIterator attributeIterator(QName name) { return getValuePointer().attributeIterator(name); }
public NodePointer createPath(JXPathContext context, Object value) { if (actual) { setValue(value); return this; } NodePointer ptr = createPath(context); ptr.setValue(value); return ptr; }
public NodePointer createChild( JXPathContext context, QName name, int index, Object value) { Object collection = createCollection(context, index); ValueUtils.setValue(collection, index, value); NodePointer cl = (NodePointer) clone(); cl.setIndex(index); return cl; }
/** * 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; }
public NodeIterator namespaceIterator() { return getValuePointer().namespaceIterator(); }
/** * Returns the object the pointer points to; does not convert it * to a "canonical" type. Opens containers, properties etc and returns * the ultimate contents. * @return Object node */ public Object getNode() { return getValuePointer().getImmediateNode(); }
public void setIndex(int index) { if (this.index != index) { super.setIndex(index); value = UNINITIALIZED; } }
/** * Get a VariablePointer for the given variable name. * @param name variable name * @return NodePointer */ public NodePointer getVariablePointer(QName name) { return NodePointer.newNodePointer(name, VariablePointerFactory .contextWrapper(this), getLocale()); }
/** * Get the NamespaceResolver associated with this NodePointer. * @return NamespaceResolver */ public NamespaceResolver getNamespaceResolver() { if (namespaceResolver == null && parent != null) { namespaceResolver = parent.getNamespaceResolver(); } return namespaceResolver; }
public String getNamespaceURI() { if (namespaceURI == null) { namespaceURI = parent.getNamespaceURI(prefix); } return namespaceURI; }
/** * VariableContextWrapper factory method. * @param context the JXPathContext to wrap. * @return VariableContextWrapper. */ public static VariableContextWrapper contextWrapper(JXPathContext context) { return new VariableContextWrapper(context); }
public NodeIterator childIterator(NodeTest test, boolean reverse, NodePointer startWith) { if (test instanceof NodeNameTest) { NodeNameTest nodeNameTest = (NodeNameTest) test; if (!nodeNameTest.isWildcard()) { String localName = nodeNameTest.getNodeName().getName(); String nameSpace = nodeNameTest.getNamespaceURI(); if (nameSpace == null) nameSpace = getNamespaceResolver().getNamespaceURI(""); return new SingleFeatureTypeAttributeIterator( this, ((ComplexType) attType), Types.typeName(nameSpace, localName)); } else { return new FeatureTypeAttributeIterator(this, ((ComplexType) attType)); } } if (test instanceof NodeTypeTest) { NodeTypeTest nodeTypeTest = (NodeTypeTest) test; if (nodeTypeTest.getNodeType() == Compiler.NODE_TYPE_NODE) { return new FeatureTypeAttributeIterator(this, ((ComplexType) attType)); } } return super.childIterator(test, reverse, startWith); }
/** * Tests if this node matches the given test. Attribute 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 NodeIterator childIterator(NodeTest test, boolean reverse, NodePointer startWith) { if (test instanceof NodeNameTest) { NodeNameTest nodeNameTest = (NodeNameTest) test; if (!nodeNameTest.isWildcard()) { String localName = nodeNameTest.getNodeName().getName(); String nameSpace = nodeNameTest.getNamespaceURI(); if (nameSpace == null) nameSpace = getNamespaceResolver().getNamespaceURI(""); return new SingleFeatureTypeAttributeIterator( this, featureType, Types.typeName(nameSpace, localName)); } else { return new FeatureTypeAttributeIterator(this, featureType); } } if (test instanceof NodeTypeTest) { NodeTypeTest nodeTypeTest = (NodeTypeTest) test; if (nodeTypeTest.getNodeType() == Compiler.NODE_TYPE_NODE) { return new FeatureTypeAttributeIterator(this, featureType); } } return super.childIterator(test, reverse, startWith); } }