jmri.managers
Class AbstractAudioManager

java.lang.Object
  extended by jmri.implementation.AbstractManager
      extended by jmri.managers.AbstractAudioManager
All Implemented Interfaces:
PropertyChangeListener, EventListener, AudioManager, Manager
Direct Known Subclasses:
DefaultAudioManager

public abstract class AbstractAudioManager
extends AbstractManager
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.

Author:
Matthew Harris copyright (c) 2009

Field Summary
 
Fields inherited from class jmri.implementation.AbstractManager
_tsys, _tuser
 
Fields inherited from interface jmri.AudioManager
MAX_BUFFERS, MAX_LISTENERS, MAX_SOURCES
 
Constructor Summary
AbstractAudioManager()
           
 
Method Summary
protected abstract  Audio createNewAudio(String systemName, String userName)
          Internal method to invoke the factory, after all the logic for returning an existing method has been invoked.
 Audio getAudio(String name)
          Locate via user name, then system name if needed.
 Audio getBySystemName(String key)
          Locate an instance based on a system name.
 Audio getByUserName(String key)
          Locate an instance based on a user name.
 Audio newAudio(String sysName, String userName)
          Return an instance with the specified system and user names.
 Audio provideAudio(String name)
          Locate via user name, then system name if needed.
 char typeLetter()
           
 
Methods inherited from class jmri.implementation.AbstractManager
addPropertyChangeListener, deregister, dispose, firePropertyChange, getInstanceBySystemName, getInstanceByUserName, getSystemNameArray, getSystemNameList, makeSystemName, propertyChange, register, registerSelf, 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, getSystemNameList, getSystemNameList, init
 
Methods inherited from interface jmri.Manager
addPropertyChangeListener, deregister, dispose, getSystemNameArray, makeSystemName, register, removePropertyChangeListener, systemLetter
 

Constructor Detail

AbstractAudioManager

public AbstractAudioManager()
Method Detail

typeLetter

public char typeLetter()
Specified by:
typeLetter in interface Manager
Returns:
The type letter for a specific implementation

provideAudio

public Audio provideAudio(String name)
                   throws AudioException
Description copied from interface: AudioManager
Locate via 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
Returns:
Never null under normal circumstances
Throws:
AudioException - if error occurs during creation

getAudio

public Audio getAudio(String name)
Description copied from interface: AudioManager
Locate via user name, then system name if needed. If that fails, return null

Specified by:
getAudio in interface AudioManager
Returns:
null if no match found

getBySystemName

public Audio getBySystemName(String key)
Description copied from interface: AudioManager
Locate an instance based on a system name. Returns null if no instance already exists.

Specified by:
getBySystemName in interface AudioManager
Parameters:
key - Audio object system name (e.g. IAS1, IAB4)
Returns:
requested Audio object or null if none exists

getByUserName

public Audio getByUserName(String key)
Description copied from interface: AudioManager
Locate an instance based on a user name. Returns null if no instance already exists.

Specified by:
getByUserName in interface AudioManager
Parameters:
key - Audio object user name
Returns:
requested Audio object or null if none exists

newAudio

public Audio newAudio(String sysName,
                      String userName)
               throws AudioException
Description copied from interface: AudioManager
Return an instance 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:

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:
sysName - Audio object system name (e.g. IAS1, IAB4)
userName - Audio object user name
Returns:
requested Audio object (never null)
Throws:
AudioException - if error occurs during creation

createNewAudio

protected abstract Audio createNewAudio(String systemName,
                                        String userName)
                                 throws AudioException
Internal method to invoke the factory, after all the logic for returning an existing method has been invoked.

Parameters:
systemName - Audio object system name (e.g. IAS1, IAB4)
userName - Audio object user name
Returns:
never null
Throws:
AudioException - if error occurs during creation


Copyright © 1997 - 2009 JMRI Community.
JMRI, DecoderPro, PanelPro, SoundPro, DispatcherPro and associated logos are our trademarks.

Additional information on copyright, trademarks and licenses is linked here.
Site hosted by: Get JMRI Model Railroad Interface at SourceForge.net. Fast, secure and Free Open Source software downloads