org.jdom2.contrib.xpath.java.JavaXPathFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jdom Show documentation
Show all versions of jdom Show documentation
A complete, Java-based solution for accessing, manipulating,
and outputting XML data
package org.jdom2.contrib.xpath.java;
import java.util.Map;
import javax.xml.xpath.XPathFactory;
import org.jdom2.Namespace;
import org.jdom2.filter.Filter;
import org.jdom2.xpath.XPathExpression;
/**
* An XPathFactory using the underlying infrastructure in javax.xml.xpath.*
* to process the XPath expressions against the JDOM content.
* @author Rolf Lear
*
*/
public class JavaXPathFactory extends org.jdom2.xpath.XPathFactory {
ThreadLocal localfac =
new ThreadLocal();
@Override
public XPathExpression compile(String expression, Filter filter,
Map variables, Namespace... namespaces) {
// Java XPath factories are not thread safe... use a thread-local.
XPathFactory fac = localfac.get();
if (fac == null) {
fac = XPathFactory.newInstance();
localfac.set(fac);
}
return new JavaXPathExpression(
expression, filter, variables, namespaces, fac);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy