Class DefaultAudioSourceManager
- java.lang.Object
-
- jmri.jmrit.audio.DefaultAudioSourceManager
-
- All Implemented Interfaces:
AudioManager,AudioSourceManager,PropertyChangeProvider,SilenceablePropertyChangeProvider,VetoableChangeProvider,Manager<Audio>
public class DefaultAudioSourceManager extends java.lang.Object implements AudioSourceManager
The default AudioSourceManager.
-
-
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 interface jmri.AudioManager
MAX_BUFFERS, MAX_LISTENERS, MAX_SOURCES
-
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 DefaultAudioSourceManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddDataListener(Manager.ManagerDataListener<Audio> e)Register aManager.ManagerDataListenerto hear about adding or removing items from the list of NamedBeans.voidaddPropertyChangeListener(java.beans.PropertyChangeListener listener)Add aPropertyChangeListenerto the listener list.voidaddPropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)Add aPropertyChangeListenerfor a specific property.voidaddVetoableChangeListener(java.beans.VetoableChangeListener listener)Add aVetoableChangeListenerto the listener list.voidaddVetoableChangeListener(java.lang.String propertyName, java.beans.VetoableChangeListener listener)Add aVetoableChangeListenerfor a specific property.voidcleanup()Perform any clean-up operationsvoiddeleteBean(Audio n, java.lang.String property)Method for a UI to delete a bean.voidderegister(Audio n)Forget a NamedBean Object created outside the manager.voiddispose()Free resources when no longer used.AudioFactorygetActiveAudioFactory()Returns the currently active AudioFactory object.AudiogetAudio(java.lang.String name)Get an existing Audio or return null if it doesn't exists.java.lang.StringgetBeanTypeHandled(boolean plural)Get the user-readable name of the type of NamedBean handled by this manager.AudiogetBySystemName(java.lang.String systemName)Get the Audio with the given system name or return null if no instance already exists.AudiogetByUserName(java.lang.String userName)Get the Audio with the given user name or return null if no instance already exists.SystemConnectionMemogetMemo()Get the system connection for this manager.AudiogetNamedBean(java.lang.String name)Locate an existing instance based on a name.java.lang.Class<Audio>getNamedBeanClass()Get the class of NamedBean supported by this Manager.java.util.SortedSet<Audio>getNamedBeanSet()Provide an unmodifiable SortedSet of NamedBeans in system-name order.java.util.SortedSet<Audio>getNamedBeanSet(char subType)Get the specified Audio sub-type NamedBeans.intgetObjectCount()Get the count of managed objects.java.beans.PropertyChangeListener[]getPropertyChangeListeners()Get allPropertyChangeListeners currently attached to this object.java.beans.PropertyChangeListener[]getPropertyChangeListeners(java.lang.String propertyName)Get allPropertyChangeListeners currently listening to changes to the specified property.java.lang.StringgetSystemPrefix()Provide access to the system prefix string.java.beans.VetoableChangeListener[]getVetoableChangeListeners()Get allVetoableChangeListeners currently attached to this object.java.beans.VetoableChangeListener[]getVetoableChangeListeners(java.lang.String propertyName)Get allVetoableChangeListeners currently listening to changes to the specified property.intgetXMLOrder()Determine the order that types should be written when storing panel files.voidinit()Perform any initialisation operationsbooleanisInitialised()Determine if this AudioManager is initialisedAudionewAudio(java.lang.String systemName, java.lang.String userName)Return an Audio with the specified system and user names.AudioprovideAudio(java.lang.String name)Get the Audio with the user name, then system name if needed; if that fails, create a new Audio.voidregister(Audio n)Remember a NamedBean Object created outside the manager.voidremoveDataListener(Manager.ManagerDataListener<Audio> e)Unregister a previously-addedManager.ManagerDataListener.voidremovePropertyChangeListener(java.beans.PropertyChangeListener listener)Remove the specified listener from this object.voidremovePropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)Remove the specified listener of the specified property from this object.voidremoveVetoableChangeListener(java.beans.VetoableChangeListener listener)Remove the specified listener from this object.voidremoveVetoableChangeListener(java.lang.String propertyName, java.beans.VetoableChangeListener listener)Remove the specified listener of the specified property from this object.voidsetPropertyChangesSilenced(java.lang.String propertyName, boolean silenced)Suppress sendingPropertyChangeEvents for the named property.chartypeLetter()-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface jmri.Manager
getBeanTypeHandled, getEntryToolTip, getKnownBeanProperties, getSubSystemNamePrefix, getSystemNamePrefix, isValidSystemNameFormat, makeSystemName, makeSystemName, makeSystemName, setDataListenerMute, validateBadCharsInSystemNameFormat, validateIntegerSystemNameFormat, validateNmraAccessorySystemNameFormat, validateSystemNameFormat, validateSystemNameFormat, validateSystemNameFormatOnlyNumeric, validateSystemNamePrefix, validateTrimmedMin1NumberSystemNameFormat, validateTrimmedSystemNameFormat, validateUppercaseTrimmedSystemNameFormat, validSystemNameFormat
-
-
-
-
Constructor Detail
-
DefaultAudioSourceManager
public DefaultAudioSourceManager()
-
-
Method Detail
-
provideAudio
public Audio provideAudio(java.lang.String name) throws AudioException
Get the Audio with the user name, then system name if needed; if that fails, create a new Audio. If the name is a valid system name, it will be used for the new Audio. Otherwise, the makeSystemName method will attempt to turn it into a valid system name.- Specified by:
provideAudioin interfaceAudioManager- Parameters:
name- User name or system name to match, or which can be promoted to system name- Returns:
- Never null under normal circumstances
- Throws:
AudioException- if error occurs during creation
-
getAudio
public Audio getAudio(java.lang.String name)
Get an existing Audio or return null if it doesn't exists. Locates via user name, then system name if needed.- Specified by:
getAudioin interfaceAudioManager- Parameters:
name- User name or system name to match- Returns:
- null if no match found
-
getBySystemName
public Audio getBySystemName(java.lang.String systemName)
Get the Audio with the given system name or return null if no instance already exists.- Specified by:
getBySystemNamein interfaceAudioManager- Specified by:
getBySystemNamein interfaceManager<Audio>- Parameters:
systemName- Audio object system name (such as IAS1 or IAB4)- Returns:
- requested Audio object or null if none exists
-
getByUserName
public Audio getByUserName(java.lang.String userName)
Get the Audio with the given user name or return null if no instance already exists.- Specified by:
getByUserNamein interfaceAudioManager- Specified by:
getByUserNamein interfaceManager<Audio>- Parameters:
userName- Audio object user name- Returns:
- requested Audio object or null if none exists
-
newAudio
public Audio newAudio(java.lang.String systemName, java.lang.String userName) throws AudioException
Return an Audio with the specified system and user names. Note that two calls with the same arguments will get the same instance; there is only one Audio object representing a given physical Audio 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 Audio object created; a valid system name must be provided
- If both names are provided, the system name defines the hardware access of the desired Audio, and the user address is associated with it. The system name must be valid.
- Specified by:
newAudioin interfaceAudioManager- Parameters:
systemName- Audio object system name (such as IAS1 or IAB4)userName- Audio object user name- Returns:
- requested Audio object (never null)
- Throws:
AudioException- if error occurs during creation
-
getActiveAudioFactory
public AudioFactory getActiveAudioFactory()
Returns the currently active AudioFactory object.An Audio factory is responsible for the creation of implementation specific audio objects.
- Specified by:
getActiveAudioFactoryin interfaceAudioManager- Returns:
- current active AudioFactory object
-
getNamedBeanSet
public java.util.SortedSet<Audio> getNamedBeanSet(char subType)
Get the specified Audio sub-type NamedBeans.- Specified by:
getNamedBeanSetin interfaceAudioManager- Parameters:
subType- sub-type to retrieve- Returns:
- Unmodifiable access to a SortedSet of NamedBeans for the specified Audio sub-type .
-
init
public void init()
Perform any initialisation operations- Specified by:
initin interfaceAudioManager
-
cleanup
public void cleanup()
Perform any clean-up operations- Specified by:
cleanupin interfaceAudioManager
-
isInitialised
public boolean isInitialised()
Determine if this AudioManager is initialised- Specified by:
isInitialisedin interfaceAudioManager- Returns:
- true if initialised
-
getMemo
public SystemConnectionMemo getMemo()
Get the system connection for this manager.
-
getSystemPrefix
public java.lang.String getSystemPrefix()
Provide access to the system prefix string. This was previously called the "System letter"- Specified by:
getSystemPrefixin interfaceManager<Audio>- Returns:
- the system prefix
-
typeLetter
public char typeLetter()
- Specified by:
typeLetterin interfaceManager<Audio>- Returns:
- The type letter for a specific implementation
-
getNamedBeanClass
public java.lang.Class<Audio> 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<Audio>- Returns:
- the class supported by this Manager.
-
dispose
public void dispose()
Free resources when no longer used. Specifically, remove all references to and from this object, so it can be garbage-collected.
-
getObjectCount
public int getObjectCount()
Get the count of managed objects.- Specified by:
getObjectCountin interfaceManager<Audio>- Returns:
- the number of managed objects
-
getNamedBeanSet
public java.util.SortedSet<Audio> 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
Note that this method only returns audio sources.
- Specified by:
getNamedBeanSetin interfaceManager<Audio>- Returns:
- Unmodifiable access to a SortedSet of NamedBeans
-
getNamedBean
public Audio getNamedBean(java.lang.String name)
Locate an existing instance based on a name.- Specified by:
getNamedBeanin interfaceManager<Audio>- Parameters:
name- User Name or System Name of the required NamedBean- Returns:
- requested NamedBean object or null if none exists
-
deleteBean
public void deleteBean(Audio n, java.lang.String property) throws java.beans.PropertyVetoException
Method for a UI to delete a bean.The UI should first request a "CanDelete", this will return a list of locations (and descriptions) where the bean is in use via throwing a VetoException, then if that comes back clear, or the user agrees with the actions, then a "DoDelete" can be called which inform the listeners to delete the bean, then it will be deregistered and disposed of.
If a property name of "DoNotDelete" is thrown back in the VetoException then the delete process should be aborted.
- Specified by:
deleteBeanin interfaceManager<Audio>- Parameters:
n- The NamedBean to be deletedproperty- The programmatic name of the request. "CanDelete" will enquire with all listeners if the item can be deleted. "DoDelete" tells the listener to delete the item- Throws:
java.beans.PropertyVetoException- If the recipients wishes the delete to be aborted (see above)
-
register
public void register(Audio n)
Remember a NamedBean Object created outside the manager.The non-system-specific SignalHeadManagers use this method extensively.
-
deregister
public void deregister(Audio n)
Forget a NamedBean Object created outside the manager.The non-system-specific RouteManager uses this method.
- Specified by:
deregisterin interfaceManager<Audio>- Parameters:
n- the bean
-
getXMLOrder
public int 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<Audio>- Returns:
- write order for this Manager; larger is later.
-
getBeanTypeHandled
public java.lang.String getBeanTypeHandled(boolean plural)
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<Audio>- 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
-
addDataListener
public void addDataListener(Manager.ManagerDataListener<Audio> e)
Register aManager.ManagerDataListenerto hear about adding or removing items from the list of NamedBeans.- Specified by:
addDataListenerin interfaceManager<Audio>- Parameters:
e- the data listener to add
-
removeDataListener
public void removeDataListener(Manager.ManagerDataListener<Audio> e)
Unregister a previously-addedManager.ManagerDataListener.- Specified by:
removeDataListenerin interfaceManager<Audio>- Parameters:
e- the data listener to remove- See Also:
Manager.addDataListener(ManagerDataListener)
-
setPropertyChangesSilenced
public void setPropertyChangesSilenced(java.lang.String propertyName, boolean silenced)
Suppress sendingPropertyChangeEvents for the named property.Stopping the suppression of sending change events may send a PropertyChangeEvent if the property changed while silenced, but otherwise should not fire a PropertyChangeEvent.
- Specified by:
setPropertyChangesSilencedin interfaceSilenceablePropertyChangeProvider- Parameters:
propertyName- the name of the property to mutesilenced- true if events are to be suppressed; false otherwise
-
addPropertyChangeListener
public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Add aPropertyChangeListenerto the listener list.- Specified by:
addPropertyChangeListenerin interfacePropertyChangeProvider- Parameters:
listener- The PropertyChangeListener to be added
-
addPropertyChangeListener
public void addPropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)
Add aPropertyChangeListenerfor a specific property.- Specified by:
addPropertyChangeListenerin interfacePropertyChangeProvider- Parameters:
propertyName- The name of the property to listen on.listener- The PropertyChangeListener to be added
-
getPropertyChangeListeners
public java.beans.PropertyChangeListener[] getPropertyChangeListeners()
Get allPropertyChangeListeners currently attached to this object.- Specified by:
getPropertyChangeListenersin interfacePropertyChangeProvider- Returns:
- An array of PropertyChangeListeners.
-
getPropertyChangeListeners
public java.beans.PropertyChangeListener[] getPropertyChangeListeners(java.lang.String propertyName)
Get allPropertyChangeListeners currently listening to changes to the specified property.- Specified by:
getPropertyChangeListenersin interfacePropertyChangeProvider- Parameters:
propertyName- the name of the property of interest- Returns:
- an array of PropertyChangeListeners
-
removePropertyChangeListener
public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Remove the specified listener from this object.- Specified by:
removePropertyChangeListenerin interfacePropertyChangeProvider- Parameters:
listener- ThePropertyChangeListenerto remove.
-
removePropertyChangeListener
public void removePropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)
Remove the specified listener of the specified property from this object.- Specified by:
removePropertyChangeListenerin interfacePropertyChangeProvider- Parameters:
propertyName- The name of the property to stop listening to.listener- ThePropertyChangeListenerto remove.
-
addVetoableChangeListener
public void addVetoableChangeListener(java.beans.VetoableChangeListener listener)
Add aVetoableChangeListenerto the listener list.- Specified by:
addVetoableChangeListenerin interfaceVetoableChangeProvider- Parameters:
listener- The VetoableChangeListener to be added
-
addVetoableChangeListener
public void addVetoableChangeListener(java.lang.String propertyName, java.beans.VetoableChangeListener listener)
Add aVetoableChangeListenerfor a specific property.- Specified by:
addVetoableChangeListenerin interfaceVetoableChangeProvider- Parameters:
propertyName- The name of the property to listen on.listener- The VetoableChangeListener to be added
-
getVetoableChangeListeners
public java.beans.VetoableChangeListener[] getVetoableChangeListeners()
Get allVetoableChangeListeners currently attached to this object.- Specified by:
getVetoableChangeListenersin interfaceVetoableChangeProvider- Returns:
- An array of VetoableChangeListeners.
-
getVetoableChangeListeners
public java.beans.VetoableChangeListener[] getVetoableChangeListeners(java.lang.String propertyName)
Get allVetoableChangeListeners currently listening to changes to the specified property.- Specified by:
getVetoableChangeListenersin interfaceVetoableChangeProvider- Parameters:
propertyName- The name of the property of interest- Returns:
- An array of VetoableChangeListeners.
-
removeVetoableChangeListener
public void removeVetoableChangeListener(java.beans.VetoableChangeListener listener)
Remove the specified listener from this object.- Specified by:
removeVetoableChangeListenerin interfaceVetoableChangeProvider- Parameters:
listener- TheVetoableChangeListenerto remove.
-
removeVetoableChangeListener
public void removeVetoableChangeListener(java.lang.String propertyName, java.beans.VetoableChangeListener listener)
Remove the specified listener of the specified property from this object.- Specified by:
removeVetoableChangeListenerin interfaceVetoableChangeProvider- Parameters:
propertyName- The name of the property to stop listening to.listener- TheVetoableChangeListenerto remove.
-
-