001package jmri.jmrit.logixng.util.parser;
002
003import jmri.JmriException;
004import jmri.jmrit.logixng.FemaleGenericExpressionSocket;
005import jmri.jmrit.logixng.SymbolTable;
006
007/**
008 * A variable that evaluates a generic expression
009 */
010public class GenericExpressionVariable implements Variable {
011
012    private final FemaleGenericExpressionSocket _socket;
013    
014    public GenericExpressionVariable(FemaleGenericExpressionSocket socket) {
015        _socket = socket;
016    }
017    
018    @Override
019    public String getName() {
020        return _socket.getName();
021    }
022
023    @Override
024    public Object getValue(SymbolTable symbolTable) throws JmriException {
025        return _socket.evaluateGeneric();
026    }
027
028    @Override
029    public void setValue(SymbolTable symbolTable, Object value) throws JmriException {
030        log.error("An expression cannot be assigned a value");
031    }
032
033    private final static org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(GenericExpressionVariable.class);
034}