Merge "Merger the code provide by lvbo chenbo."
[vfc/nfvo/wfengine.git] / wso2bpel-ext / wso2bpel-core / BPEL4RESTLight / src / main / java / de / unistuttgart / iaas / xml / XPathEvaluator.java
1 /**
2  * 
3  * Copyright 2011 IAAS University of Stuttgart <br>
4  * <br>
5  * 
6  * @author uwe.breitenbuecher@iaas.uni-stuttgart.de
7  * 
8  */
9 package de.unistuttgart.iaas.xml;
10
11 import javax.xml.namespace.QName;
12 import javax.xml.xpath.XPath;
13 import javax.xml.xpath.XPathFactory;
14
15
16 public class XPathEvaluator {
17         
18         public static XPath xpath = XPathFactory.newInstance().newXPath();
19         
20         
21         @SuppressWarnings("unchecked")
22         public static <t> t evaluate(String expression, Object source, QName returnType) {
23                 
24                 Object resultAsObject = null;
25                 try {
26                         resultAsObject = xpath.evaluate(expression, source, returnType);
27                         
28                 } catch (Exception e) {
29                         e.printStackTrace();
30                 }
31                 return (t) resultAsObject;
32         }
33         
34 }