001package jmri;
002
003/**
004 * Interface for generic Locomotive Address.
005 *
006 * Note that this is not DCC-specific.
007 *
008 *
009 * <hr>
010 * This file is part of JMRI.
011 * <p>
012 * JMRI is free software; you can redistribute it and/or modify it under the
013 * terms of version 2 of the GNU General Public License as published by the Free
014 * Software Foundation. See the "COPYING" file for a copy of this license.
015 * <p>
016 * JMRI is distributed in the hope that it will be useful, but WITHOUT ANY
017 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
018 * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
019 *
020 * @author Bob Jacobsen Copyright (C) 2005
021 */
022@javax.annotation.concurrent.Immutable
023public interface LocoAddress {
024
025    int getNumber();
026
027    Protocol getProtocol();
028
029    enum Protocol {
030
031        DCC_SHORT("dcc_short", "ProtocolDCC_Short"), // NOI18N
032        DCC_LONG("dcc_long", "ProtocolDCC_Long"), // NOI18N
033        DCC("dcc", "ProtocolDCC"), // NOI18N
034        SELECTRIX("selectrix", "ProtocolSelectrix"), // NOI18N
035        MOTOROLA("motorola", "ProtocolMotorola"), // NOI18N
036        MFX("mfx", "ProtocolMFX"), // NOI18N
037        M4("m4", "ProtocolM4"), // NOI18N
038        OPENLCB("openlcb", "ProtocolOpenLCB"), // NOI18N
039        LGB("lgb", "ProtocolLGB");   // NOI18N
040
041        Protocol(String shName, String peopleKey) {
042            this.shortName = shName;
043            this.peopleName = Bundle.getMessage(peopleKey);
044        }
045
046        String shortName;
047        String peopleName;
048
049        public String getShortName() {
050            return shortName;
051        }
052
053        public String getPeopleName() {
054            return peopleName;
055        }
056
057        static public Protocol getByShortName(String shName) {
058            for (Protocol p : Protocol.values()) {
059                if (p.shortName.equals(shName)) {
060                    return p;
061                }
062            }
063            throw new java.lang.IllegalArgumentException("argument value " + shName + " not valid");
064        }
065
066        static public Protocol getByPeopleName(String pName) {
067            for (Protocol p : Protocol.values()) {
068                if (p.peopleName.equals(pName)) {
069                    return p;
070                }
071            }
072            throw new java.lang.IllegalArgumentException("argument value " + pName + " not valid");
073        }
074
075    }
076
077}