Search in sources :

Example 1 with SimpleVariable

use of com.teradata.jaqy.utils.SimpleVariable in project jaqy by Teradata.

the class VariableManager method setVariable.

public Object setVariable(String name, Object value) {
    if (name == null || name.length() == 0) {
        throw new IllegalArgumentException("Empty variable name.");
    }
    if (value instanceof Variable) {
        setVariable((Variable) value);
        return null;
    }
    if (m_parent != null && m_parent.containsKey(name)) {
        return m_parent.setVariable(name, value);
    }
    Variable var;
    synchronized (m_lock) {
        var = (Variable) m_variables.get(name);
        if (var == null) {
            var = new SimpleVariable(name);
            var.set(value);
            m_variables.put(name, var);
            return null;
        }
    }
    Object old = var.get();
    if (!var.set(value)) {
        throw new IllegalArgumentException("Cannot set the variable: " + name);
    }
    return old;
}
Also used : Variable(com.teradata.jaqy.interfaces.Variable) SimpleVariable(com.teradata.jaqy.utils.SimpleVariable) FixedVariable(com.teradata.jaqy.utils.FixedVariable) SimpleVariable(com.teradata.jaqy.utils.SimpleVariable)

Aggregations

Variable (com.teradata.jaqy.interfaces.Variable)1 FixedVariable (com.teradata.jaqy.utils.FixedVariable)1 SimpleVariable (com.teradata.jaqy.utils.SimpleVariable)1