Methods Summary |
---|
public static oracle.toplink.essentials.internal.ejb.cmp3.xml.parser.XPathEngine | getInstance()Return the XPathEngine singleton.
if (instance == null) {
instance = new XPathEngine();
}
return instance;
|
private org.w3c.dom.NodeList | getNodes(org.w3c.dom.Node contextNode, java.lang.String xPathFragment)
if (xPathFragment.startsWith(ATTRIBUTE)) {
return selectAttributeNodes(contextNode, xPathFragment);
} else if (TEXT.equals(xPathFragment)) {
return selectTextNodes(contextNode);
} else if (xPathFragment.equals(ALL_CHILDREN)) {
return selectChildElements(contextNode);
}
return selectElementNodes(contextNode, xPathFragment);
|
private org.w3c.dom.Node | getSingleNode(org.w3c.dom.Node contextNode, java.lang.String xPathFragment)
if (xPathFragment.startsWith(ATTRIBUTE)) {
return selectSingleAttribute(contextNode, xPathFragment);
} else if (TEXT.equals(xPathFragment)) {
return selectSingleText(contextNode);
}
return selectSingleElement(contextNode, xPathFragment);
|
private boolean | sameName(org.w3c.dom.Node node, java.lang.String name)
return name.equals(node.getLocalName()) || name.equals(node.getNodeName());
|
private boolean | sameNamespaceURI(org.w3c.dom.Node node, java.lang.String namespaceURI)
// HANDLE THE NULL CASE
String nodeNamespaceURI = node.getNamespaceURI();
if (nodeNamespaceURI == namespaceURI) {
return true;
}
if ((nodeNamespaceURI == null) && namespaceURI.equals("")) {
return true;
}
if ((namespaceURI == null) && nodeNamespaceURI.equals("")) {
return true;
}
// HANDLE THE NON-NULL CASE
return (null != nodeNamespaceURI) && nodeNamespaceURI.equals(namespaceURI);
|
private org.w3c.dom.NodeList | selectAttributeNodes(org.w3c.dom.Node contextNode, java.lang.String xPathFragment)
XMLNodeList xmlNodeList = new XMLNodeList();
Node child = selectSingleAttribute(contextNode, xPathFragment);
if (null != child) {
xmlNodeList.add(child);
}
return xmlNodeList;
|
private org.w3c.dom.NodeList | selectChildElements(org.w3c.dom.Node contextNode)
XMLNodeList xmlNodeList = new XMLNodeList();
Node child = contextNode.getFirstChild();
while (child != null) {
if (child.getNodeType() == Node.ELEMENT_NODE) {
xmlNodeList.add(child);
}
child = child.getNextSibling();
}
return xmlNodeList;
|
private org.w3c.dom.NodeList | selectElementNodes(org.w3c.dom.Node contextNode, java.lang.String xPathFragment)
XMLNodeList xmlNodeList = new XMLNodeList();
Node child = contextNode.getFirstChild();
while (null != child) {
if ((child.getNodeType() == Node.ELEMENT_NODE) && sameName(child, xPathFragment) && sameNamespaceURI(child, NAMESPACE_URI)) {
xmlNodeList.add(child);
}
child = child.getNextSibling();
}
return xmlNodeList;
|
public org.w3c.dom.NodeList | selectNodes(org.w3c.dom.Node contextNode, java.lang.String[] xPathFragments)Execute the XPath statement relative to the context node.
if (contextNode == null) {
return null;
}
return selectNodes(contextNode, xPathFragments, 0);
|
private org.w3c.dom.NodeList | selectNodes(org.w3c.dom.Node contextNode, java.lang.String[] xPathFragments, int index)
NodeList resultNodes = getNodes(contextNode, xPathFragments[index]);
if (xPathFragments.length != index + 1) {
Node resultNode;
XMLNodeList result = new XMLNodeList();
int numberOfResultNodes = resultNodes.getLength();
for (int x = 0; x < numberOfResultNodes; x++) {
resultNode = resultNodes.item(x);
result.addAll(selectNodes(resultNode, xPathFragments, index + 1));
}
return result;
}
return resultNodes;
|
private org.w3c.dom.Node | selectSingleAttribute(org.w3c.dom.Node contextNode, java.lang.String xPathFragment)
Element contextElement = (Element)contextNode;
return contextElement.getAttributeNode(xPathFragment.substring(1));
|
private org.w3c.dom.Node | selectSingleElement(org.w3c.dom.Node contextNode, java.lang.String xPathFragment)
Node child = contextNode.getFirstChild();
while (null != child) {
if ((child.getNodeType() == Node.ELEMENT_NODE) && sameName(child, xPathFragment) && sameNamespaceURI(child, NAMESPACE_URI)) {
return child;
}
child = child.getNextSibling();
}
return null;
|
public org.w3c.dom.Node | selectSingleNode(org.w3c.dom.Node contextNode, java.lang.String[] xPathFragments)Execute the XPath statement relative to the context node.
if (contextNode == null) {
return null;
}
return selectSingleNode(contextNode, xPathFragments, 0);
|
private org.w3c.dom.Node | selectSingleNode(org.w3c.dom.Node contextNode, java.lang.String[] xPathFragments, int index)
Node resultNode = getSingleNode(contextNode, xPathFragments[index]);
if ((resultNode == null) || (xPathFragments.length == (index + 1))) {
return resultNode;
}
return selectSingleNode(resultNode, xPathFragments, index + 1);
|
private org.w3c.dom.Node | selectSingleText(org.w3c.dom.Node contextNode)
NodeList childrenNodes = contextNode.getChildNodes();
if (childrenNodes.getLength() == 0) {
return null;
}
if (childrenNodes.getLength() == 1) {
Node child = childrenNodes.item(0);
if (child.getNodeType() == Node.TEXT_NODE) {
return child;
}
return null;
}
String returnVal = null;
for (int i = 0; i < childrenNodes.getLength(); i++) {
Node next = childrenNodes.item(i);
if (next.getNodeType() == Node.TEXT_NODE) {
String val = ((Text)next).getNodeValue();
if (val != null) {
if (returnVal == null) {
returnVal = new String();
}
returnVal += val;
}
}
}
//bug#4515249 a new text node was being created when null should have been returned
//case where contextNode had several children but no Text children
if (returnVal != null) {
return contextNode.getOwnerDocument().createTextNode(returnVal);
}
return null;
|
private org.w3c.dom.NodeList | selectTextNodes(org.w3c.dom.Node contextNode)
Node n = selectSingleText(contextNode);
XMLNodeList xmlNodeList = new XMLNodeList();
if (n != null) {
xmlNodeList.add(n);
}
return xmlNodeList;
|