org.biffle.cliff.pearl.tools
Class Client

java.lang.Object
  |
  +--org.biffle.cliff.pearl.tools.Client
All Implemented Interfaces:
java.lang.Runnable

public class Client
extends java.lang.Object
implements java.lang.Runnable

Implements a simple command-line interface to a PearlConnection, primarily to demonstrate the use of the APIs and exception cases.


Field Summary
protected  PearlConnection con
          Our connection to the device.
protected  DeviceInfo info
          Cached copy of the device's info (created lazily).
protected  DeviceSettings settings
          Cached copy of the device's settings (created lazily).
 
Constructor Summary
Client(java.net.InetAddress device)
          Creates a new Client, connecting to a Pearl device via TCP.
 
Method Summary
 void authenticate(java.lang.String password)
          Attempts to authenticate the connection using the provided password.
 void close()
          Closes the connection.
 void delete(java.lang.String fidS)
          Attempts to delete a file by FID.
protected  void downloadInfo()
          Caches device info.
protected  void downloadSettings()
          Caches device settings.
 void dump(java.lang.String fidS)
          Dumps the first 16k of a file.
 void fetch(java.lang.String fidS)
          Retrieves a file to local storage.
static void main(java.lang.String[] args)
          Main function executed from the command line; takes one argument (an IP address) and spawns a Client.
protected  void msg(java.lang.String message)
          Utility function; prints a message from the Client (rather than data from the device).
 void run()
          The meat of the client; this function is executed in its own thread and provides the console interface.
 void showField(java.lang.String field)
          Displays a named field from the device settings file.
 void showFile(java.lang.String arg)
          Show file information.
 void showInfo(java.lang.String arg)
          Show system information.
 void showList(java.lang.String arg)
          Show list of available files.
 void showStorage(java.lang.String indexString)
          Displays information on a storage device by index, or a list of storage devices if no index is given.
 void taxi(java.lang.String filename)
          Uploads a local taxi file.
 void unmarkBad(java.lang.String fidS)
          Attempts to un-mark a file as bad.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

con

protected PearlConnection con
Our connection to the device.


settings

protected DeviceSettings settings
Cached copy of the device's settings (created lazily).


info

protected DeviceInfo info
Cached copy of the device's info (created lazily).

Constructor Detail

Client

public Client(java.net.InetAddress device)
       throws java.io.IOException,
              PearlException
Creates a new Client, connecting to a Pearl device via TCP.

Method Detail

showField

public void showField(java.lang.String field)
Displays a named field from the device settings file. This is the implementation of the "show" command.


showStorage

public void showStorage(java.lang.String indexString)
Displays information on a storage device by index, or a list of storage devices if no index is given. This is the implementation of the "storage" command.


showList

public void showList(java.lang.String arg)
Show list of available files. This is the implementation of the "list" command.


showInfo

public void showInfo(java.lang.String arg)
Show system information. This is the implementation of the "system" command.


showFile

public void showFile(java.lang.String arg)
Show file information. This is the implementation of the "info" command.


authenticate

public void authenticate(java.lang.String password)
Attempts to authenticate the connection using the provided password. This is the implementation of the "auth" command.


delete

public void delete(java.lang.String fidS)
Attempts to delete a file by FID. This is the implementation of the "delete" command.


dump

public void dump(java.lang.String fidS)
Dumps the first 16k of a file. This is the implementation of the "dump" command.


taxi

public void taxi(java.lang.String filename)
Uploads a local taxi file. This is the implementation of the "taxi" command.


fetch

public void fetch(java.lang.String fidS)
Retrieves a file to local storage. This is the implementation of the "fetch" command. Filenames are constructed as follows: - If the song is a music file: $TRACKNR-$TITLE.$EXT - If the song is a taxi file, the original filename is used.


unmarkBad

public void unmarkBad(java.lang.String fidS)
Attempts to un-mark a file as bad. This is the implementation of the "unbad" command.


downloadSettings

protected void downloadSettings()
                         throws PearlException
Caches device settings.

PearlException

downloadInfo

protected void downloadInfo()
                     throws PearlException
Caches device info.

PearlException

close

public void close()
Closes the connection.


run

public void run()
The meat of the client; this function is executed in its own thread and provides the console interface.

Specified by:
run in interface java.lang.Runnable

msg

protected void msg(java.lang.String message)
Utility function; prints a message from the Client (rather than data from the device).


main

public static void main(java.lang.String[] args)
Main function executed from the command line; takes one argument (an IP address) and spawns a Client.