public NodePointer createPath(JXPathContext context) { if (getImmediateNode() == null) { AbstractFactory factory = getAbstractFactory(context); int inx = (index == WHOLE_COLLECTION ? 0 : index); boolean success = factory.createObject( context, this, getBean(), getPropertyName(), inx); if (!success) { throw new JXPathAbstractFactoryException("Factory " + factory + " could not create an object for path: " + asPath()); } } return this; }
public NodePointer createChild( JXPathContext context, QName name, int index, Object value) { PropertyPointer prop = (PropertyPointer) clone(); if (name != null) { prop.setPropertyName(name.toString()); } prop.setIndex(index); return prop.createPath(context, value); }
public int hashCode() { return getImmediateParentPointer().hashCode() + propertyIndex + index; }
public NodePointer createPath(JXPathContext context, Object value) { // If neccessary, expand collection if (index != WHOLE_COLLECTION && index >= getLength()) { createPath(context); } setValue(value); return this; }
/** * Returns a NodePointer that can be used to access the currently * selected property value. * @return NodePointer */ public NodePointer getImmediateValuePointer() { return NodePointer.newChildNodePointer( (NodePointer) this.clone(), getName(), getImmediateNode()); }
return propertyNodePointer.getValuePointer(); propertyNodePointer.getImmediateParentPointer()); npp.setPropertyName(propertyNodePointer.getPropertyName()); npp.setIndex(propertyNodePointer.getIndex()); return npp.getValuePointer();
public boolean setPosition(int position) { if (nameTestExpression == null) { return setPositionStandard(position); } else { if (dynamicPropertyPointer == null && !setupDynamicPropertyPointer()) { return setPositionStandard(position); } if (position < 1 || position > dynamicPropertyPointer.getLength()) { return false; } dynamicPropertyPointer.setIndex(position - 1); return true; } }
NodePointer startWith) { propertyNodePointer = (PropertyPointer) pointer.getPropertyPointer().clone(); this.name = name; this.reverse = reverse; ((PropertyPointer) startWith).getPropertyIndex(); this.startIndex = startWith.getIndex(); if (this.startIndex == NodePointer.WHOLE_COLLECTION) {
public Object getImmediateNode() { if (value == UNINITIALIZED) { value = index == WHOLE_COLLECTION ? ValueUtils.getValue(getBaseValue()) : ValueUtils.getValue(getBaseValue(), index); } return value; }
/** * Computes length for the current pointer - ignores any exceptions. * @return length */ private int getLength() { int length; try { length = propertyNodePointer.getLength(); // TBD: cache length } catch (Throwable t) { // @todo: should this exception be reported in any way? length = 0; } return length; } }
public NodePointer createPath(JXPathContext context) { if (getImmediateNode() == null) { super.createPath(context); baseValue = UNINITIALIZED; value = UNINITIALIZED; } return this; }
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(); }
/** * Used for an optimized access to dynamic properties using the * "map[@name = 'name']" syntax * @return whether valid */ private boolean setupDynamicPropertyPointer() { if (nameTestExpression == null) { return false; } NodePointer parent = parentContext.getCurrentNodePointer(); if (parent == null) { return false; } parent = parent.getValuePointer(); if (!(parent instanceof PropertyOwnerPointer)) { return false; } dynamicPropertyPointer = (PropertyPointer) ((PropertyOwnerPointer) parent) .getPropertyPointer() .clone(); return true; }
public boolean isCollection() { Object value = getBaseValue(); return value != null && ValueUtils.isCollection(value); }
public NodePointer createChild( JXPathContext context, QName name, int index) { PropertyPointer prop = (PropertyPointer) clone(); if (name != null) { prop.setPropertyName(name.toString()); } prop.setIndex(index); return prop.createPath(context); }
/** * If the property contains a collection, then the length of that * collection, otherwise - 1. * @return int length */ public int getLength() { return ValueUtils.getLength(getBaseValue()); }
/** * Get the parent bean. * @return Object */ public Object getBean() { if (bean == null) { bean = getImmediateParentPointer().getNode(); } return bean; }