org.jdesktop.el.impl.lang.VariableMapperFactory Maven / Gradle / Ivy
/*
* Copyright (C) 2007 Sun Microsystems, Inc. All rights reserved. Use is
* subject to license terms.
*/
package org.jdesktop.el.impl.lang;
import org.jdesktop.el.ValueExpression;
import org.jdesktop.el.VariableMapper;
public class VariableMapperFactory extends VariableMapper {
private final VariableMapper target;
private VariableMapper momento;
public VariableMapperFactory(VariableMapper target) {
if (target == null) {
throw new NullPointerException("Target VariableMapper cannot be null");
}
this.target = target;
}
public VariableMapper create() {
return this.momento;
}
public ValueExpression resolveVariable(String variable) {
ValueExpression expr = this.target.resolveVariable(variable);
if (expr != null) {
if (this.momento == null) {
this.momento = new VariableMapperImpl();
}
this.momento.setVariable(variable, expr);
}
return expr;
}
public ValueExpression setVariable(String variable, ValueExpression expression) {
throw new UnsupportedOperationException("Cannot Set Variables on Factory");
}
}