All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jdom2.contrib.xpath.java.JavaXPathFactory Maven / Gradle / Ivy

Go to download

A complete, Java-based solution for accessing, manipulating, and outputting XML data

There is a newer version: 2.0.2
Show newest version
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