Class Schedule
- java.lang.Object
-
- jmri.beans.PropertyChangeSupport
-
- jmri.jmrit.operations.locations.schedules.Schedule
-
- All Implemented Interfaces:
java.beans.PropertyChangeListener
,java.util.EventListener
,PropertyChangeFirer
,PropertyChangeProvider
public class Schedule extends PropertyChangeSupport implements java.beans.PropertyChangeListener
Represents a car delivery schedule for a location
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.String
_comment
protected java.lang.String
_id
protected int
_IdNumber
protected java.lang.String
_name
protected java.util.Hashtable<java.lang.String,ScheduleItem>
_scheduleHashTable
protected int
_sequenceNum
static java.lang.String
DISPOSE
static java.lang.String
LISTCHANGE_CHANGED_PROPERTY
static java.lang.String
SCHEDULE_OKAY
-
Fields inherited from class jmri.beans.PropertyChangeSupport
propertyChangeSupport
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ScheduleItem
addItem(java.lang.String type)
Adds a car type to the end of this scheduleScheduleItem
addItem(java.lang.String carType, int sequence)
Add a schedule item at a specific place (sequence) in the schedule Allowable sequence numbers are 0 to max size of schedule. 0 = start of list.boolean
checkScheduleAttribute(java.lang.String attribute, java.lang.String carType, Car car)
java.lang.String
checkScheduleItem(ScheduleItem si, Car car, Track track)
java.lang.String
checkScheduleItemValid(ScheduleItem si, Track track)
java.lang.String
checkScheduleValid(Track track)
Check to see if schedule is valid for the track.void
deleteItem(ScheduleItem si)
Delete a ScheduleItemvoid
dispose()
java.lang.String
getComment()
java.lang.String
getId()
ScheduleItem
getItemById(java.lang.String id)
Get a ScheduleItem by idScheduleItem
getItemBySequenceId(int sequenceId)
ScheduleItem
getItemByType(java.lang.String carType)
Get item by car type (gets last schedule item with this type)java.util.List<ScheduleItem>
getItemsBySequenceList()
Get a list of ScheduleItems sorted by schedule orderjava.lang.String
getName()
int
getSize()
boolean
hasRandomItem()
void
moveItemDown(ScheduleItem si)
Places a ScheduleItem later in the schedulevoid
moveItemUp(ScheduleItem si)
Places a ScheduleItem earlier in the schedulevoid
propertyChange(java.beans.PropertyChangeEvent e)
void
register(ScheduleItem si)
Remember a NamedBean Object created outside the manager.void
resetHitCounts()
java.lang.String
searchSchedule(Car car, Track track)
void
setComment(java.lang.String comment)
protected void
setDirtyAndFirePropertyChange(java.lang.String p, java.lang.Object old, java.lang.Object n)
void
setName(java.lang.String name)
org.jdom2.Element
store()
Create an XML element to represent this Entry.java.lang.String
toString()
-
Methods inherited from class jmri.beans.PropertyChangeSupport
addPropertyChangeListener, addPropertyChangeListener, fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getPropertyChangeListeners, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener
-
-
-
-
Field Detail
-
_id
protected java.lang.String _id
-
_name
protected java.lang.String _name
-
_comment
protected java.lang.String _comment
-
_scheduleHashTable
protected java.util.Hashtable<java.lang.String,ScheduleItem> _scheduleHashTable
-
_IdNumber
protected int _IdNumber
-
_sequenceNum
protected int _sequenceNum
-
LISTCHANGE_CHANGED_PROPERTY
public static final java.lang.String LISTCHANGE_CHANGED_PROPERTY
- See Also:
- Constant Field Values
-
DISPOSE
public static final java.lang.String DISPOSE
- See Also:
- Constant Field Values
-
SCHEDULE_OKAY
public static final java.lang.String SCHEDULE_OKAY
- See Also:
- Constant Field Values
-
-
Method Detail
-
getId
public java.lang.String getId()
-
setName
public void setName(java.lang.String name)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
getName
public java.lang.String getName()
-
getSize
public int getSize()
-
setComment
public void setComment(java.lang.String comment)
-
getComment
public java.lang.String getComment()
-
dispose
public void dispose()
-
resetHitCounts
public void resetHitCounts()
-
hasRandomItem
public boolean hasRandomItem()
-
addItem
public ScheduleItem addItem(java.lang.String type)
Adds a car type to the end of this schedule- Parameters:
type
- The string car type to add.- Returns:
- ScheduleItem created for the car type added
-
addItem
public ScheduleItem addItem(java.lang.String carType, int sequence)
Add a schedule item at a specific place (sequence) in the schedule Allowable sequence numbers are 0 to max size of schedule. 0 = start of list.- Parameters:
carType
- The string car type name to add.sequence
- Where in the schedule to add the item.- Returns:
- schedule item
-
register
public void register(ScheduleItem si)
Remember a NamedBean Object created outside the manager.- Parameters:
si
- The schedule item to add.
-
deleteItem
public void deleteItem(ScheduleItem si)
Delete a ScheduleItem- Parameters:
si
- The scheduleItem to delete.
-
getItemByType
public ScheduleItem getItemByType(java.lang.String carType)
Get item by car type (gets last schedule item with this type)- Parameters:
carType
- The string car type to search for.- Returns:
- schedule item
-
getItemById
public ScheduleItem getItemById(java.lang.String id)
Get a ScheduleItem by id- Parameters:
id
- The string id of the ScheduleItem.- Returns:
- schedule item
-
getItemsBySequenceList
public java.util.List<ScheduleItem> getItemsBySequenceList()
Get a list of ScheduleItems sorted by schedule order- Returns:
- list of ScheduleItems ordered by sequence
-
moveItemUp
public void moveItemUp(ScheduleItem si)
Places a ScheduleItem earlier in the schedule- Parameters:
si
- The ScheduleItem to move.
-
moveItemDown
public void moveItemDown(ScheduleItem si)
Places a ScheduleItem later in the schedule- Parameters:
si
- The ScheduleItem to move.
-
getItemBySequenceId
public ScheduleItem getItemBySequenceId(int sequenceId)
-
checkScheduleValid
public java.lang.String checkScheduleValid(Track track)
Check to see if schedule is valid for the track.- Parameters:
track
- The track associated with this schedule- Returns:
- SCHEDULE_OKAY if schedule okay, otherwise an error message.
-
checkScheduleItemValid
public java.lang.String checkScheduleItemValid(ScheduleItem si, Track track)
-
searchSchedule
public java.lang.String searchSchedule(Car car, Track track)
-
checkScheduleItem
public java.lang.String checkScheduleItem(ScheduleItem si, Car car, Track track)
-
checkScheduleAttribute
public boolean checkScheduleAttribute(java.lang.String attribute, java.lang.String carType, Car car)
-
store
public org.jdom2.Element store()
Create an XML element to represent this Entry. This member has to remain synchronized with the detailed DTD in operations-config.xml.- Returns:
- Contents in a JDOM Element
-
propertyChange
public void propertyChange(java.beans.PropertyChangeEvent e)
- Specified by:
propertyChange
in interfacejava.beans.PropertyChangeListener
-
setDirtyAndFirePropertyChange
protected void setDirtyAndFirePropertyChange(java.lang.String p, java.lang.Object old, java.lang.Object n)
-
-