Package jmri.managers

Class AbstractAudioManager

    • Method Detail

      • 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 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​(@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 interface AudioManager
        Parameters:
        name - User name or system name to match
        Returns:
        null if no match found
      • 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.
        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
      • 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 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
      • 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.