summaryrefslogtreecommitdiffstats
path: root/wso2/wso2bpel-ext/wso2bpel-core/BPEL4RESTLight/src/main/java/de/unistuttgart/iaas/xml/XPathEvaluator.java
blob: 0ae6b2c3f616a3e92aa6b36fafabff28913ab219 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/**
 * 
 * Copyright 2011 IAAS University of Stuttgart <br>
 * <br>
 * 
 * @author uwe.breitenbuecher@iaas.uni-stuttgart.de
 * 
 */
package de.unistuttgart.iaas.xml;

import javax.xml.namespace.QName;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathFactory;


public class XPathEvaluator {
	
	public static XPath xpath = XPathFactory.newInstance().newXPath();
	
	
	@SuppressWarnings("unchecked")
	public static <t> t evaluate(String expression, Object source, QName returnType) {
		
		Object resultAsObject = null;
		try {
			resultAsObject = xpath.evaluate(expression, source, returnType);
			
		} catch (Exception e) {
			e.printStackTrace();
		}
		return (t) resultAsObject;
	}
	
}