JavaTron
Class AudioTronState

java.lang.Object
  |
  +--JavaTron.AudioTron
        |
        +--JavaTron.AudioTronState
All Implemented Interfaces:
AudioTron.InputStreamListener

public class AudioTronState
extends AudioTron
implements AudioTron.InputStreamListener

AudioTron stateful interface class. This class maintains state by updating at periodic intervals. It uses a priority queue to all commands to supercede an update requests. If a command is sent during an update, the update is canceled and requeued.

To get useful information about the state of the AudioTron, register an AudioTronListener with this object. The AudioTronListener will then get notifications wrt to state changes.


Nested Class Summary
 
Nested classes inherited from class JavaTron.AudioTron
AudioTron.InputStreamListener
 
Field Summary
protected  java.lang.reflect.Method mParseSongQueue
           
protected  java.lang.reflect.Method mParseStatus
           
 
Fields inherited from class JavaTron.AudioTron
OFF, ON, TOGGLE
 
Constructor Summary
AudioTronState()
          Zero parameter version of constructor -- default settings for address, username, and password.
AudioTronState(java.lang.String server_)
          One parameter version of constructor -- allows setting of AudioTron address (default username and password)
AudioTronState(java.lang.String server_, java.lang.String username_)
          Two parameter version of constructor -- allows setting of AudioTron address and username (default password).
AudioTronState(java.lang.String server_, java.lang.String username_, java.lang.String password_)
          Three parameter version of constructor -- allows setting of AudioTron address, username, and password.
 
Method Summary
 void addAudioTronListener(JavaTron.AudioTronListener listener_)
          Add an AudioTronListener to this instance
protected  void endCommand()
          Call at the end of a a command.
 java.util.Enumeration getSongQueue()
           
 java.lang.String getStatus()
          Return a text string describing the status of the AudioTron 'engine' status.
protected  boolean parseSongQueue(java.lang.String content)
          Parse the returned data from the api "apigetinfo.asp" page.
protected  boolean parseStatus(java.lang.String content)
          Parse the returned data from the api "apigetstatus.asp" page.
protected  void refreshStatus()
          Update listener(s) with the current status
 void setInputStream(java.io.InputStreamReader isr)
          Implements the InputStreamListener interface - FOR INTERNAL USE ONLY.
protected  void startCommand()
          Call at the beginning a command
 
Methods inherited from class JavaTron.AudioTron
addCommand, doCommand, get, get, get, gotoIndex, mute, mute, next, pause, pause, play, post, prev, random, random, repeat, repeat, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mParseStatus

protected java.lang.reflect.Method mParseStatus

mParseSongQueue

protected java.lang.reflect.Method mParseSongQueue
Constructor Detail

AudioTronState

public AudioTronState()
Zero parameter version of constructor -- default settings for address, username, and password. Sets up the thread and other initializations.


AudioTronState

public AudioTronState(java.lang.String server_)
One parameter version of constructor -- allows setting of AudioTron address (default username and password)


AudioTronState

public AudioTronState(java.lang.String server_,
                      java.lang.String username_)
Two parameter version of constructor -- allows setting of AudioTron address and username (default password).

Parameters:
server_ - the AudioTron ip address (defaults to 192.168.0.10)
username_ - the username to use when accessing AudioTron pages (defaults to 'admin')

AudioTronState

public AudioTronState(java.lang.String server_,
                      java.lang.String username_,
                      java.lang.String password_)
Three parameter version of constructor -- allows setting of AudioTron address, username, and password.

Parameters:
server_ - the AudioTron ip address (defaults to 192.168.0.10)
username_ - the username to use when accessing AudioTron pages (defaults to 'admin')
password_ - the password to use when accessing the AudioTron pages (defaults to 'admin')
Method Detail

addAudioTronListener

public void addAudioTronListener(JavaTron.AudioTronListener listener_)
Add an AudioTronListener to this instance


getSongQueue

public java.util.Enumeration getSongQueue()

getStatus

public java.lang.String getStatus()
Return a text string describing the status of the AudioTron 'engine' status.

Returns:
string describing internal state

parseStatus

protected boolean parseStatus(java.lang.String content)
Parse the returned data from the api "apigetstatus.asp" page. This is a parse callback method.

Parameters:
content - line-by-line content of the data returned
Returns:
true if the parse is successful, false otherwise

parseSongQueue

protected boolean parseSongQueue(java.lang.String content)
Parse the returned data from the api "apigetinfo.asp" page. This is a parse callback method.

Parameters:
content - line-by-line content of the data returned
Returns:
true if the parse is successful, false otherwise

startCommand

protected void startCommand()
Description copied from class: AudioTron
Call at the beginning a command

Overrides:
startCommand in class AudioTron

endCommand

protected void endCommand()
Description copied from class: AudioTron
Call at the end of a a command.

Overrides:
endCommand in class AudioTron

refreshStatus

protected void refreshStatus()
Update listener(s) with the current status


setInputStream

public void setInputStream(java.io.InputStreamReader isr)
Implements the InputStreamListener interface - FOR INTERNAL USE ONLY. It is an implementation detail that this is public.

Specified by:
setInputStream in interface AudioTron.InputStreamListener
Parameters:
isr - the InputStreamReader that is being set