Class DefaultIdTagManager
- All Implemented Interfaces:
PropertyChangeListener,VetoableChangeListener,EventListener,PropertyChangeFirer,PropertyChangeProvider,SilenceablePropertyChangeProvider,VetoableChangeFirer,VetoableChangeProvider,Disposable,IdTagManager,Manager<IdTag>,ProvidingManager<IdTag>
- Direct Known Subclasses:
DefaultRailComManager,TranspondingTagManager
IdTagManager interface.- Since:
- 2.11.4
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface jmri.Manager
Manager.ManagerDataEvent<E extends NamedBean>, Manager.ManagerDataListener<E extends NamedBean>, Manager.NameValidity -
Field Summary
FieldsFields inherited from class jmri.managers.AbstractManager
_beans, _tsys, _tuser, lastAutoNamedBeanRef, memo, paddedNumber, silenceableProperties, silencedPropertiesFields inherited from class jmri.beans.VetoableChangeSupport
vetoableChangeSupportFields inherited from class jmri.beans.PropertyChangeSupport
propertyChangeSupportFields 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 -
Method Summary
Modifier and TypeMethodDescriptionprotected IdTagcreateNewIdTag(String systemName, String userName) voidderegister(IdTag s) Forget a NamedBean Object created outside the manager.voiddispose()Free resources when no longer used.getBeanTypeHandled(boolean plural) Get the user-readable name of the type of NamedBean handled by this manager.getBySystemName(String name) Locate an existing instance based on a system name.getByTagID(String tagID) Locate an instance based on a tag ID.getByUserName(String key) Locate an existing instance based on a user name.Locate via tag ID, then by user name, and finally system name if needed.Get the class of NamedBean supported by this Manager.Provide an unmodifiable SortedSet of NamedBeans in system-name order.intGet the count of managed objects.getTagsForReporter(Reporter reporter, long threshold) Get a list of all IdTags seen by a specified Reporter within a specific time threshold from the most recently seen.intDetermine the order that types should be written when storing panel files.voidinit()Perform initialization.protected voidbooleanDetermines if fast clock times should be recorded for when a given IdTag was last seen.booleanDetermines if the manager has been initialized.booleanDetermines if the state of known IdTags should be stored.Provide ID Tag by UserName then SystemName, creates new IdTag if not found.voidThe PropertyChangeListener interface in this class is intended to keep track of user name changes to individual NamedBeans.Get an existing instance via user name, then system name; if no matching instance is found, create a new NameBean from the system name.provideIdTag(String name) Locate via tag ID, then user name, and finally system name if needed.voidvoidRemember a NamedBean Object created outside the manager.protected voidBy default, register this manager to store as configuration information.voidsetFastClockUsed(boolean fastClock) Define if the manager should use the fast clock when setting the times when a given IdTag was last seen.voidsetStateStored(boolean state) Define if the manager should persist details of when and where all known IdTags were seen.charvoidMethods inherited from class jmri.managers.AbstractManager
addDataListener, checkNumeric, createSystemName, deleteBean, fireDataListenersAdded, fireDataListenersRemoved, fireVetoableChange, getAutoSystemName, getBySystemName, getKnownBeanProperties, getMemo, getNamedBean, getOuterBean, getSystemPrefix, handleUserNameUniqueness, makeSystemName, registerUserName, removeDataListener, setDataListenerMute, setPropertyChangesSilenced, setRegisterSelf, updateAutoNumber, validSystemNameFormat, vetoableChangeMethods inherited from class jmri.beans.VetoableChangeSupport
addVetoableChangeListener, addVetoableChangeListener, fireVetoableChange, fireVetoableChange, fireVetoableChange, getVetoableChangeListeners, getVetoableChangeListeners, removeVetoableChangeListener, removeVetoableChangeListenerMethods inherited from class jmri.beans.PropertyChangeSupport
addPropertyChangeListener, addPropertyChangeListener, fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getPropertyChangeListeners, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListenerMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface jmri.Manager
addDataListener, deleteBean, getBeanTypeHandled, getEntryToolTip, getKnownBeanProperties, getMemo, getNamedBean, getSubSystemNamePrefix, getSystemNamePrefix, getSystemPrefix, isValidSystemNameFormat, makeSystemName, makeSystemName, makeSystemName, removeDataListener, setDataListenerMute, validateBadCharsInSystemNameFormat, validateIntegerSystemNameFormat, validateNmraAccessorySystemNameFormat, validateSystemNameFormat, validateSystemNameFormat, validateSystemNameFormatOnlyNumeric, validateSystemNamePrefix, validateTrimmedMin1NumberSystemNameFormat, validateTrimmedSystemNameFormat, validateUppercaseTrimmedSystemNameFormat, validSystemNameFormatMethods inherited from interface jmri.beans.PropertyChangeProvider
addPropertyChangeListener, addPropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListenerMethods inherited from interface jmri.beans.SilenceablePropertyChangeProvider
setPropertyChangesSilencedMethods inherited from interface jmri.beans.VetoableChangeProvider
addVetoableChangeListener, addVetoableChangeListener, getVetoableChangeListeners, getVetoableChangeListeners, removeVetoableChangeListener, removeVetoableChangeListener
-
Field Details
-
dirty
-
PROPERTY_INITIALISED
- See Also:
-
-
Constructor Details
-
DefaultIdTagManager
-
-
Method Details
-
getXMLOrder
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:
getXMLOrderin interfaceManager<IdTag>- Returns:
- write order for this Manager; larger is later.
-
isInitialised
Determines if the manager has been initialized.- Specified by:
isInitialisedin interfaceIdTagManager- Returns:
- state of initialization
-
init
Perform initialization.- Specified by:
initin interfaceIdTagManager
-
initShutdownTask
-
registerSelf
By default, register this manager to store as configuration information. Override to change that. Don't want to store this information- Overrides:
registerSelfin classAbstractManager<IdTag>
-
typeLetter
- Specified by:
typeLetterin interfaceManager<IdTag>- Returns:
- The type letter for a specific implementation
-
provide
Get an existing instance via user name, then system name; if no matching instance is found, create a new NameBean from the system name.If the name is a valid system name, it will be used for the new NamedBean. Otherwise, the
Manager.makeSystemName(java.lang.String)method will attempt to turn it into a valid system name which the manager will attempt to use. If that fails, an exception is thrown.This is similar to the specific methods found in certain type-specific managers:
TurnoutManager.provideTurnout(java.lang.String),SensorManager.provideSensor(java.lang.String), et al. Those might be more mnemonic; this one is more generic. Neither is preferred nor deprecated; use your choice.- Specified by:
providein interfaceProvidingManager<IdTag>- Parameters:
name- User name, system name, or address which can be promoted to system name- Returns:
- Never null
- Throws:
IllegalArgumentException- if NamedBean doesn't already exist and the manager cannot create it due to an illegal name or name that can't be parsed.
-
getNamedBeanSet
Provide an unmodifiable SortedSet of NamedBeans in system-name order.Note: This is the fastest of the accessors, and is the only long-term form.
Note: This is a live set; the contents are kept up to date
- Specified by:
getNamedBeanSetin interfaceManager<IdTag>- Overrides:
getNamedBeanSetin classAbstractManager<IdTag>- Returns:
- Unmodifiable access to a SortedSet of NamedBeans
-
getObjectCount
Get the count of managed objects.- Specified by:
getObjectCountin interfaceManager<IdTag>- Overrides:
getObjectCountin classAbstractManager<IdTag>- Returns:
- the number of managed objects
-
provideIdTag
Locate via tag ID, then user name, and finally system name if needed. If that fails, create a new IdTag. If the name is a valid system name, it will be used for the new IdTag. Otherwise, the makeSystemName method will attempt to turn it into a valid system name.- Specified by:
provideIdTagin interfaceIdTagManager- Parameters:
name- Tag ID, user name, system name, or address which can be promoted to system name- Returns:
- A tag ID
- Throws:
IllegalArgumentException- if IdTag doesn't already exist and the manager cannot create the IdTag due to an illegal name or name that can't be parsed.
-
getIdTag
Locate via tag ID, then by user name, and finally system name if needed. If that fails, return null- Specified by:
getIdTagin interfaceIdTagManager- Parameters:
name- tag name being requested- Returns:
- null if no match found
-
getBySystemName
Locate an existing instance based on a system name.- Specified by:
getBySystemNamein interfaceIdTagManager- Specified by:
getBySystemNamein interfaceManager<IdTag>- Overrides:
getBySystemNamein classAbstractManager<IdTag>- Parameters:
name- System Name of the required NamedBean- Returns:
- requested NamedBean object or null if none exists
-
getByUserName
Locate an existing instance based on a user name.- Specified by:
getByUserNamein interfaceIdTagManager- Specified by:
getByUserNamein interfaceManager<IdTag>- Overrides:
getByUserNamein classAbstractManager<IdTag>- Parameters:
key- System Name of the required NamedBean- Returns:
- requested NamedBean object or null if none exists
-
getByTagID
Locate an instance based on a tag ID. Returns null if no instance already exists.- Specified by:
getByTagIDin interfaceIdTagManager- Parameters:
tagID- tag ID being requested- Returns:
- requested IdTag object or null if none exists
-
createNewIdTag
@Nonnull protected IdTag createNewIdTag(String systemName, String userName) throws IllegalArgumentException - Throws:
IllegalArgumentException
-
newIdTag
@Nonnull public IdTag newIdTag(@Nonnull String systemName, @CheckForNull String userName) throws IllegalArgumentException Provide ID Tag by UserName then SystemName, creates new IdTag if not found. Return an instance with the specified system and user names. Note that two calls with the same arguments will get the same instance; there is only one IdTag object representing a given physical IdTag and therefore only one with a specific system or user name.This will always return a valid object reference; a new object will be created if necessary. In that case:
- If a null reference is given for user name, no user name will be associated with the IdTag object created; a valid system name must be provided
- If both are provided, the system name defines the hardware access of the desired IdTag, and the user address is associated with it. The system name must be valid.
- Specified by:
newIdTagin interfaceIdTagManager- Parameters:
systemName- the system nameuserName- the user name- Returns:
- requested IdTag object (never null)
- Throws:
IllegalArgumentException- if cannot create the IdTag due to e.g. an illegal name or name that can't be parsed.
-
register
Remember a NamedBean Object created outside the manager.The non-system-specific SignalHeadManagers use this method extensively.
-
deregister
Forget a NamedBean Object created outside the manager.The non-system-specific RouteManager uses this method.
- Specified by:
deregisterin interfaceManager<IdTag>- Overrides:
deregisterin classAbstractManager<IdTag>- Parameters:
s- the bean
-
propertyChange
The PropertyChangeListener interface in this class is intended to keep track of user name changes to individual NamedBeans. It is not completely implemented yet. In particular, listeners are not added to newly registered objects.- Specified by:
propertyChangein interfacePropertyChangeListener- Overrides:
propertyChangein classAbstractManager<IdTag>- Parameters:
e- the event
-
writeIdTagDetails
- Throws:
IOException
-
readIdTagDetails
-
setStateStored
Define if the manager should persist details of when and where all known IdTags were seen.- Specified by:
setStateStoredin interfaceIdTagManager- Parameters:
state- True to store; False to omit
-
isStateStored
Determines if the state of known IdTags should be stored.- Specified by:
isStateStoredin interfaceIdTagManager- Returns:
- True to store state; False to discard state
-
setFastClockUsed
Define if the manager should use the fast clock when setting the times when a given IdTag was last seen.- Specified by:
setFastClockUsedin interfaceIdTagManager- Parameters:
fastClock- True to use the fast clock; False to use the system clock
-
isFastClockUsed
Determines if fast clock times should be recorded for when a given IdTag was last seen.- Specified by:
isFastClockUsedin interfaceIdTagManager- Returns:
- True to use the fast clock; False to use the system clock
-
getTagsForReporter
Get a list of all IdTags seen by a specified Reporter within a specific time threshold from the most recently seen.- Specified by:
getTagsForReporterin interfaceIdTagManager- Parameters:
reporter- Reporter to return list forthreshold- Time threshold (in ms)- Returns:
- List of matching IdTags
-
dispose
Free resources when no longer used. Specifically, remove all references to and from this object, so it can be garbage-collected.- Specified by:
disposein interfaceDisposable- Specified by:
disposein interfaceManager<IdTag>- Overrides:
disposein classAbstractManager<IdTag>
-
getBeanTypeHandled
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:
getBeanTypeHandledin interfaceManager<IdTag>- 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
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<IdTag>- Returns:
- the class supported by this Manager.
-