jmri.jmrit.operations.rollingstock
Class RollingStockManager

java.lang.Object
  extended by jmri.jmrit.operations.rollingstock.RollingStockManager
Direct Known Subclasses:
CarManager, EngineManager

public class RollingStockManager
extends Object

Base class for rolling stock managers car and engine.

Author:
Daniel Boudreau Copyright (C) 2010, 2011

Field Summary
protected  Hashtable<String,RollingStock> _hashTable
           
protected static int BY_BUILT
           
protected static int BY_COLOR
           
protected static int BY_DESTINATION
           
protected static int BY_LOCATION
           
protected static int BY_MOVES
           
protected static int BY_NUMBER
           
protected static int BY_OWNER
           
protected static int BY_RFID
           
protected static int BY_ROAD
           
protected static int BY_TRAIN
           
protected static int BY_TYPE
           
protected static int BY_VALUE
           
static String LISTLENGTH_CHANGED_PROPERTY
           
 
Constructor Summary
RollingStockManager()
           
 
Method Summary
 void addPropertyChangeListener(PropertyChangeListener l)
           
 void deleteAll()
          Remove all RollingStock from roster
 void deregister(RollingStock rs)
          Unload RollingStock.
 void dispose()
           
protected  void firePropertyChange(String p, Object old, Object n)
           
 List<String> getAvailableTrainList(Train train)
          Return a list available rolling stock (no assigned train or rolling stock already assigned to this train) on a route, RollingStock is ordered least recently moved to most recently moved.
 List<String> getByBuiltList()
          Sort by when rolling stock was built
 List<String> getByColorList()
          Sort by rolling stock color names
 List<String> getByDestinationList()
          Sort by rolling stock destination
 RollingStock getById(String id)
          Get rolling stock by id
 List<String> getByIdList()
          Sort by rolling stock id
protected  List<String> getByList(List<String> sortIn, int attribute)
           
 List<String> getByLocationList()
          Sort by rolling stock location
 List<String> getByMovesList()
          Sort by rolling stock moves
 List<String> getByNumberList()
          Sort by rolling stock number, number can alpha numeric
 List<String> getByOwnerList()
          Sort by rolling stock owner
 RollingStock getByRfid(String rfid)
          Get a rolling stock by Radio Frequency Identification (RFID)
 List<String> getByRfidList()
          Sort by rolling stock RFID
 RollingStock getByRoadAndNumber(String road, String number)
          Get rolling stock by road and number
 List<String> getByRoadNameList()
          Sort by rolling stock road name
 List<String> getByTrainList()
          Sort by rolling stocks in trains
 List<String> getByTrainList(Train train)
          Get a list of rolling stocks assigned to a train
 RollingStock getByTypeAndRoad(String type, String road)
          Get a rolling stock by type and road.
 List<String> getByTypeList()
          Sort by rolling stock type names
 List<String> getByTypeList(String type)
          Return rolling stock ids of a specific type
 List<String> getByValueList()
          Sort by rolling stock value
 int getNumEntries()
          Get the number of items in the roster
protected  Object getRsAttribute(RollingStock rs, int attribute)
           
 void register(RollingStock rs)
          Load RollingStock.
 void removePropertyChangeListener(PropertyChangeListener l)
           
protected  List<String> sortList(List<String> list)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_hashTable

protected Hashtable<String,RollingStock> _hashTable

LISTLENGTH_CHANGED_PROPERTY

public static final String LISTLENGTH_CHANGED_PROPERTY
See Also:
Constant Field Values

BY_NUMBER

protected static final int BY_NUMBER
See Also:
Constant Field Values

BY_ROAD

protected static final int BY_ROAD
See Also:
Constant Field Values

BY_TYPE

protected static final int BY_TYPE
See Also:
Constant Field Values

BY_COLOR

protected static final int BY_COLOR
See Also:
Constant Field Values

BY_LOCATION

protected static final int BY_LOCATION
See Also:
Constant Field Values

BY_DESTINATION

protected static final int BY_DESTINATION
See Also:
Constant Field Values

BY_TRAIN

protected static final int BY_TRAIN
See Also:
Constant Field Values

BY_MOVES

protected static final int BY_MOVES
See Also:
Constant Field Values

BY_BUILT

protected static final int BY_BUILT
See Also:
Constant Field Values

BY_OWNER

protected static final int BY_OWNER
See Also:
Constant Field Values

BY_RFID

protected static final int BY_RFID
See Also:
Constant Field Values

BY_VALUE

protected static final int BY_VALUE
See Also:
Constant Field Values
Constructor Detail

