|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.swath.UserDefinedCommand
User Defined Command base class.
| Field Summary | |
static java.lang.String |
RETURN_KEY
The return key character (0x0D). |
| Constructor Summary | |
UserDefinedCommand()
Constructor. |
|
| Method Summary | |
boolean |
atPrompt(int validPrompts)
Checks if you are at any of the valid prompts. |
void |
endCommand(boolean finished)
Called by the framework when the command is finished. |
java.lang.Object |
execInstance()
Executes a command instance. |
java.lang.String |
getClassName()
Gets the command class name. |
java.lang.String |
getName()
Called by the framework to get the name of the command. |
java.util.Enumeration |
getParams()
Gets the command parameters. |
java.net.URL |
getResource(java.lang.String resource)
Finds a resource with a given name. |
boolean |
initCommand()
Called by the framework to initialise the command. |
void |
initInstance()
Initialises a command instance. |
boolean |
isInternal()
Indicates if this is an internal SWATH command or not. |
boolean |
isUserDefined()
Indicates if this command is user defined or not. |
void |
onEvent(EventIfc event)
This method is called for each posted event. |
void |
onText(java.lang.String buffer,
java.lang.String text)
This method is called when new text has arrived from the game server. |
void |
postEvent(UserDefinedEvent event)
This method posts an event in the SWATH event queue. |
void |
printTrace(java.lang.Exception e)
Print an exception and the complete stack trace in the SWATH console window. |
void |
printTrace(java.lang.String text)
Print trace text in the SWATH console window. |
void |
registerParam(Parameter param)
This method is used to register a command parameter. |
void |
sendString(java.lang.String str)
Sends a string to the TW server. |
void |
setBufferText(java.lang.String text)
Sets the current text buffer content. |
void |
setResult(java.lang.Object result)
Sets the result value that will be returned when the command is finished. |
void |
skipBufferText(int count)
Removes characters from the current text buffer. |
void |
startCommand()
Called by the framework to start executing the command. |
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final java.lang.String RETURN_KEY
| Constructor Detail |
public UserDefinedCommand()
| Method Detail |
public final boolean isUserDefined()
CommandIfc
isUserDefined in interface CommandIfctrue if user defined, otherwise false.public final boolean isInternal()
CommandIfc
isInternal in interface CommandIfctrue if internal, otherwise false.public final java.lang.String getClassName()
CommandIfc
getClassName in interface CommandIfc
public final void registerParam(Parameter param)
throws CommandException
param - The parameter to register.
CommandException - If no more parameters could be added.public final java.util.Enumeration getParams()
getParams in interface CommandIfc
public final void initInstance()
throws CommandException,
java.lang.Exception
exec() methods.
CommandException - If the command initialisation fails for some reason.
java.lang.ExceptionexecInstance()
public final java.lang.Object execInstance()
throws CommandException,
java.lang.Exception
exec() methods.
CommandException - If the command execution fails for some reason.
java.lang.ExceptioninitInstance()public final void skipBufferText(int count)
count - Number of characters to remove.setBufferText(java.lang.String),
onText(java.lang.String, java.lang.String)public final void setBufferText(java.lang.String text)
text - The new content.skipBufferText(int),
onText(java.lang.String, java.lang.String)public final void setResult(java.lang.Object result)
result - The result.execInstance()
public final boolean atPrompt(int validPrompts)
throws java.lang.Exception
validPrompts - The valid prompts. (Combine several prompts with logical OR)
true if you are at a valid prompt,
otherwise false.
java.lang.ExceptionSwath.NO_PROMPT,
Swath.COMMAND_PROMPT,
Swath.COMPUTER_PROMPT,
Swath.PLANET_PROMPT,
Swath.CITADEL_PROMPT,
Swath.CORP_PROMPT,
Swath.STARDOCK_PROMPT,
Swath.ALL_PROMPTSpublic final java.net.URL getResource(java.lang.String resource)
resource - The name of the wanted resource.
null if not found.
public final void sendString(java.lang.String str)
throws java.lang.Exception
str - The string to send.
java.lang.ExceptionRETURN_KEYpublic final void postEvent(UserDefinedEvent event)
event - The event to post.
public final void printTrace(java.lang.String text)
throws java.lang.Exception
text - The text to print.
java.lang.Exception
public final void printTrace(java.lang.Exception e)
throws java.lang.Exception
e - The exception to print.
java.lang.Exceptionpublic java.lang.String getName()
getName in interface CommandIfc
public boolean initCommand()
throws java.lang.Exception
true if the initialisation was successful,
otherwise false.
java.lang.ExceptionatPrompt(int),
printTrace(java.lang.String),
setResult(java.lang.Object)
public void startCommand()
throws java.lang.Exception
onText and onEvent.
java.lang.ExceptionsendString(java.lang.String),
postEvent(com.swath.UserDefinedEvent),
printTrace(java.lang.String),
setResult(java.lang.Object),
onText(java.lang.String, java.lang.String),
onEvent(com.swath.EventIfc)
public void endCommand(boolean finished)
throws java.lang.Exception
finished - true if the command finished correctly or
false if the command was interrupted in some way.
java.lang.Exception
public void onText(java.lang.String buffer,
java.lang.String text)
throws java.lang.Exception
skipBufferText and setBufferText methods.
buffer - The current text buffer.text - The new incoming text.
java.lang.ExceptionskipBufferText(int),
setBufferText(java.lang.String),
sendString(java.lang.String),
postEvent(com.swath.UserDefinedEvent),
printTrace(java.lang.String),
setResult(java.lang.Object)
public void onEvent(EventIfc event)
throws java.lang.Exception
event - The event.
java.lang.ExceptionsendString(java.lang.String),
postEvent(com.swath.UserDefinedEvent),
printTrace(java.lang.String),
setResult(java.lang.Object)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||