Java Code Examples for org.apache.commons.jxpath.JXPathContext#getValue()

The following examples show how to use org.apache.commons.jxpath.JXPathContext#getValue() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EPLUtilities.java    From jetstream-esper with GNU General Public License v2.0 6 votes vote down vote up
public static Object getAttribute(Object object, String key) {
  try {
    Object event = object;
    if (object instanceof String) {
      ObjectMapper mapper = new ObjectMapper();
      event = mapper.readValue(object.toString(), HashMap.class);
    }
    if (event != null) {
      JXPathContext context = JXPathContext.newContext(event);
      context.setLenient(true);
      return context.getValue(key);
    }
  }
  catch (Exception e) { // NOPMD
    return null;
  }
  return null;
}
 
Example 2
Source File: PathValueMessageFilter.java    From suro with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public boolean apply(Object input) {
    JXPathContext jxpath = JXPathContext.newContext(input);
    // We should allow non-existing path, and let predicate handle it. 
    jxpath.setLenient(true);
    
    Object value = jxpath.getValue(xpath);
   
    return predicate.apply(value);
}
 
Example 3
Source File: XPath.java    From cloudml with GNU Lesser General Public License v3.0 4 votes vote down vote up
public Object query(Object context){
    JXPathContext jpathcontext = JXPathContext.newContext(context);
    return jpathcontext.getValue(literal);
}
 
Example 4
Source File: CloudMLQueryUtil.java    From cloudml with GNU Lesser General Public License v3.0 4 votes vote down vote up
public static Object cloudmlQuery(String jxpath, Object context){
    JXPathContext jxpathcontext = JXPathContext.newContext(context); 
    return jxpathcontext.getValue(jxpath);
}
 
Example 5
Source File: JXPath.java    From cloudml with GNU Lesser General Public License v3.0 4 votes vote down vote up
public Object query(Object context){
    JXPathContext jpathcontext = JXPathContext.newContext(context);
    return jpathcontext.getValue(literal);
}
 
Example 6
Source File: LazyDynaBeanTest.java    From commons-jxpath with Apache License 2.0 4 votes vote down vote up
public void testLazyProperty() throws JXPathNotFoundException {
    LazyDynaBean bean = new LazyDynaBean();
    JXPathContext context = JXPathContext.newContext(bean);
    context.getValue("nosuch");
}