Example usage for org.apache.commons.jxpath Variables isDeclaredVariable

List of usage examples for org.apache.commons.jxpath Variables isDeclaredVariable

Introduction

In this page you can find the example usage for org.apache.commons.jxpath Variables isDeclaredVariable.

Prototype

boolean isDeclaredVariable(String varName);

Source Link

Document

Returns true if the specified variable is declared.

Usage

From source file:org.openvpms.archetype.function.expression.ExpressionFunctions.java

/**
 * Evaluates a variable, if it exists.//w w  w  .  j  a  v a  2s. c  o m
 *
 * @param context the expression context
 * @param name    the variable name
 * @return the value of the variable, or {@code elseValue} if it doesn't exist
 */
public Object var(ExpressionContext context, String name, Object elseValue) {
    Variables variables = context.getJXPathContext().getVariables();
    if (variables.isDeclaredVariable(name)) {
        return variables.getVariable(name);
    }
    return elseValue;
}