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_CONSIST("dcc_consist", "ProtocolDCC_Consist"), // NOI18N
034        DCC_EXTENDED_CONSIST("dcc_extended_consist", "ProtocolDCC_Extended_Consist"), // NOI18N
035        DCC("dcc", "ProtocolDCC"), // NOI18N
036        SELECTRIX("selectrix", "ProtocolSelectrix"), // NOI18N
037        MOTOROLA("motorola", "ProtocolMotorola"), // NOI18N
038        MFX("mfx", "ProtocolMFX"), // NOI18N
039        M4("m4", "ProtocolM4"), // NOI18N
040        OPENLCB("openlcb", "ProtocolOpenLCB"), // NOI18N
041        TMCC1("tmcc1", "ProtocolTMCC1"), // NOI18N
042        TMCC2("tmcc2", "ProtocolTMCC2"), // NOI18N
043        LGB("lgb", "ProtocolLGB");   // NOI18N
044
045        Protocol(String shName, String peopleKey) {
046            this.shortName = shName;
047            this.peopleName = Bundle.getMessage(peopleKey);
048        }
049
050        String shortName;
051        String peopleName;
052
053        public String getShortName() {
054            return shortName;
055        }
056
057        public String getPeopleName() {
058            return peopleName;
059        }
060
061        static public Protocol getByShortName(String shName) {
062            for (Protocol p : Protocol.values()) {
063                if (p.shortName.equals(shName)) {
064                    return p;
065                }
066            }
067            throw new java.lang.IllegalArgumentException("argument value " + shName + " not valid");
068        }
069
070        static public Protocol getByPeopleName(String pName) {
071            for (Protocol p : Protocol.values()) {
072                if (p.peopleName.equals(pName)) {
073                    return p;
074                }
075            }
076            throw new java.lang.IllegalArgumentException("argument value " + pName + " not valid");
077        }
078
079    }
080
081}