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, 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 void
addDataListener(Manager.ManagerDataListener<Audio> e)
Register aManager.ManagerDataListener
to hear about adding or removing items from the list of NamedBeans.void
addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Add aPropertyChangeListener
to the listener list.void
addPropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)
Add aPropertyChangeListener
for a specific property.void
addVetoableChangeListener(java.beans.VetoableChangeListener listener)
Add aVetoableChangeListener
to the listener list.void
addVetoableChangeListener(java.lang.String propertyName, java.beans.VetoableChangeListener listener)
Add aVetoableChangeListener
for a specific property.void
cleanup()
Perform any clean-up operationsvoid
deleteBean(Audio n, java.lang.String property)
Method for a UI to delete a bean.void
deregister(Audio n)
Forget a NamedBean Object created outside the manager.void
dispose()
Free resources when no longer used.AudioFactory
getActiveAudioFactory()
Returns the currently active AudioFactory object.Audio
getAudio(java.lang.String name)
Get an existing Audio or return null if it doesn't exists.java.lang.String
getBeanTypeHandled(boolean plural)
Get the user-readable name of the type of NamedBean handled by this manager.Audio
getBySystemName(java.lang.String systemName)
Get the Audio with the given system name or return null if no instance already exists.Audio
getByUserName(java.lang.String userName)
Get the Audio with the given user name or return null if no instance already exists.SystemConnectionMemo
getMemo()
Get the system connection for this manager.Audio
getNamedBean(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.int
getObjectCount()
Get the count of managed objects.java.beans.PropertyChangeListener[]
getPropertyChangeListeners()
Get allPropertyChangeListener
s currently attached to this object.java.beans.PropertyChangeListener[]
getPropertyChangeListeners(java.lang.String propertyName)
Get allPropertyChangeListener
s currently listening to changes to the specified property.java.lang.String
getSystemPrefix()
Provide access to the system prefix string.java.beans.VetoableChangeListener[]
getVetoableChangeListeners()
Get allVetoableChangeListener
s currently attached to this object.java.beans.VetoableChangeListener[]
getVetoableChangeListeners(java.lang.String propertyName)
Get allVetoableChangeListener
s currently listening to changes to the specified property.int
getXMLOrder()
Determine the order that types should be written when storing panel files.void
init()
Perform any initialisation operationsboolean
isInitialised()
Determine if this AudioManager is initialisedAudio
newAudio(java.lang.String systemName, java.lang.String userName)
Return an Audio with the specified system and user names.Audio
provideAudio(java.lang.String name)
Get the Audio with the user name, then system name if needed; if that fails, create a new Audio.void
register(Audio n)
Remember a NamedBean Object created outside the manager.void
removeDataListener(Manager.ManagerDataListener<Audio> e)
Unregister a previously-addedManager.ManagerDataListener
.void
removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Remove the specified listener from this object.void
removePropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)
Remove the specified listener of the specified property from this object.void
removeVetoableChangeListener(java.beans.VetoableChangeListener listener)
Remove the specified listener from this object.void
removeVetoableChangeListener(java.lang.String propertyName, java.beans.VetoableChangeListener listener)
Remove the specified listener of the specified property from this object.void
setPropertyChangesSilenced(java.lang.String propertyName, boolean silenced)
Suppress sendingPropertyChangeEvent
s for the named property.char
typeLetter()
-
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:
provideAudio
in 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:
getAudio
in 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:
getBySystemName
in interfaceAudioManager
- Specified by:
getBySystemName
in 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:
getByUserName
in interfaceAudioManager
- Specified by:
getByUserName
in 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:
newAudio
in 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:
getActiveAudioFactory
in interfaceAudioManager
- Returns:
- current active AudioFactory object
-
getNamedBeanSet
public java.util.SortedSet<Audio> getNamedBeanSet(char subType)
Get the specified Audio sub-type NamedBeans.- Specified by:
getNamedBeanSet
in 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:
init
in interfaceAudioManager
-
cleanup
public void cleanup()
Perform any clean-up operations- Specified by:
cleanup
in interfaceAudioManager
-
isInitialised
public boolean isInitialised()
Determine if this AudioManager is initialised- Specified by:
isInitialised
in 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:
getSystemPrefix
in interfaceManager<Audio>
- Returns:
- the system prefix
-
typeLetter
public char typeLetter()
- Specified by:
typeLetter
in 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:
getNamedBeanClass
in 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:
getObjectCount
in 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:
getNamedBeanSet
in 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:
getNamedBean
in 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:
deleteBean
in 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:
deregister
in 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:
getXMLOrder
in 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:
getBeanTypeHandled
in 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.ManagerDataListener
to hear about adding or removing items from the list of NamedBeans.- Specified by:
addDataListener
in interfaceManager<Audio>
- Parameters:
e
- the data listener to add
-
removeDataListener
public void removeDataListener(Manager.ManagerDataListener<Audio> e)
Unregister a previously-addedManager.ManagerDataListener
.- Specified by:
removeDataListener
in 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 sendingPropertyChangeEvent
s 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:
setPropertyChangesSilenced
in 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 aPropertyChangeListener
to the listener list.- Specified by:
addPropertyChangeListener
in interfacePropertyChangeProvider
- Parameters:
listener
- The PropertyChangeListener to be added
-
addPropertyChangeListener
public void addPropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)
Add aPropertyChangeListener
for a specific property.- Specified by:
addPropertyChangeListener
in interfacePropertyChangeProvider
- Parameters:
propertyName
- The name of the property to listen on.listener
- The PropertyChangeListener to be added
-
getPropertyChangeListeners
public java.beans.PropertyChangeListener[] getPropertyChangeListeners()
Get allPropertyChangeListener
s currently attached to this object.- Specified by:
getPropertyChangeListeners
in interfacePropertyChangeProvider
- Returns:
- An array of PropertyChangeListeners.
-
getPropertyChangeListeners
public java.beans.PropertyChangeListener[] getPropertyChangeListeners(java.lang.String propertyName)
Get allPropertyChangeListener
s currently listening to changes to the specified property.- Specified by:
getPropertyChangeListeners
in 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:
removePropertyChangeListener
in interfacePropertyChangeProvider
- Parameters:
listener
- ThePropertyChangeListener
to 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:
removePropertyChangeListener
in interfacePropertyChangeProvider
- Parameters:
propertyName
- The name of the property to stop listening to.listener
- ThePropertyChangeListener
to remove.
-
addVetoableChangeListener
public void addVetoableChangeListener(java.beans.VetoableChangeListener listener)
Add aVetoableChangeListener
to the listener list.- Specified by:
addVetoableChangeListener
in interfaceVetoableChangeProvider
- Parameters:
listener
- The VetoableChangeListener to be added
-
addVetoableChangeListener
public void addVetoableChangeListener(java.lang.String propertyName, java.beans.VetoableChangeListener listener)
Add aVetoableChangeListener
for a specific property.- Specified by:
addVetoableChangeListener
in interfaceVetoableChangeProvider
- Parameters:
propertyName
- The name of the property to listen on.listener
- The VetoableChangeListener to be added
-
getVetoableChangeListeners
public java.beans.VetoableChangeListener[] getVetoableChangeListeners()
Get allVetoableChangeListener
s currently attached to this object.- Specified by:
getVetoableChangeListeners
in interfaceVetoableChangeProvider
- Returns:
- An array of VetoableChangeListeners.
-
getVetoableChangeListeners
public java.beans.VetoableChangeListener[] getVetoableChangeListeners(java.lang.String propertyName)
Get allVetoableChangeListener
s currently listening to changes to the specified property.- Specified by:
getVetoableChangeListeners
in 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:
removeVetoableChangeListener
in interfaceVetoableChangeProvider
- Parameters:
listener
- TheVetoableChangeListener
to 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:
removeVetoableChangeListener
in interfaceVetoableChangeProvider
- Parameters:
propertyName
- The name of the property to stop listening to.listener
- TheVetoableChangeListener
to remove.
-
-