001package jmri.jmrit.logixng.implementation;
002
003import java.util.List;
004import java.util.Locale;
005import java.util.Map;
006
007import jmri.InstanceManager;
008import jmri.JmriException;
009import jmri.jmrit.logixng.Base;
010import jmri.jmrit.logixng.Category;
011import jmri.jmrit.logixng.FemaleSocketListener;
012import jmri.jmrit.logixng.FemaleStringExpressionSocket;
013import jmri.jmrit.logixng.MaleStringExpressionSocket;
014import jmri.jmrit.logixng.MaleSocket;
015import jmri.jmrit.logixng.StringExpressionManager;
016
017/**
018 * Default implementation of the Female String Expression socket
019 */
020public class DefaultFemaleStringExpressionSocket extends AbstractFemaleSocket
021        implements FemaleStringExpressionSocket {
022
023    public DefaultFemaleStringExpressionSocket(Base parent, FemaleSocketListener listener, String name) {
024        super(parent, listener, name);
025    }
026    
027    /** {@inheritDoc} */
028    @Override
029    public boolean isCompatible(MaleSocket socket) {
030        return socket instanceof MaleStringExpressionSocket;
031    }
032    
033    /** {@inheritDoc} */
034    @Override
035    public String evaluate() throws JmriException {
036        if (isConnected()) {
037            return ((MaleStringExpressionSocket)getConnectedSocket()).evaluate();
038        } else {
039            return "";
040        }
041    }
042    
043    /** {@inheritDoc} */
044    @Override
045    public boolean getTriggerOnChange() {
046        throw new UnsupportedOperationException("Not supported");
047    }
048    
049    /** {@inheritDoc} */
050    @Override
051    public void setTriggerOnChange(boolean triggerOnChange) {
052        throw new UnsupportedOperationException("Not supported");
053    }
054    
055    /** {@inheritDoc} */
056    @Override
057    public String getShortDescription(Locale locale) {
058        return Bundle.getMessage(locale, "DefaultFemaleStringExpressionSocket_Short");
059    }
060
061    /** {@inheritDoc} */
062    @Override
063    public String getLongDescription(Locale locale) {
064        return Bundle.getMessage(locale, "DefaultFemaleStringExpressionSocket_Long", getName());
065    }
066
067    /** {@inheritDoc} */
068    @Override
069    public Map<Category, List<Class<? extends Base>>> getConnectableClasses() {
070        return InstanceManager.getDefault(StringExpressionManager.class).getExpressionClasses();
071    }
072
073    /** {@inheritDoc} */
074    @Override
075    public void disposeMe() {
076        // Do nothing
077    }
078
079}