List of usage examples for org.apache.commons.jxpath.ri.model NodePointer getImmediateParentPointer
public NodePointer getImmediateParentPointer()
From source file:org.eclipse.e4.emf.internal.xpath.EStructuralFeatureIterator.java
/** * Create a new PropertyIterator./*from ww w . java 2s. c o m*/ * @param pointer owning pointer * @param name property name * @param reverse iteration order * @param startWith beginning pointer */ public EStructuralFeatureIterator(EStructuralFeatureOwnerPointer pointer, String name, boolean reverse, NodePointer startWith) { propertyNodePointer = (EStructuralFeaturePointer) pointer.getPropertyPointer().clone(); this.name = name; this.reverse = reverse; this.includeStart = true; if (reverse) { this.startPropertyIndex = EStructuralFeaturePointer.UNSPECIFIED_PROPERTY; this.startIndex = -1; } if (startWith != null) { while (startWith != null && startWith.getImmediateParentPointer() != pointer) { startWith = startWith.getImmediateParentPointer(); } if (startWith == null) { throw new JXPathException( "PropertyIerator startWith parameter is " + "not a child of the supplied parent"); } this.startPropertyIndex = ((EStructuralFeaturePointer) startWith).getPropertyIndex(); this.startIndex = startWith.getIndex(); if (this.startIndex == NodePointer.WHOLE_COLLECTION) { this.startIndex = 0; } this.includeStart = false; if (reverse && startIndex == -1) { this.includeStart = true; } } }
From source file:org.eclipse.e4.emf.internal.xpath.NullElementPointer.java
@Override public String asPath() { StringBuffer buffer = new StringBuffer(); NodePointer parent = getImmediateParentPointer(); if (parent != null) { buffer.append(parent.asPath());// w w w .j a va 2 s . c o m } if (index != WHOLE_COLLECTION) { // Address the list[1][2] case if (parent != null && parent.getIndex() != WHOLE_COLLECTION) { buffer.append("/."); } else if (parent != null && parent.getImmediateParentPointer() != null && parent.getImmediateParentPointer().getIndex() != WHOLE_COLLECTION) { buffer.append("/."); } buffer.append("[").append(index + 1).append(']'); } return buffer.toString(); }