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
LogixTableActionConditional user names have specific requirements that are addressed in the
Conditionalclass.
-
-
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, PROPERTY_BEANS, PROPERTY_CAN_DELETE, PROPERTY_DISPLAY_LIST_NAME, PROPERTY_DO_DELETE, PROPERTY_DO_NOT_DELETE, PROPERTY_LENGTH, 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 voidaddWhereUsed(java.lang.String target, java.lang.String reference)Add a conditional reference to the array indicated by the target system name.ConditionalcreateNewConditional(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.voiddeleteConditional(Conditional c)Remove an existing Conditional.voiddisplayWhereUsed()Display the complete structure, used for debugging purposes.java.lang.StringgetBeanTypeHandled(boolean plural)Get the user-readable name of the type of NamedBean handled by this manager.ConditionalgetBySystemName(java.lang.String name)Locate an existing instance based on a system name.ConditionalgetByUserName(java.lang.String key)Locate an existing instance based on a user name.ConditionalgetByUserName(Logix x, java.lang.String key)ConditionalgetConditional(java.lang.String name)ConditionalgetConditional(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.LogixgetParentLogix(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.intgetXMLOrder()Determine the order that types should be written when storing panel files.protected voidhandleUserNameUniqueness(Conditional s)Do not insist that Conditional user names are unique, unlike the usual NamedBean supportvoidremoveWhereUsed(java.lang.String target, java.lang.String reference)Remove a conditional reference from the array indicated by the target system name.chartypeLetter()-
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:ManagerDetermine 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:
getXMLOrderin interfaceManager<Conditional>- Returns:
- write order for this Manager; larger is later.
-
typeLetter
public char typeLetter()
- Specified by:
typeLetterin 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:
createNewConditionalin 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:
handleUserNameUniquenessin classAbstractManager<Conditional>- Parameters:
s- the bean to register
-
getParentLogix
@CheckForNull 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:
getParentLogixin 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:
deleteConditionalin interfaceConditionalManager- Parameters:
c- the conditional to remove
-
getConditional
@CheckForNull public Conditional getConditional(@CheckForNull 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:
getConditionalin interfaceConditionalManager- Parameters:
x- parent Logix (may be null)name- name to look up- Returns:
- null if no match found
-
getConditional
@CheckForNull public Conditional getConditional(java.lang.String name)
- Specified by:
getConditionalin interfaceConditionalManager
-
getByUserName
@CheckForNull public Conditional getByUserName(java.lang.String key)
Description copied from class:AbstractManagerLocate an existing instance based on a user name.- Specified by:
getByUserNamein interfaceConditionalManager- Specified by:
getByUserNamein interfaceManager<Conditional>- Overrides:
getByUserNamein classAbstractManager<Conditional>- Parameters:
key- System Name of the required NamedBean- Returns:
- requested NamedBean object or null if none exists
-
getByUserName
@CheckForNull public Conditional getByUserName(@CheckForNull Logix x, @Nonnull java.lang.String key)
- Specified by:
getByUserNamein interfaceConditionalManager
-
getBySystemName
@CheckForNull public Conditional getBySystemName(java.lang.String name)
Description copied from class:AbstractManagerLocate an existing instance based on a system name.- Specified by:
getBySystemNamein interfaceConditionalManager- Specified by:
getBySystemNamein interfaceManager<Conditional>- Overrides:
getBySystemNamein 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:
getSystemNameListForLogixin 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:
getNamedBeanSetin interfaceManager<Conditional>- Overrides:
getNamedBeanSetin 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:ManagerGet 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:
getBeanTypeHandledin 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:
getNamedBeanClassin 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:
getWhereUsedMapin 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:
addWhereUsedin 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:
getWhereUsedin 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:
removeWhereUsedin 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:
displayWhereUsedin 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:
getTargetListin 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
-
-