RollingStockManager

public RollingStockManager()
Method Detail

getNumEntries

public int getNumEntries()
Get the number of items in the roster

Returns:
Number of rolling stock in the Roster

dispose

public void dispose()

getById

public RollingStock getById(String id)
Get rolling stock by id

Returns:
requested RollingStock object or null if none exists

getByRoadAndNumber

public RollingStock getByRoadAndNumber(String road,
                                       String number)
Get rolling stock by road and number

Parameters:
road - RollingStock road
number - RollingStock number
Returns:
requested RollingStock object or null if none exists

getByTypeAndRoad

public RollingStock getByTypeAndRoad(String type,
                                     String road)
Get a rolling stock by type and road. Used to test that rolling stock with a specific type and road exists.

Parameters:
type - RollingStock type.
road - RollingStock road.
Returns:
the first RollingStock found with the specified type and road.

getByRfid

public RollingStock getByRfid(String rfid)
Get a rolling stock by Radio Frequency Identification (RFID)

Parameters:
rfid - RollingStock's RFID.
Returns:
the RollingStock with the specific RFID, or null if not found

register

public void register(RollingStock rs)
Load RollingStock.


deregister

public void deregister(RollingStock rs)
Unload RollingStock.


deleteAll

public void deleteAll()
Remove all RollingStock from roster


getByIdList

public List<String> getByIdList()
Sort by rolling stock id

Returns:
list of RollingStock ids ordered by id

getByRoadNameList

public List<String> getByRoadNameList()
Sort by rolling stock road name

Returns:
list of RollingStock ids ordered by road name

getByNumberList

public List<String> getByNumberList()
Sort by rolling stock number, number can alpha numeric

Returns:
list of RollingStock ids ordered by number

getByTypeList

public List<String> getByTypeList()
Sort by rolling stock type names

Returns:
list of RollingStock ids ordered by RollingStock type

getByTypeList

public List<String> getByTypeList(String type)
Return rolling stock ids of a specific type

Parameters:
type - type of rolling stock
Returns:
list of RollingStock ids that are specific type

getByColorList

public List<String> getByColorList()
Sort by rolling stock color names

Returns:
list of RollingStock ids ordered by RollingStock color

getByLocationList

public List<String> getByLocationList()
Sort by rolling stock location

Returns:
list of RollingStock ids ordered by RollingStock location

getByDestinationList

public List<String> getByDestinationList()
Sort by rolling stock destination

Returns:
list of RollingStock ids ordered by RollingStock destination

getByTrainList

public List<String> getByTrainList()
Sort by rolling stocks in trains

Returns:
list of RollingStock ids ordered by trains

getByMovesList

public List<String> getByMovesList()
Sort by rolling stock moves

Returns:
list of RollingStock ids ordered by RollingStock moves

getByBuiltList

public List<String> getByBuiltList()
Sort by when rolling stock was built

Returns:
list of RollingStock ids ordered by RollingStock built date

getByOwnerList

public List<String> getByOwnerList()
Sort by rolling stock owner

Returns:
list of RollingStock ids ordered by RollingStock owner

getByValueList

public List<String> getByValueList()
Sort by rolling stock value

Returns:
list of RollingStock ids ordered by value

getByRfidList

public List<String> getByRfidList()
Sort by rolling stock RFID

Returns:
list of RollingStock ids ordered by RFIDs

getByList

protected List<String> getByList(List<String> sortIn,
                                 int attribute)

getRsAttribute

protected Object getRsAttribute(RollingStock rs,
                                int attribute)

getAvailableTrainList

public List<String> getAvailableTrainList(Train train)
Return a list available rolling stock (no assigned train or rolling stock already assigned to this train) on a route, RollingStock is ordered least recently moved to most recently moved.

Parameters:
train -
Returns:
List of RollingStock ids with no assigned train on a route

getByTrainList

public List<String> getByTrainList(Train train)
Get a list of rolling stocks assigned to a train

Parameters:
train -
Returns:
List of RollingStock ids assigned to the train

sortList

protected List<String> sortList(List<String> list)

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener l)

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener l)

firePropertyChange

protected void firePropertyChange(String p,
                                  Object old,
                                  Object n)


Copyright © 1997 - 2011 JMRI Community.
JMRI, DecoderPro, PanelPro, SoundPro, DispatcherPro and associated logos are our trademarks.

Additional information on copyright, trademarks and licenses is linked here.
Site hosted by: Get JMRI Model Railroad Interface at SourceForge.net. Fast, secure and Free Open Source software downloads