Example usage for org.apache.commons.jxpath JXPathContext newContext

List of usage examples for org.apache.commons.jxpath JXPathContext newContext

Introduction

In this page you can find the example usage for org.apache.commons.jxpath JXPathContext newContext.

Prototype

public static JXPathContext newContext(Object contextBean) 

Source Link

Document

Creates a new JXPathContext with the specified object as the root node.

Usage

From source file:blueprint.sdk.util.JXPathHelper.java

/**
 * @param xpath XPath to evaluate/*from   w  w w.j  a v  a  2 s  . c  o  m*/
 * @param target target node
 * @return String or null(not found)
 */
public static String evaluate(String xpath, Node target) {
    return evaluate(xpath, JXPathContext.newContext(target));
}

From source file:events.Utils.java

public static <V> Predicate<V> xpath(String query) {
    return t -> (boolean) JXPathContext.newContext(t).iterate(query).next();
}

From source file:jp.go.nict.langrid.commons.jxpath.JXPathUtil.java

/**
 * /* w  w w  .ja  v  a  2  s.  co  m*/
 * 
 */
public static JXPathContext newXMLContext(String anXml) throws IOException, SAXException {
    DocumentBuilder builder = DocumentUtil.newDocumentBuilder();
    return JXPathContext.newContext(builder.parse(new InputSource(new StringReader(anXml))));
}

From source file:it.polimi.modaclouds.qos_models.util.XMLHelper.java

public static <T> T getElementByID(Collection<T> elements, String id) {
    for (T element : elements) {
        if (JXPathContext.newContext(element).getValue("id").equals(id))
            return element;
    }//from   w w  w .j av a2  s. c o  m
    return null;
}

From source file:blueprint.sdk.util.JXPathHelper.java

/**
 * @param xpath XPath to evaluate/*from w  ww . ja  va2  s. c  o m*/
 * @param target target node
 * @return Pointer or null(not found)
 */
public static Pointer evaluatePointer(String xpath, Node target) {
    return evaluatePointer(xpath, JXPathContext.newContext(target));
}

From source file:com.ixcode.framework.model.binding.ModelXPathResolver.java

public ModelXPathResolver(Object rootModel) {
    _pathContext = JXPathContext.newContext(rootModel);
    _pathContext.setLenient(true);
    _rootModel = rootModel;
}

From source file:jp.go.nict.langrid.commons.jxpath.JXPathUtil.java

/**
 * //from   w w w .  j  a va 2  s.  com
 * 
 */
public static JXPathContext newXMLContext(InputStream anInputStream) throws IOException, SAXException {
    DocumentBuilder builder = DocumentUtil.newDocumentBuilder();
    return JXPathContext.newContext(builder.parse(anInputStream));
}

From source file:com.technofovea.hl2parse.vdf.SoundScapeReader.java

public SoundScapeReader(VdfRoot rootNode) {
    root = rootNode;
    context = JXPathContext.newContext(root);
    JxPathUtil.addFunctions(context);
    context.getVariables().declareVariable("wavkey", KEY_WAV);
}

From source file:com.technofovea.hl2parse.vdf.SteamMetaReader.java

public SteamMetaReader(VdfRoot rootNode) {
    root = rootNode;
    context = JXPathContext.newContext(root);
    JxPathUtil.addFunctions(context);

}

From source file:com.technofovea.hl2parse.vdf.ParticleManifestReader.java

public ParticleManifestReader(VdfRoot rootNode) {
    root = rootNode;//w w w .ja v a  2  s  .  co  m
    context = JXPathContext.newContext(root);
    JxPathUtil.addFunctions(context);

    context.getVariables().declareVariable("filekey", KEY_NAME);
}