Package jmri.managers
Class AbstractAudioManager
- java.lang.Object
-
- jmri.beans.PropertyChangeSupport
-
- jmri.beans.VetoableChangeSupport
-
- jmri.managers.AbstractManager<Audio>
-
- jmri.managers.AbstractAudioManager
-
- All Implemented Interfaces:
java.beans.PropertyChangeListener
,java.beans.VetoableChangeListener
,java.util.EventListener
,AudioManager
,PropertyChangeFirer
,PropertyChangeProvider
,SilenceablePropertyChangeProvider
,VetoableChangeFirer
,VetoableChangeProvider
,Manager<Audio>
- Direct Known Subclasses:
DefaultAudioManager
public abstract class AbstractAudioManager extends AbstractManager<Audio> implements AudioManager
Abstract partial implementation of an AudioManager.
This file is part of JMRI.JMRI is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. See the "COPYING" file for a copy of this license.
JMRI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
-
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.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 AbstractAudioManager(SystemConnectionMemo memo)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract Audio
createNewAudio(java.lang.String systemName, java.lang.String userName)
Internal method to invoke the factory, after all the logic for returning an existing Audio has been invoked.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 key)
Locate an existing instance based on a system name.Audio
getByUserName(java.lang.String key)
Locate an existing instance based on a user name.java.lang.Class<Audio>
getNamedBeanClass()
Get the class of NamedBean supported by this Manager.Audio
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.char
typeLetter()
-
Methods inherited from class jmri.managers.AbstractManager
addDataListener, checkNumeric, createSystemName, deleteBean, deregister, dispose, fireDataListenersAdded, fireDataListenersRemoved, fireVetoableChange, getAutoSystemName, getBySystemName, getKnownBeanProperties, getMemo, getNamedBean, getNamedBeanSet, getObjectCount, getOuterBean, getSystemPrefix, handleUserNameUniqueness, 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.AudioManager
cleanup, getActiveAudioFactory, getNamedBeanSet, init, isInitialised
-
Methods inherited from interface jmri.Manager
addDataListener, deleteBean, deregister, dispose, getBeanTypeHandled, getEntryToolTip, getKnownBeanProperties, getMemo, getNamedBean, getNamedBeanSet, getObjectCount, getSubSystemNamePrefix, getSystemNamePrefix, getSystemPrefix, getXMLOrder, 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
-
AbstractAudioManager
public AbstractAudioManager(SystemConnectionMemo memo)
-
-
Method Detail
-
typeLetter
public char typeLetter()
- Specified by:
typeLetter
in interfaceManager<Audio>
- Returns:
- The type letter for a specific implementation
-
provideAudio
@Nonnull public Audio provideAudio(@Nonnull 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(@Nonnull 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(@Nonnull java.lang.String key)
Locate an existing instance based on a system name.- Specified by:
getBySystemName
in interfaceAudioManager
- Specified by:
getBySystemName
in interfaceManager<Audio>
- Overrides:
getBySystemName
in classAbstractManager<Audio>
- Parameters:
key
- System Name of the required NamedBean- Returns:
- requested NamedBean object or null if none exists
-
getByUserName
public Audio getByUserName(@Nonnull java.lang.String key)
Locate an existing instance based on a user name.- Specified by:
getByUserName
in interfaceAudioManager
- Specified by:
getByUserName
in interfaceManager<Audio>
- Overrides:
getByUserName
in classAbstractManager<Audio>
- Parameters:
key
- System Name of the required NamedBean- Returns:
- requested NamedBean object or null if none exists
-
newAudio
@Nonnull public Audio newAudio(@Nonnull 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
-
createNewAudio
protected abstract Audio createNewAudio(@Nonnull java.lang.String systemName, java.lang.String userName) throws AudioException
Internal method to invoke the factory, after all the logic for returning an existing Audio has been invoked.- Parameters:
systemName
- Audio object system name (for example IAS1, IAB4)userName
- Audio object user name- Returns:
- never null
- Throws:
AudioException
- if error occurs during creation
-
getBeanTypeHandled
@Nonnull 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
-
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.
-
-