2002-12-10 20:53:55 +00:00
|
|
|
package org.thdl.quilldriver;
|
|
|
|
|
|
|
|
import org.jaxen.XPath;
|
2002-12-12 15:17:42 +00:00
|
|
|
import org.jaxen.JaxenException;
|
|
|
|
import org.jaxen.jdom.JDOMXPath;
|
|
|
|
import java.util.List;
|
2002-12-10 20:53:55 +00:00
|
|
|
|
2002-12-12 15:17:42 +00:00
|
|
|
public class TranscriptNavigator {
|
|
|
|
private TranscriptNavigator() {} //can't instantiate this class
|
2002-12-10 20:53:55 +00:00
|
|
|
|
2002-12-12 15:17:42 +00:00
|
|
|
public static Object findSingleNode(Object jdomNode, String xpathExpression) {
|
|
|
|
List l = findNodeSet(jdomNode, xpathExpression);
|
|
|
|
if (l == null || l.size() == 0)
|
|
|
|
return null;
|
|
|
|
else {
|
|
|
|
return l.get(0);
|
2002-12-10 20:53:55 +00:00
|
|
|
}
|
|
|
|
}
|
2002-12-12 15:17:42 +00:00
|
|
|
public static List findNodeSet(Object jdomNode, String xpathExpression) {
|
2002-12-10 20:53:55 +00:00
|
|
|
if (jdomNode == null)
|
|
|
|
return null;
|
2002-12-12 15:17:42 +00:00
|
|
|
try {
|
|
|
|
XPath path = new JDOMXPath(xpathExpression);
|
|
|
|
return path.selectNodes(jdomNode);
|
|
|
|
} catch (JaxenException je) {
|
|
|
|
je.printStackTrace();
|
2002-12-10 20:53:55 +00:00
|
|
|
return null;
|
2002-12-12 15:17:42 +00:00
|
|
|
}
|
2002-12-10 20:53:55 +00:00
|
|
|
}
|
|
|
|
}
|