Class DefaultConditionalManager
- java.lang.Object
-
- jmri.beans.PropertyChangeSupport
-
- jmri.beans.VetoableChangeSupport
-
- jmri.managers.AbstractManager<Conditional>
-
- jmri.managers.DefaultConditionalManager
-
- All Implemented Interfaces:
java.beans.PropertyChangeListener
,java.beans.VetoableChangeListener
,java.util.EventListener
,PropertyChangeFirer
,PropertyChangeProvider
,SilenceablePropertyChangeProvider
,VetoableChangeFirer
,VetoableChangeProvider
,ConditionalManager
,Manager<Conditional>
public class DefaultConditionalManager extends AbstractManager<Conditional> implements ConditionalManager
Basic Implementation of a ConditionalManager.Note that Conditionals always have an associated parent Logix.
Logix system names must begin with IX, and be followed by a string, usually, but not always, a number. The system names of Conditionals always begin with the parent Logix's system name, then there is a capital C and a number.
Conditional system names are set automatically when the Conditional is created. All alphabetic characters in a Conditional system name must be upper case. This is enforced when a new Conditional is created via
LogixTableAction
Conditional user names have specific requirements that are addressed in the
Conditional
class.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface jmri.Manager
Manager.ManagerDataEvent<E extends NamedBean>, Manager.ManagerDataListener<E extends NamedBean>, Manager.NameValidity
-
-
Field Summary
-
Fields inherited from class jmri.managers.AbstractManager
_beans, _tsys, _tuser, lastAutoNamedBeanRef, memo, paddedNumber, silenceableProperties, silencedProperties
-
Fields inherited from class jmri.beans.VetoableChangeSupport
vetoableChangeSupport
-
Fields inherited from class jmri.beans.PropertyChangeSupport
propertyChangeSupport
-
Fields inherited from interface jmri.Manager
ANALOGIOS, AUDIO, BLOCKBOSS, BLOCKS, CONDITIONALS, CTCDATA, ENTRYEXIT, IDTAGS, LAYOUTBLOCKS, LIGHTS, LOGIXNG_ANALOG_ACTIONS, LOGIXNG_ANALOG_EXPRESSIONS, LOGIXNG_CONDITIONALNGS, LOGIXNG_DIGITAL_ACTIONS, LOGIXNG_DIGITAL_BOOLEAN_ACTIONS, LOGIXNG_DIGITAL_EXPRESSIONS, LOGIXNG_GLOBAL_VARIABLES, LOGIXNG_MODULES, LOGIXNG_STRING_ACTIONS, LOGIXNG_STRING_EXPRESSIONS, LOGIXNG_TABLES, LOGIXNGS, LOGIXS, MEMORIES, METERFRAMES, METERS, OBLOCKS, PANELFILES, REPORTERS, ROUTES, SECTIONS, SENSORGROUPS, SENSORS, SIGNALGROUPS, SIGNALHEADS, SIGNALMASTLOGICS, SIGNALMASTS, STRINGIOS, TIMEBASE, TRANSITS, TURNOUTS, WARRANTS
-
-
Constructor Summary
Constructors Constructor Description DefaultConditionalManager(InternalSystemConnectionMemo memo)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addWhereUsed(java.lang.String target, java.lang.String reference)
Add a conditional reference to the array indicated by the target system name.Conditional
createNewConditional(java.lang.String systemName, java.lang.String userName)
Method to create a new Conditional if the Conditional does not exist If the parent Logix cannot be found, the userName cannot be checked, but the Conditional is still created.void
deleteConditional(Conditional c)
Remove an existing Conditional.void
displayWhereUsed()
Display the complete structure, used for debugging purposes.java.lang.String
getBeanTypeHandled(boolean plural)
Get the user-readable name of the type of NamedBean handled by this manager.Conditional
getBySystemName(java.lang.String name)
Locate an existing instance based on a system name.Conditional
getByUserName(java.lang.String key)
Locate an existing instance based on a user name.Conditional
getByUserName(Logix x, java.lang.String key)
Conditional
getConditional(java.lang.String name)
Conditional
getConditional(Logix x, java.lang.String name)
Method to get an existing Conditional.java.lang.Class<Conditional>
getNamedBeanClass()
Get the class of NamedBean supported by this Manager.java.util.SortedSet<Conditional>
getNamedBeanSet()
Create a named bean set for conditionals.Logix
getParentLogix(java.lang.String name)
Parses the Conditional system name to get the parent Logix system name, then gets the parent Logix, and returns it.java.util.List<java.lang.String>
getSystemNameListForLogix(Logix x)
Get a list of all Conditional system names with the specified Logix parentjava.util.ArrayList<java.lang.String>
getTargetList(java.lang.String reference)
Get the target system names used by this conditionaljava.util.ArrayList<java.lang.String>
getWhereUsed(java.lang.String target)
Get a list of conditional references for the indicated conditionaljava.util.HashMap<java.lang.String,java.util.ArrayList<java.lang.String>>
getWhereUsedMap()
Return a copy of the entire map.int
getXMLOrder()
Determine the order that types should be written when storing panel files.protected void
handleUserNameUniqueness(Conditional s)
Do not insist that Conditional user names are unique, unlike the usual NamedBean supportvoid
removeWhereUsed(java.lang.String target, java.lang.String reference)
Remove a conditional reference from the array indicated by the target system name.char
typeLetter()
-
Methods inherited from class jmri.managers.AbstractManager
addDataListener, checkNumeric, createSystemName, deleteBean, deregister, dispose, fireDataListenersAdded, fireDataListenersRemoved, fireVetoableChange, getAutoSystemName, getBySystemName, getKnownBeanProperties, getMemo, getNamedBean, getObjectCount, getOuterBean, getSystemPrefix, makeSystemName, propertyChange, register, registerSelf, registerUserName, removeDataListener, setDataListenerMute, setPropertyChangesSilenced, setRegisterSelf, updateAutoNumber, validSystemNameFormat, vetoableChange
-
Methods inherited from class jmri.beans.VetoableChangeSupport
addVetoableChangeListener, addVetoableChangeListener, fireVetoableChange, fireVetoableChange, fireVetoableChange, getVetoableChangeListeners, getVetoableChangeListeners, removeVetoableChangeListener, removeVetoableChangeListener
-
Methods inherited from class jmri.beans.PropertyChangeSupport
addPropertyChangeListener, addPropertyChangeListener, fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getPropertyChangeListeners, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface jmri.ConditionalManager
dispose
-
Methods inherited from interface jmri.Manager
addDataListener, deleteBean, deregister, getBeanTypeHandled, getEntryToolTip, getKnownBeanProperties, getMemo, getNamedBean, getObjectCount, getSubSystemNamePrefix, getSystemNamePrefix, getSystemPrefix, isValidSystemNameFormat, makeSystemName, makeSystemName, makeSystemName, register, removeDataListener, setDataListenerMute, validateBadCharsInSystemNameFormat, validateIntegerSystemNameFormat, validateNmraAccessorySystemNameFormat, validateSystemNameFormat, validateSystemNameFormat, validateSystemNameFormatOnlyNumeric, validateSystemNamePrefix, validateTrimmedMin1NumberSystemNameFormat, validateTrimmedSystemNameFormat, validateUppercaseTrimmedSystemNameFormat, validSystemNameFormat
-
Methods inherited from interface jmri.beans.PropertyChangeProvider
addPropertyChangeListener, addPropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener
-
Methods inherited from interface jmri.beans.SilenceablePropertyChangeProvider
setPropertyChangesSilenced
-
Methods inherited from interface jmri.beans.VetoableChangeProvider
addVetoableChangeListener, addVetoableChangeListener, getVetoableChangeListeners, getVetoableChangeListeners, removeVetoableChangeListener, removeVetoableChangeListener
-
-
-
-
Constructor Detail
-
DefaultConditionalManager
public DefaultConditionalManager(InternalSystemConnectionMemo memo)
-
-
Method Detail
-
getXMLOrder
public int getXMLOrder()
Description copied from interface:Manager
Determine the order that types should be written when storing panel files. Uses one of the constants defined in this class.Yes, that's an overly-centralized methodology, but it works for now.
- Specified by:
getXMLOrder
in interfaceManager<Conditional>
- Returns:
- write order for this Manager; larger is later.
-
typeLetter
public char typeLetter()
- Specified by:
typeLetter
in interfaceManager<Conditional>
- Returns:
- The type letter for a specific implementation
-
createNewConditional
public Conditional createNewConditional(java.lang.String systemName, java.lang.String userName)
Method to create a new Conditional if the Conditional does not exist If the parent Logix cannot be found, the userName cannot be checked, but the Conditional is still created. The scenario can happen when a Logix is loaded from a file after its Conditionals.- Specified by:
createNewConditional
in interfaceConditionalManager
- Parameters:
systemName
- properly formatted system name for the new ConditionaluserName
- must not be null, use "" instead- Returns:
- null if a Conditional with the same systemName or userName already exists, or if there is trouble creating a new Conditional
-
handleUserNameUniqueness
protected void handleUserNameUniqueness(Conditional s)
Do not insist that Conditional user names are unique, unlike the usual NamedBean support- Overrides:
handleUserNameUniqueness
in classAbstractManager<Conditional>
- Parameters:
s
- the bean to register
-
getParentLogix
public Logix getParentLogix(java.lang.String name)
Parses the Conditional system name to get the parent Logix system name, then gets the parent Logix, and returns it. For sensor groups, the parent Logix name is 'SYS'. LRoutes and exported Routes (RTX prefix) require special logic- Specified by:
getParentLogix
in interfaceConditionalManager
- Parameters:
name
- system name of Conditionals- Returns:
- the parent Logix or null
-
deleteConditional
public void deleteConditional(Conditional c)
Remove an existing Conditional. Parent Logix must have been deactivated before invoking this.- Specified by:
deleteConditional
in interfaceConditionalManager
- Parameters:
c
- the conditional to remove
-
getConditional
public Conditional getConditional(Logix x, java.lang.String name)
Method to get an existing Conditional. First looks up assuming that name is a User Name. Note: the parent Logix must be passed in x for user name lookup. If this fails, or if x == null, looks up assuming that name is a System Name. If both fail, returns null.- Specified by:
getConditional
in interfaceConditionalManager
- Parameters:
x
- parent Logix (may be null)name
- name to look up- Returns:
- null if no match found
-
getConditional
public Conditional getConditional(java.lang.String name)
- Specified by:
getConditional
in interfaceConditionalManager
-
getByUserName
public Conditional getByUserName(java.lang.String key)
Description copied from class:AbstractManager
Locate an existing instance based on a user name.- Specified by:
getByUserName
in interfaceConditionalManager
- Specified by:
getByUserName
in interfaceManager<Conditional>
- Overrides:
getByUserName
in classAbstractManager<Conditional>
- Parameters:
key
- System Name of the required NamedBean- Returns:
- requested NamedBean object or null if none exists
-
getByUserName
public Conditional getByUserName(Logix x, java.lang.String key)
- Specified by:
getByUserName
in interfaceConditionalManager
-
getBySystemName
public Conditional getBySystemName(java.lang.String name)
Description copied from class:AbstractManager
Locate an existing instance based on a system name.- Specified by:
getBySystemName
in interfaceConditionalManager
- Specified by:
getBySystemName
in interfaceManager<Conditional>
- Overrides:
getBySystemName
in classAbstractManager<Conditional>
- Parameters:
name
- System Name of the required NamedBean- Returns:
- requested NamedBean object or null if none exists
-
getSystemNameListForLogix
public java.util.List<java.lang.String> getSystemNameListForLogix(Logix x)
Get a list of all Conditional system names with the specified Logix parent- Specified by:
getSystemNameListForLogix
in interfaceConditionalManager
- Parameters:
x
- the logix- Returns:
- a list of Conditional system names
-
getNamedBeanSet
@Nonnull public java.util.SortedSet<Conditional> getNamedBeanSet()
Create a named bean set for conditionals. This requires special logic since conditional beans are not registered.- Specified by:
getNamedBeanSet
in interfaceManager<Conditional>
- Overrides:
getNamedBeanSet
in classAbstractManager<Conditional>
- Returns:
- a sorted named bean set of conditionals.
- Since:
- 4.17.5
-
getBeanTypeHandled
@Nonnull public java.lang.String getBeanTypeHandled(boolean plural)
Description copied from interface:Manager
Get the user-readable name of the type of NamedBean handled by this manager.For instance, in the code where we are dealing with just a bean and a message that needs to be passed to the user or in a log.
- Specified by:
getBeanTypeHandled
in interfaceManager<Conditional>
- Parameters:
plural
- true to return plural form of the type; false to return singular form- Returns:
- a string of the bean type that the manager handles, eg Turnout, Sensor etc
-
getNamedBeanClass
public java.lang.Class<Conditional> getNamedBeanClass()
Get the class of NamedBean supported by this Manager. This should be the generic class used in the Manager's class declaration.- Specified by:
getNamedBeanClass
in interfaceManager<Conditional>
- Returns:
- the class supported by this Manager.
-
getWhereUsedMap
public java.util.HashMap<java.lang.String,java.util.ArrayList<java.lang.String>> getWhereUsedMap()
Return a copy of the entire map. Used byLogixTableAction.buildWhereUsedListing()
- Specified by:
getWhereUsedMap
in interfaceConditionalManager
- Returns:
- a copy of the map
- Since:
- 4.7.4
-
addWhereUsed
public void addWhereUsed(java.lang.String target, java.lang.String reference)
Add a conditional reference to the array indicated by the target system name.- Specified by:
addWhereUsed
in interfaceConditionalManager
- Parameters:
target
- The system name for the target conditionalreference
- The system name of the conditional that contains the conditional reference- Since:
- 4.7.4
-
getWhereUsed
public java.util.ArrayList<java.lang.String> getWhereUsed(java.lang.String target)
Get a list of conditional references for the indicated conditional- Specified by:
getWhereUsed
in interfaceConditionalManager
- Parameters:
target
- The target conditional for a conditional reference- Returns:
- an ArrayList or null if none
- Since:
- 4.7.4
-
removeWhereUsed
public void removeWhereUsed(java.lang.String target, java.lang.String reference)
Remove a conditional reference from the array indicated by the target system name.- Specified by:
removeWhereUsed
in interfaceConditionalManager
- Parameters:
target
- The system name for the target conditionalreference
- The system name of the conditional that contains the conditional reference- Since:
- 4.7.4
-
displayWhereUsed
public void displayWhereUsed()
Display the complete structure, used for debugging purposes.- Specified by:
displayWhereUsed
in interfaceConditionalManager
- Since:
- 4.7.4
-
getTargetList
public java.util.ArrayList<java.lang.String> getTargetList(java.lang.String reference)
Get the target system names used by this conditional- Specified by:
getTargetList
in interfaceConditionalManager
- Parameters:
reference
- The system name of the conditional the refers to other conditionals.- Returns:
- a list of the target conditionals
- Since:
- 4.7.4
-
-