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

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

Introduction

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

Prototype

public Object getNode() 

Source Link

Document

Returns the object the pointer points to; does not convert it to a "canonical" type.

Usage

From source file:org.apache.ctakes.jdl.data.loader.XmlLoader.java

/**
 * @param jdlConnection/*from   ww  w .  j a  va 2 s.co m*/
 *            the jdlConnection to manage
 */
@Override
public final void dataInsert(final JdlConnection jdlConnection) {
    String sql = getSqlInsert(loader);
    Number ncommit = loader.getCommit();
    int r = 0;
    try {
        Iterator<?> iterator = context.iteratePointers(loader.getXroot());
        while (iterator.hasNext()) {
            r++;
            NodePointer pointer = (NodePointer) iterator.next();
            Node node = (Node) pointer.getNode();
            JXPathContext context = JXPathContext.newContext(DomUtil.nodeToDocument(node));
            try {
                int c = 0;
                PreparedStatement preparedStatement = jdlConnection.getOpenConnection().prepareStatement(sql);
                if (ncommit == null) {
                    jdlConnection.setAutoCommit(true);
                } else {
                    jdlConnection.setAutoCommit(false);
                }
                for (Column column : loader.getColumn()) {
                    c++;
                    Object value = column.getConstant();
                    if (value == null) {
                        if (column.getSeq() != null) {
                            value = r + column.getSeq().intValue();
                        } else if (column.getXpath() != null) {
                            value = this.context.getValue(column.getXpath());
                        } else {
                            value = context.getPointer(column.getXleaf()).getValue();
                        }
                    }
                    preparedStatement.setObject(c, value);
                }
                executeBatch(preparedStatement);
                if (!jdlConnection.isAutoCommit() && (r % ncommit.intValue() == 0)) {
                    jdlConnection.commitConnection();
                }
            } catch (SQLException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    } catch (InstantiationException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (ClassNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    try {
        if (!jdlConnection.isAutoCommit()) {
            jdlConnection.commitConnection();
        }
    } catch (SQLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:org.apache.maven.project.harness.Xpp3DomAttributeIterator.java

public Xpp3DomAttributeIterator(NodePointer parent, QName qname) {
    this.parent = parent;
    this.node = (Xpp3Dom) parent.getNode();

    Map<String, String> map = new LinkedHashMap<>();
    for (String name : this.node.getAttributeNames()) {
        if (name.equals(qname.getName()) || "*".equals(qname.getName())) {
            String value = this.node.getAttribute(name);
            map.put(name, value);//  www  .  j  a v a 2  s.c  o m
        }
    }
    this.attributes = new ArrayList<>(map.entrySet());
}

From source file:org.apache.maven.project.harness.Xpp3DomNodeIterator.java

public Xpp3DomNodeIterator(NodePointer parent, NodeTest test, boolean reverse, NodePointer startWith) {
    this.parent = parent;
    this.node = (Xpp3Dom) parent.getNode();
    this.children = this.node.getChildren();
    if (startWith != null) {
        Xpp3Dom startWithNode = (Xpp3Dom) startWith.getNode();
        for (; filteredIndex < children.length; filteredIndex++) {
            if (startWithNode.equals(children[filteredIndex])) {
                filteredIndex++;/*www  .  ja  v a2s .  c o  m*/
                break;
            }
        }
    }
    this.test = test;
    if (reverse) {
        throw new UnsupportedOperationException();
    }
}

From source file:org.lilyproject.runtime.conf.jxpath.ConfAttributeIterator.java

/**
 * @param parent pointer// ww  w.  ja v  a 2s .c o  m
 * @param qName to test
 */
public ConfAttributeIterator(NodePointer parent, QName qName) {
    this.parent = parent;

    Conf conf = (Conf) parent.getNode();

    String name = qName.getName();
    if (name.equals("*")) {
        attributes.addAll(conf.getAttributes().entrySet());
    } else {
        for (Map.Entry<String, String> entry : conf.getAttributes().entrySet()) {
            if (entry.getKey().equals(name)) {
                attributes.add(entry);
                break;
            }
        }
    }
}

From source file:org.lilyproject.runtime.conf.jxpath.ConfNodeIterator.java

/**
 * Create a new DOMNodeIterator.// w ww.  j a  v  a 2  s  . co m
 * @param parent parent pointer
 * @param nodeTest test
 * @param startWith starting pointer
 */
public ConfNodeIterator(NodePointer parent, NodeTest nodeTest, NodePointer startWith) {
    this.parent = parent;

    Conf conf = (Conf) parent.getNode();
    for (Conf child : conf.getChildren()) {
        if (ConfNodePointer.testNode(child, nodeTest)) {
            children.add(child);
        }
    }

    if (startWith != null) {
        Conf wanted = (Conf) startWith.getNode();
        for (int i = 0; i < children.size(); i++) {
            if (children.get(i) == wanted) {
                position = i + 1;
                break;
            }
        }
    }
}