@Override public String asPath() { if (id != null) { return "id(" + id + ")"; } return parent == null ? "null()" : super.asPath(); }
@Override public NodeIterator childIterator(NodeTest test, boolean reverse, NodePointer startWith) { if (test == null) { return createNodeIterator(null, reverse, startWith); } if (test instanceof NodeNameTest) { NodeNameTest nodeNameTest = (NodeNameTest) test; QName testName = nodeNameTest.getNodeName(); if (isValidProperty(testName)) { return createNodeIterator(nodeNameTest.isWildcard() ? null : testName.toString(), reverse, startWith); } return null; } return test instanceof NodeTypeTest && ((NodeTypeTest) test).getNodeType() == Compiler.NODE_TYPE_NODE ? createNodeIterator(null, reverse, startWith) : null; }
@Override public Object getImmediateNode() { if (value == UNINITIALIZED) { value = index == WHOLE_COLLECTION ? ValueUtils.getValue(getBaseValue()) : ValueUtils.getValue(getBaseValue(), index); } return value; }
@Override public void setValue(Object value) { if (parent == null || parent.isContainer()) { throw new JXPathInvalidAccessException( "Cannot set property " + asPath() + ", the target object is null"); } if (parent instanceof EStructuralFeatureOwnerPointer && ((EStructuralFeatureOwnerPointer) parent) .isDynamicPropertyDeclarationSupported()) { // If the parent property owner can create // a property automatically - let it do so EStructuralFeaturePointer propertyPointer = ((EStructuralFeatureOwnerPointer) parent).getPropertyPointer(); propertyPointer.setPropertyName(propertyName); propertyPointer.setValue(value); } else { throw new JXPathInvalidAccessException( "Cannot set property " + asPath() + ", path does not match a changeable location"); } }
@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); }
/** * Learn whether <code>name</code> is a valid child name for this PropertyOwnerPointer. * @param name the QName to test * @return <code>true</code> if <code>QName</code> is a valid property name. * @since JXPath 1.3 */ public boolean isValidProperty(QName name) { return isDefaultNamespace(name.getPrefix()); }
@Override public void setValue(Object value) { if (parent == null || parent.isContainer()) { throw new JXPathInvalidAccessException( "Cannot set property " + asPath() + ", the target object is null"); } if (parent instanceof EStructuralFeatureOwnerPointer && ((EStructuralFeatureOwnerPointer) parent) .isDynamicPropertyDeclarationSupported()) { // If the parent property owner can create // a property automatically - let it do so EStructuralFeaturePointer propertyPointer = ((EStructuralFeatureOwnerPointer) parent).getPropertyPointer(); propertyPointer.setPropertyName(propertyName); propertyPointer.setValue(value); } else { throw new JXPathInvalidAccessException( "Cannot set property " + asPath() + ", path does not match a changeable location"); } }
@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); }
/** * Learn whether <code>name</code> is a valid child name for this PropertyOwnerPointer. * @param name the QName to test * @return <code>true</code> if <code>QName</code> is a valid property name. * @since JXPath 1.3 */ public boolean isValidProperty(QName name) { return isDefaultNamespace(name.getPrefix()); }
@Override public NodeIterator childIterator(NodeTest test, boolean reverse, NodePointer startWith) { if (test == null) { return createNodeIterator(null, reverse, startWith); } if (test instanceof NodeNameTest) { NodeNameTest nodeNameTest = (NodeNameTest) test; QName testName = nodeNameTest.getNodeName(); if (isValidProperty(testName)) { return createNodeIterator(nodeNameTest.isWildcard() ? null : testName.toString(), reverse, startWith); } return null; } return test instanceof NodeTypeTest && ((NodeTypeTest) test).getNodeType() == Compiler.NODE_TYPE_NODE ? createNodeIterator(null, reverse, startWith) : null; }
@Override 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 EStructuralFeatureOwnerPointer) { EStructuralFeatureOwnerPointer pop = (EStructuralFeatureOwnerPointer) newParent; newParent = pop.getPropertyPointer(); } return newParent.createChild(context, getName(), getIndex()); }
@Override public String asPath() { if (id != null) { return "id(" + id + ")"; } return parent == null ? "null()" : super.asPath(); }
@Override public Object getImmediateNode() { if (value == UNINITIALIZED) { value = index == WHOLE_COLLECTION ? ValueUtils.getValue(getBaseValue()) : ValueUtils.getValue(getBaseValue(), index); } return value; }
@Override 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 EStructuralFeatureOwnerPointer) { EStructuralFeatureOwnerPointer pop = (EStructuralFeatureOwnerPointer) newParent; newParent = pop.getPropertyPointer(); } return newParent.createChild(context, getName(), getIndex()); }
public String asPath() { if (parent != null) { return super.asPath();
NodePointer startWith) { propertyNodePointer = (EStructuralFeaturePointer) pointer.getPropertyPointer().clone(); this.name = name; this.reverse = reverse;
public String asPath() { if (parent != null) { return super.asPath();
NodePointer startWith) { propertyNodePointer = (EStructuralFeaturePointer) pointer.getPropertyPointer().clone(); this.name = name; this.reverse = reverse;