List of usage examples for org.apache.commons.jxpath.ri.model NodePointer getBaseValue
public abstract Object getBaseValue();
From source file:org.apache.maven.project.harness.Xpp3DomNodePointer.java
@Override public int compareChildNodePointers(NodePointer pointer1, NodePointer pointer2) { Xpp3Dom node1 = (Xpp3Dom) pointer1.getBaseValue(); Xpp3Dom node2 = (Xpp3Dom) pointer2.getBaseValue(); if (node1 == node2) { return 0; }/*w w w . j a va 2 s. c om*/ for (int i = 0; i < node.getChildCount(); i++) { Xpp3Dom child = node.getChild(i); if (child == node1) { return -1; } if (child == node2) { return 1; } } return 0; }
From source file:org.firesoa.common.jxpath.model.dom4j.Dom4JNodePointer.java
@Override public int compareChildNodePointers(NodePointer pointer1, NodePointer pointer2) { Object node1 = pointer1.getBaseValue(); Object node2 = pointer2.getBaseValue(); if (node1 == node2) { return 0; }/*from ww w . j a v a2s . c o m*/ if ((node1 instanceof Attribute) && !(node2 instanceof Attribute)) { return -1; } if (!(node1 instanceof Attribute) && (node2 instanceof Attribute)) { return 1; } if ((node1 instanceof Attribute) && (node2 instanceof Attribute)) { List list = ((Element) getNode()).attributes(); int length = list.size(); for (int i = 0; i < length; i++) { Object n = list.get(i); if (n == node1) { return -1; } else if (n == node2) { return 1; } } return 0; // Should not happen } if (!(node instanceof Element)) { throw new RuntimeException("JXPath internal error: " + "compareChildNodes called for " + node); } List children = ((Element) node).content(); int length = children.size(); for (int i = 0; i < length; i++) { Object n = children.get(i); if (n == node1) { return -1; } if (n == node2) { return 1; } } return 0; }
From source file:org.lilyproject.runtime.conf.jxpath.ConfNodePointer.java
public int compareChildNodePointers(NodePointer pointer1, NodePointer pointer2) { Object value1 = pointer1.getBaseValue(); Object value2 = pointer2.getBaseValue(); if (value1 == value2) { return 0; }/*from w ww .j a v a2s. c o m*/ boolean value1isAttr = value1 instanceof ConfAttr; boolean value2isAttr = value2 instanceof ConfAttr; if (value1isAttr && !value2isAttr) { return -1; } if (!value1isAttr && value2isAttr) { return 1; } if (value1isAttr && value2isAttr) { return ((ConfAttr) value1).getName().compareTo(((ConfAttr) value2).getName()); } List<Conf> children = conf.getChildren(); for (Conf child : children) { if (child == value1) { return -1; } if (child == value2) { return 1; } } return 0; }