|
SunSPOT host API V3.0 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sun.spot.client.SpotClientCommands
public class SpotClientCommands
SpotClientCommands
An instance of this holds all the commands available in a SpotClient including user extensions. An
instance must be created during the startup of a host application that wishes to use the SpotClient
infrastructure, by doing something like:
IUI ui = new DummyUI();
// Use this constructor for locally connected SPOTs, or the other public one for remote SPOTs
SpotClientCommands commandRepository = new SpotClientCommands(ui, appPath, libFile, sysBinPath, keyStorePath, port);
Then the instance can be used to execute commands, for example:
commandRepository.getCommand("flashapp").execute(null);
The required signature to the execute(...) method depends on the particular command class
(see ISpotClientCommand.getSignature()
).
See the SPOT Developer's Guide for more details.
Field Summary | |
---|---|
static int |
MODE_LOCAL
value returned from getMode() when there is a locally connected SPOT |
static int |
MODE_REMOTE_NON_SPECIFIC
value returned from getMode() when there is no specific SPOT |
static int |
MODE_REMOTE_SPECIFIC
value returned from getMode() when there is a remotely connected SPOT |
Constructor Summary | |
---|---|
SpotClientCommands(IUI ui,
String appFilePath,
String libFile,
File sysBinPath,
String keyStorePath,
String port)
Create an instance to deal with a locally connected SPOT. |
|
SpotClientCommands(IUI ui,
String appFilePath,
String libFile,
File sysBinPath,
String keyStorePath,
String port,
String remoteAddr,
int remoteChannel,
short remotePanId,
int echoPort)
Create an instance to deal with a remote SPOT or SPOTs. |
Method Summary | |
---|---|
void |
addCommand(ISpotClientCommand command)
Add or replace a command in the active command set (replaces if the new command has the same name as an existing one). |
boolean |
containsCommand(String commandName)
Answer whether a command exists with the given name. |
Object |
execute(String commandName)
Execute the ISpotClientCommand registered with the given name, assuming that
the ISpotClientCommand implements ISpotClientCommand.SIGNATURE_NOTHING . |
Object |
execute(String commandName,
boolean arg0)
Execute the ISpotClientCommand registered with the given name, assuming that
the ISpotClientCommand implements ISpotClientCommand.SIGNATURE_BOOLEAN . |
Object |
execute(String commandName,
int arg0)
Execute the ISpotClientCommand registered with the given name, assuming that
the ISpotClientCommand implements ISpotClientCommand.SIGNATURE_INT . |
Object |
execute(String commandName,
long arg0)
Execute the ISpotClientCommand registered with the given name, assuming that
the ISpotClientCommand implements ISpotClientCommand.SIGNATURE_LONG . |
Object |
execute(String commandName,
String arg0)
Execute the ISpotClientCommand registered with the given name, assuming that
the ISpotClientCommand implements ISpotClientCommand.SIGNATURE_STRING or
ISpotClientCommand.SIGNATURE_OPTIONAL_STRING . |
Object |
execute(String commandName,
String arg0,
String arg1)
Execute the ISpotClientCommand registered with the given name, assuming that
the ISpotClientCommand implements ISpotClientCommand.SIGNATURE_TWO_STRINGS or
ISpotClientCommand.SIGNATURE_OPTIONAL_SECOND_STRING . |
Object |
execute(String commandName,
String arg0,
String arg1,
String arg2)
Execute the ISpotClientCommand registered with the given name, assuming that
the ISpotClientCommand implements ISpotClientCommand.SIGNATURE_THREE_STRINGS . |
ISpotClientCommand |
getCommand(String commandName)
Answer an existing command if there is one with the given name. |
Set |
getCommandNames()
|
int |
getMode()
Answer the mode in which the SpotClient is operating. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int MODE_LOCAL
getMode()
when there is a locally connected SPOT
public static final int MODE_REMOTE_SPECIFIC
getMode()
when there is a remotely connected SPOT
public static final int MODE_REMOTE_NON_SPECIFIC
getMode()
when there is no specific SPOT
Constructor Detail |
---|
public SpotClientCommands(IUI ui, String appFilePath, String libFile, File sysBinPath, String keyStorePath, String port) throws FileNotFoundException, IOException
ui
- the active IUI
appFilePath
- the application path specified on the SpotClient command line. Normally this
is the relative path from the launch folder of the SpotClient to the suite file of the application,
minus the ".suite" extension. If the path is not specified on the command line, it will be the
relative path to the launch folder (i.e. ".").libFile
- the fully qualified path to the SDK's current library suite.sysBinPath
- the fully qualified path to the folder containing arm-specific files (typically
keyStorePath
- the path to the folder containing security keysport
- the name of the port to which the local SPOT to be communicated with is attached
FileNotFoundException
IOException
public SpotClientCommands(IUI ui, String appFilePath, String libFile, File sysBinPath, String keyStorePath, String port, String remoteAddr, int remoteChannel, short remotePanId, int echoPort) throws FileNotFoundException, IOException
ui
- the active IUI
appFilePath
- the application path specified on the SpotClient command line. Normally this
is the relative path from the launch folder of the SpotClient to the suite file of the application,
minus the ".suite" extension. If the path is not specified on the command line, it will be the
relative path to the launch folder (i.e. ".").libFile
- the fully qualified path to the SDK's current library suite.sysBinPath
- the fully qualified path to the folder containing arm-specific files (typically
keyStorePath
- the path to the folder containing security keysport
- the name of the port to which the basestation is connected, or null if already set in system property SERIAL_PORTremoteAddr
- the IEEE address of the remote SPOT, or null if no commands that access a specific target will be calledremoteChannel
- the radio channel to communicate with the remote SPOTremotePanId
- the PAN id to communicate with the remote SPOTechoPort
- the radiostream port on which to receive remote printing output
FileNotFoundException
IOException
Method Detail |
---|
public int getMode()
MODE_LOCAL
, MODE_REMOTE_NON_SPECIFIC
and MODE_REMOTE_SPECIFIC
public void addCommand(ISpotClientCommand command)
command
- to add to the available setpublic ISpotClientCommand getCommand(String commandName) throws SpotClientArgumentException
commandName
- the name of the command to answer
SpotClientArgumentException
- if there is no command with the given namepublic boolean containsCommand(String commandName)
commandName
- the command name to search for.
public Set getCommandNames()
public Object execute(String commandName) throws SpotClientException, IOException
ISpotClientCommand
registered with the given name, assuming that
the ISpotClientCommand
implements ISpotClientCommand.SIGNATURE_NOTHING
.
If this is the wrong signature for this command, throw an IllegalStateException
.
If no command is registered for the given name throws SpotClientArgumentException
.
commandName
- the command to execute
SpotClientException
IOException
public Object execute(String commandName, int arg0) throws SpotClientException, IOException
ISpotClientCommand
registered with the given name, assuming that
the ISpotClientCommand
implements ISpotClientCommand.SIGNATURE_INT
.
If this is the wrong signature for this command, throw an IllegalStateException
.
If no command is registered for the given name throws SpotClientArgumentException
.
commandName
- the command to execute
SpotClientException
IOException
public Object execute(String commandName, long arg0) throws SpotClientException, IOException
ISpotClientCommand
registered with the given name, assuming that
the ISpotClientCommand
implements ISpotClientCommand.SIGNATURE_LONG
.
If this is the wrong signature for this command, throw an IllegalStateException
.
If no command is registered for the given name throws SpotClientArgumentException
.
commandName
- the command to execute
SpotClientException
IOException
public Object execute(String commandName, boolean arg0) throws SpotClientException, IOException
ISpotClientCommand
registered with the given name, assuming that
the ISpotClientCommand
implements ISpotClientCommand.SIGNATURE_BOOLEAN
.
If this is the wrong signature for this command, throw an IllegalStateException
.
If no command is registered for the given name throws SpotClientArgumentException
.
commandName
- the command to execute
SpotClientException
IOException
public Object execute(String commandName, String arg0) throws SpotClientException, IOException
ISpotClientCommand
registered with the given name, assuming that
the ISpotClientCommand
implements ISpotClientCommand.SIGNATURE_STRING
or
ISpotClientCommand.SIGNATURE_OPTIONAL_STRING
.
If this is the wrong signature for this command, throw an IllegalStateException
.
If no command is registered for the given name throws SpotClientArgumentException
.
commandName
- the command to execute
SpotClientException
IOException
public Object execute(String commandName, String arg0, String arg1) throws SpotClientException, IOException
ISpotClientCommand
registered with the given name, assuming that
the ISpotClientCommand
implements ISpotClientCommand.SIGNATURE_TWO_STRINGS
or
ISpotClientCommand.SIGNATURE_OPTIONAL_SECOND_STRING
.
If this is the wrong signature for this command, throw an IllegalStateException
.
If no command is registered for the given name throws SpotClientArgumentException
.
commandName
- the command to execute
SpotClientException
IOException
public Object execute(String commandName, String arg0, String arg1, String arg2) throws SpotClientException, IOException
ISpotClientCommand
registered with the given name, assuming that
the ISpotClientCommand
implements ISpotClientCommand.SIGNATURE_THREE_STRINGS
.
If this is the wrong signature for this command, throw an IllegalStateException
.
If no command is registered for the given name throws SpotClientArgumentException
.
commandName
- the command to execute
SpotClientException
IOException
|
SunSPOT host API V3.0 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |