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;
}
Aggregations