Class AbstractAudio

java.lang.Object
jmri.implementation.AbstractNamedBean
jmri.implementation.AbstractAudio
All Implemented Interfaces:
Comparable<NamedBean>, Audio, PropertyChangeProvider, NamedBean
Direct Known Subclasses:
AbstractAudioBuffer, AbstractAudioListener, AbstractAudioSource

public abstract class AbstractAudio
extends AbstractNamedBean
implements Audio
Base implementation of the Audio class.

Specific implementations will extend this base class.

  • Constructor Details

    • AbstractAudio

      public AbstractAudio​(String systemName)
      Abstract constructor for new Audio with system name
      Parameters:
      systemName - Audio object system name (e.g. IAS1, IAB4)
    • AbstractAudio

      public AbstractAudio​(String systemName, String userName)
      Abstract constructor for new Audio with system name and user name
      Parameters:
      systemName - Audio object system name (e.g. IAS1, IAB4)
      userName - Audio object user name
  • Method Details

    • getState

      public int getState()
      Description copied from interface: NamedBean
      Provide generic access to internal state.

      This generally shouldn't be used by Java code; use the class-specific form instead (e.g. getCommandedState in Turnout). This is provided to make scripts easier to read.

      Specified by:
      getState in interface NamedBean
      Returns:
      the state
    • setState

      public void setState​(int newState)
      Description copied from interface: NamedBean
      Provide generic access to internal state.

      This generally shouldn't be used by Java code; use the class-specific form instead (e.g. setCommandedState in Turnout). This is provided to make scripts access easier to read.

      Specified by:
      setState in interface NamedBean
      Parameters:
      newState - the state
    • cleanup

      protected abstract void cleanup()
      Abstract method that concrete classes will implement to perform necessary cleanup routines.
    • dispose

      public void dispose()
      Description copied from interface: NamedBean
      Deactivate this object, so that it releases as many resources as possible and no longer effects others.

      For example, if this object has listeners, after a call to this method it should no longer notify those listeners. Any native or system-wide resources it maintains should be released, including threads, files, etc.

      It is an error to invoke any other methods on this object once dispose() has been called. Note, however, that there is no guarantee about behavior in that case.

      Afterwards, references to this object may still exist elsewhere, preventing its garbage collection. But it's formally dead, and shouldn't be keeping any other objects alive. Therefore, this method should null out any references to other objects that this NamedBean contained.

      Specified by:
      dispose in interface NamedBean
      Overrides:
      dispose in class AbstractNamedBean
    • roundDecimal

      public static float roundDecimal​(float value, double places)
      Static method to round a float value to the specified number of decimal places
      Parameters:
      value - float value to round
      places - number of decimal places to round to
      Returns:
      float value rounded to specified number of decimal places
    • roundDecimal

      public static float roundDecimal​(float value)
      Static method to round a float value to the number of decimal places defined by DECIMAL_PLACES.
      Parameters:
      value - float value to round
      Returns:
      float value rounded to DECIMAL_PLACES decimal places
    • getBeanType

      public String getBeanType()
      Description copied from interface: NamedBean
      For instances in the code where we are dealing with just a bean and a message needs to be passed to the user or in a log.
      Specified by:
      getBeanType in interface NamedBean
      Returns:
      a string of the bean type, eg Turnout, Sensor etc