Class 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 interface AudioManager
        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 interface AudioManager
        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 interface AudioManager
        Specified by:
        getBySystemName in interface Manager<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 interface AudioManager
        Specified by:
        getByUserName in interface Manager<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.
        Note that it is possible to make an inconsistent request if both addresses are provided, but the given values are associated with different objects. This is a problem, and we don't have a good solution except to issue warnings. This will mostly happen if you're creating Audio objects when you should be looking them up.
        Specified by:
        newAudio in interface AudioManager
        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
      • getNamedBeanSet

        public java.util.SortedSet<AudiogetNamedBeanSet​(char subType)
        Get the specified Audio sub-type NamedBeans.
        Specified by:
        getNamedBeanSet in interface AudioManager
        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 interface AudioManager
      • getSystemPrefix

        public java.lang.String getSystemPrefix()
        Provide access to the system prefix string. This was previously called the "System letter"
        Specified by:
        getSystemPrefix in interface Manager<Audio>
        Returns:
        the system prefix
      • getNamedBeanClass

        public java.lang.Class<AudiogetNamedBeanClass()
        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 interface Manager<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.
        Specified by:
        dispose in interface Manager<Audio>
      • getNamedBeanSet

        public java.util.SortedSet<AudiogetNamedBeanSet()
        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 interface Manager<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 interface Manager<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 interface Manager<Audio>
        Parameters:
        n - The NamedBean to be deleted
        property - 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.

        Specified by:
        register in interface Manager<Audio>
        Parameters:
        n - the bean
      • 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 interface Manager<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 interface Manager<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 interface Manager<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
      • setPropertyChangesSilenced

        public void setPropertyChangesSilenced​(java.lang.String propertyName,
                                               boolean silenced)
        Suppress sending PropertyChangeEvents 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 interface SilenceablePropertyChangeProvider
        Parameters:
        propertyName - the name of the property to mute
        silenced - true if events are to be suppressed; false otherwise
      • addPropertyChangeListener

        public void addPropertyChangeListener​(java.lang.String propertyName,
                                              java.beans.PropertyChangeListener listener)
        Add a PropertyChangeListener for a specific property.
        Specified by:
        addPropertyChangeListener in interface PropertyChangeProvider
        Parameters:
        propertyName - The name of the property to listen on.
        listener - The PropertyChangeListener to be added
      • getPropertyChangeListeners

        public java.beans.PropertyChangeListener[] getPropertyChangeListeners​(java.lang.String propertyName)
        Get all PropertyChangeListeners currently listening to changes to the specified property.
        Specified by:
        getPropertyChangeListeners in interface PropertyChangeProvider
        Parameters:
        propertyName - the name of the property of interest
        Returns:
        an array of PropertyChangeListeners
      • 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 interface PropertyChangeProvider
        Parameters:
        propertyName - The name of the property to stop listening to.
        listener - The PropertyChangeListener to remove.
      • addVetoableChangeListener

        public void addVetoableChangeListener​(java.lang.String propertyName,
                                              java.beans.VetoableChangeListener listener)
        Add a VetoableChangeListener for a specific property.
        Specified by:
        addVetoableChangeListener in interface VetoableChangeProvider
        Parameters:
        propertyName - The name of the property to listen on.
        listener - The VetoableChangeListener to be added
      • getVetoableChangeListeners

        public java.beans.VetoableChangeListener[] getVetoableChangeListeners​(java.lang.String propertyName)
        Get all VetoableChangeListeners currently listening to changes to the specified property.
        Specified by:
        getVetoableChangeListeners in interface VetoableChangeProvider
        Parameters:
        propertyName - The name of the property of interest
        Returns:
        An array of VetoableChangeListeners.
      • 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 interface VetoableChangeProvider
        Parameters:
        propertyName - The name of the property to stop listening to.
        listener - The VetoableChangeListener to remove.