public abstract class AbstractCommand extends Object implements ICasaCommand
Modifier and Type | Field and Description |
---|---|
protected static Signature |
EMPTY_SIGNATURE |
DEFAULT_NAMESPACE, PROP_DESCRIPTION, PROP_NAME
Constructor and Description |
---|
AbstractCommand() |
Modifier and Type | Method and Description |
---|---|
protected void |
addSignature(Signature signature) |
Object |
execute(InputStream in,
PrintStream out,
org.json.JSONObject param)
Execute a block of code and then returns the result from execution.
|
abstract Object |
execute(InputStream in,
PrintStream out,
org.json.JSONObject param,
Signature signature) |
String |
getDescription()
Get the command description.
|
Signature |
getSignature(int param)
Get signature by passing the number of arguments..
|
boolean |
validate(org.json.JSONObject param,
Signature signature)
To validate the given parameters.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getName
protected static Signature EMPTY_SIGNATURE
public Object execute(InputStream in, PrintStream out, org.json.JSONObject param) throws Exception
ICasaCommand
in
and
out
stream to print result instead of the direct use of System.in
and System.out
execute
in interface ICasaCommand
in
- : the input stream.out
- : the output stream.param
- a json object of parametersException
- if anything goes wrongprotected void addSignature(Signature signature)
public Signature getSignature(int param)
ICasaCommand
getSignature
in interface ICasaCommand
public String getDescription()
getDescription
in interface ICasaCommand
public boolean validate(org.json.JSONObject param, Signature signature) throws Exception
ICasaCommand
validate
in interface ICasaCommand
param
- The parameters in JSON formatException
public abstract Object execute(InputStream in, PrintStream out, org.json.JSONObject param, Signature signature) throws Exception
Exception
Copyright © 2012-2013 ADELE Research Group. All Rights Reserved.