JavaTron
Class AudioTron

java.lang.Object
  |
  +--JavaTron.AudioTron
Direct Known Subclasses:
AudioTronState

public class AudioTron
extends java.lang.Object

Implements the AudioTron api. The AudioTron object calls all api command requests on a seperate thread. All calls to the AudioTron object API's are non blocking.

State is notified via a AudioTronListener object. If you want state use an AudioTronState object instead.


Nested Class Summary
static interface AudioTron.InputStreamListener
           
 
Field Summary
 java.lang.Integer OFF
           
 java.lang.Integer ON
           
 java.lang.Integer TOGGLE
           
 
Constructor Summary
AudioTron()
          Zero parameter version of constructor -- default settings for address, username, and password.
AudioTron(java.lang.String server_)
          One parameter version of constructor -- allows setting of AudioTron address (default username and password)
AudioTron(java.lang.String server_, java.lang.String username_)
          Two parameter version of constructor -- allows setting of AudioTron address and username (default password).
AudioTron(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
protected  void addCommand(JavaTron.WrappedMethod wm, int priority)
          Add a command to execute.
protected  void doCommand(java.lang.String command, java.lang.String state)
          Perform a command synchronously.
protected  void endCommand()
          Call at the end of a a command.
protected  java.lang.String get(AudioTron.InputStreamListener listener, java.lang.String address)
          Send a get request to the AudioTron server (2 param version).
protected  java.lang.String get(AudioTron.InputStreamListener listener, java.lang.String address, java.util.Vector args)
          Send a get request to the AudioTron server (3 param version).
protected  java.lang.String get(AudioTron.InputStreamListener listener, java.lang.String address, java.util.Vector args, java.lang.reflect.Method parser)
          Send a get request to the AudioTron server
 void gotoIndex(int index)
          Tell the AudioTron to go to a new index
 void mute()
          Tell the AudioTron to toggle the Mute setting
 void mute(java.lang.Integer state)
          Tell the AudioTron to set the Mute setting
 void next()
          Tell the AudioTron to go forward (Next)
 void pause()
          Tell the AudioTron to toggle the Pause setting
 void pause(java.lang.Integer state)
          Tell the AudioTron to Pause
 void play()
          Tell the AudioTron to Play
protected  void post(java.lang.String formAddress, java.util.Vector args)
          Send a form to the AudioTron server
 void prev()
          Tell the AudioTron to go back (Prev)
 void random()
          Tell the AudioTron to toggle the Random setting
 void random(java.lang.Integer state)
          Tell the AudioTron to set the Random setting
 void repeat()
          Tell the AudioTron to toggle the Repeat setting
 void repeat(java.lang.Integer state)
          Tell the AudioTron to set the Repeat setting
protected  void startCommand()
          Call at the beginning a command
 void stop()
          Tell the AudioTron to Stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ON

public final java.lang.Integer ON

OFF

public final java.lang.Integer OFF

TOGGLE

public final java.lang.Integer TOGGLE
Constructor Detail

AudioTron

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


AudioTron

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


AudioTron

public AudioTron(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')

AudioTron

public AudioTron(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

stop

public void stop()
Tell the AudioTron to Stop


play

public void play()
Tell the AudioTron to Play


prev

public void prev()
Tell the AudioTron to go back (Prev)


next

public void next()
Tell the AudioTron to go forward (Next)


pause

public void pause()
Tell the AudioTron to toggle the Pause setting


pause

public void pause(java.lang.Integer state)
Tell the AudioTron to Pause

Parameters:
state - the state to set the setting to. Must be one of ON, OFF, TOGGLE.

random

public void random()
Tell the AudioTron to toggle the Random setting


random

public void random(java.lang.Integer state)
Tell the AudioTron to set the Random setting

Parameters:
state - the state to set the setting to. Must be one of ON, OFF, TOGGLE.

repeat

public void repeat()
Tell the AudioTron to toggle the Repeat setting


repeat

public void repeat(java.lang.Integer state)
Tell the AudioTron to set the Repeat setting

Parameters:
state - the state to set the setting to. Must be one of ON, OFF, TOGGLE.

mute

public void mute()
Tell the AudioTron to toggle the Mute setting


mute

public void mute(java.lang.Integer state)
Tell the AudioTron to set the Mute setting

Parameters:
state - the state to set the setting to. Must be one of ON, OFF, TOGGLE.

gotoIndex

public void gotoIndex(int index)
Tell the AudioTron to go to a new index

Parameters:
index - the index to go to

doCommand

protected void doCommand(java.lang.String command,
                         java.lang.String state)
Perform a command synchronously.

Parameters:
command - the command to perform
state - additional args.

post

protected void post(java.lang.String formAddress,
                    java.util.Vector args)
Send a form to the AudioTron server


get

protected java.lang.String get(AudioTron.InputStreamListener listener,
                               java.lang.String address)
Send a get request to the AudioTron server (2 param version).


get

protected java.lang.String get(AudioTron.InputStreamListener listener,
                               java.lang.String address,
                               java.util.Vector args)
Send a get request to the AudioTron server (3 param version).


get

protected java.lang.String get(AudioTron.InputStreamListener listener,
                               java.lang.String address,
                               java.util.Vector args,
                               java.lang.reflect.Method parser)
Send a get request to the AudioTron server

Parameters:
listener - if set (can be null) the InputStreamReader that is created for this connection is notified through this interface
address - the uri to use
args - the arguments to use
parser - an optional line-by-line parser to use instead of buffering the whole response
Returns:
null on error, a string on success. On succes, if a parser is not specified then the response is returned, otherwise an empty string is returned.

addCommand

protected void addCommand(JavaTron.WrappedMethod wm,
                          int priority)
Add a command to execute. Does so non-blocking. Just calls the CommandThreads' addCommand method.

Parameters:
wm - the callback method to invoke.

startCommand

protected void startCommand()
Call at the beginning a command


endCommand

protected void endCommand()
Call at the end of a a command.