/** * Get the property pointer for this. * @return PropertyPointer */ public PropertyPointer getPropertyPointer() { return new NullPropertyPointer(this); }
/** * Create a "bad factory" JXPathAbstractFactoryException for the specified AbstractFactory. * @param factory AbstractFactory * @return JXPathAbstractFactoryException */ private JXPathAbstractFactoryException createBadFactoryException(AbstractFactory factory) { return new JXPathAbstractFactoryException("Factory " + factory + " reported success creating object for path: " + asPath() + " but object was null. Terminating to avoid stack recursion."); } }
public NodePointer createChild(JXPathContext context, QName name, int index, Object value) { return createPath(context).createChild(context, name, index, value); }
public String asPath() { if (!byNameAttribute) { return super.asPath(); } StringBuffer buffer = new StringBuffer(); buffer.append(getImmediateParentPointer().asPath()); buffer.append("[@name='"); buffer.append(escape(getPropertyName())); buffer.append("']"); if (index != WHOLE_COLLECTION) { buffer.append('[').append(index + 1).append(']'); } return buffer.toString(); }
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()); }
new NullPropertyPointer( propertyNodePointer.getImmediateParentPointer()); npp.setPropertyName(propertyNodePointer.getPropertyName()); npp.setIndex(propertyNodePointer.getIndex()); return npp.getValuePointer();
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); }
NullPropertyPointer pointer = new NullPropertyPointer(parent); QName name = ((NodeNameTest) step.getNodeTest()).getNodeName(); pointer.setPropertyName(name.toString()); pointer.setAttribute(axis == Compiler.AXIS_ATTRIBUTE); parent = pointer;
String key = keyFromPredicate(context, predicate); parent = valuePointer(parent); NullPropertyPointer pointer = new NullPropertyPointer(parent); pointer.setNameAttributeValue(key); parent = pointer;
public boolean isCollection() { return getIndex() != WHOLE_COLLECTION; }
public NodePointer getValuePointer() { return new NullPointer(this, new QName(getPropertyName())); }
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 PropertyOwnerPointer && ((PropertyOwnerPointer) parent) .isDynamicPropertyDeclarationSupported()) { // If the parent property owner can create // a property automatically - let it do so PropertyPointer propertyPointer = ((PropertyOwnerPointer) parent).getPropertyPointer(); propertyPointer.setPropertyName(propertyName); propertyPointer.setValue(value); } else { throw new JXPathInvalidAccessException( "Cannot set property " + asPath() + ", path does not match a changeable location"); } }
public PropertyPointer getPropertyPointer() { return new NullPropertyPointer(this); }
public NodePointer createChild(JXPathContext context, QName name, int index) { return createPath(context).createChild(context, name, index); }