Example usage for org.apache.commons.jxpath.ri.model NodePointer getValuePointer

List of usage examples for org.apache.commons.jxpath.ri.model NodePointer getValuePointer

Introduction

In this page you can find the example usage for org.apache.commons.jxpath.ri.model NodePointer getValuePointer.

Prototype

public NodePointer getValuePointer() 

Source Link

Document

If this pointer manages a transparent container, like a variable, this method returns the pointer to the contents.

Usage

From source file:org.eclipse.e4.emf.internal.xpath.CollectionNodeIterator.java

/**
 * Prepare.../*ww w  . ja  va  2 s . co  m*/
 */
private void prepare() {
    collection = new ArrayList<>();
    NodePointer ptr = (NodePointer) pointer.clone();
    int length = ptr.getLength();
    for (int i = 0; i < length; i++) {
        ptr.setIndex(i);
        NodePointer elementPointer = ptr.getValuePointer();
        NodeIterator iter = getElementNodeIterator(elementPointer);

        for (int j = 1; iter.setPosition(j); j++) {
            NodePointer childPointer = iter.getNodePointer();
            if (reverse) {
                collection.add(0, childPointer);
            } else {
                collection.add(childPointer);
            }
        }
    }
    if (startWith != null) {
        int index = collection.indexOf(startWith);
        if (index == -1) {
            throw new JXPathException("Invalid starting pointer for iterator: " + startWith);
        }
        while (collection.size() > index) {
            if (!reverse) {
                collection.remove(collection.size() - 1);
            } else {
                collection.remove(0);
            }
        }
    }
}

From source file:org.firesoa.common.jxpath.XMLModelTestCase.java

public void testID() {
    context.setIdentityManager(new IdentityManager() {
        public Pointer getPointerByID(JXPathContext context, String id) {
            NodePointer ptr = (NodePointer) context.getPointer("/");
            ptr = ptr.getValuePointer(); // Unwrap the container
            return ptr.getPointerByID(context, id);
        }/*from w ww  .j  a  v a  2 s.  co m*/
    });

    assertXPathValueAndPointer(context, "id(101)//street", "Tangerine Drive", "id('101')/address[1]/street[1]");

    assertXPathPointerLenient(context, "id(105)/address/street", "id(105)/address/street");
}