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.DigitalExpressionManager;
012import jmri.jmrit.logixng.FemaleSocketListener;
013import jmri.jmrit.logixng.MaleSocket;
014import jmri.jmrit.logixng.FemaleDigitalExpressionSocket;
015import jmri.jmrit.logixng.MaleDigitalExpressionSocket;
016
017/**
018 * Default implementation of the Female Digital Expression socket
019 */
020public class DefaultFemaleDigitalExpressionSocket extends AbstractFemaleSocket
021        implements FemaleDigitalExpressionSocket {
022
023    public DefaultFemaleDigitalExpressionSocket(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 MaleDigitalExpressionSocket;
031    }
032    
033    /** {@inheritDoc} */
034    @Override
035    public boolean evaluate() throws JmriException {
036        if (isConnected()) {
037            return ((MaleDigitalExpressionSocket)getConnectedSocket())
038                    .evaluate();
039        } else {
040            return false;
041        }
042    }
043
044    /** {@inheritDoc} */
045    @Override
046    public String getShortDescription(Locale locale) {
047        return Bundle.getMessage(locale, "DefaultFemaleDigitalExpressionSocket_Short");
048    }
049
050    /** {@inheritDoc} */
051    @Override
052    public String getLongDescription(Locale locale) {
053        return Bundle.getMessage(locale, "DefaultFemaleDigitalExpressionSocket_Long", getName());
054    }
055
056    @Override
057    public Map<Category, List<Class<? extends Base>>> getConnectableClasses() {
058        return InstanceManager.getDefault(DigitalExpressionManager.class).getExpressionClasses();
059    }
060
061    /** {@inheritDoc} */
062    @Override
063    public void disposeMe() {
064        // Do nothing
065    }
066
067}