com.bluemarsh.jswat.command
Class JSwatCommand

java.lang.Object
  |
  +--com.bluemarsh.jswat.command.JSwatCommand
Direct Known Subclasses:
aboutCommand, aliasCommand, attachCommand, catchCommand, classCommand, classesCommand, classpathCommand, closeCommand, detachCommand, disablegcCommand, downCommand, dumpCommand, enablegcCommand, exitCommand, fieldsCommand, frameCommand, helpCommand, historyCommand, interruptCommand, killCommand, linesCommand, listenCommand, loadCommand, localsCommand, lockCommand, macroCommand, methodsCommand, optionsCommand, printCommand, readCommand, resumeCommand, runtoCommand, setCommand, sourcepathCommand, stderrCommand, stdinCommand, stdoutCommand, stepCommand, stopCommand, suspendCommand, threadCommand, threadgroupsCommand, threadlocksCommand, unaliasCommand, upCommand, versionCommand, viewCommand, vmlistCommand, whereCommand

public abstract class JSwatCommand
extends java.lang.Object

Defines the abstract class for command classes within JSwat.

Author:
Nathan Fiedler

Field Summary
protected static Category logCategory
          Reporting Category for logging debugging events.
protected static java.util.List primitiveTypeNames
          List of primitive type names.
protected static JSwat swat
          Instance of JSwat.
 
Constructor Summary
JSwatCommand()
           
 
Method Summary
protected static boolean argumentsMatch(java.util.List argNames, java.util.List arguments)
          Tests if the two lists of arguments match in types.
static com.sun.jdi.ObjectReference createObject(com.sun.jdi.ReferenceType refType, java.util.List arguments, com.sun.jdi.ThreadReference thread)
          Creates an object of the given class in the debuggee VM.
 java.lang.String description()
          Return a short, one-line description of this command.
static java.util.List findClassesByPattern(Session session, java.lang.String pattern)
          Return a list of classes and interfaces whose names match the given pattern.
 java.lang.String getCommandName()
          Retrieves the name of this command (similar to the class name).
static com.sun.jdi.ThreadReference getThreadByID(Session session, java.lang.String idToken)
          Finds a thread in the list of all threads whose unique ID number matches that given.
 void help(Log out)
          Display helpful information about this command, including the possible arguments and their interpretation.
protected  void help(Log out, java.lang.StringBuffer buf)
          Display helpful information about this command, including the possible arguments and their interpretation.
 void missingArgs(Log out)
          Display helpful information about this command because the user failed to provide all of the necessary arguments.
abstract  void perform(Session session, com.bluemarsh.util.StringTokenizer args, Log out)
          Perform the command using the given arguments.
 void receiveInput(Session session, Log out, CommandManager cmdman, java.lang.String input)
          Called by the CommandManager when new input has been received from the user.
protected static com.sun.jdi.Method resolveOverload(java.util.List overloads, java.util.List arguments)
          Finds a method that matches the given arguments.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

primitiveTypeNames

protected static java.util.List primitiveTypeNames
List of primitive type names.

swat

protected static JSwat swat
Instance of JSwat.

logCategory

protected static Category logCategory
Reporting Category for logging debugging events.
Constructor Detail

JSwatCommand

public JSwatCommand()
Method Detail

argumentsMatch

protected static boolean argumentsMatch(java.util.List argNames,
                                        java.util.List arguments)
Tests if the two lists of arguments match in types.
Parameters:
argNames - Names of arguments.
arguments - List of method arguments.
Returns:
True of two lists match, false otherwise.

createObject

public static com.sun.jdi.ObjectReference createObject(com.sun.jdi.ReferenceType refType,
                                                       java.util.List arguments,
                                                       com.sun.jdi.ThreadReference thread)
                                                throws com.sun.jdi.ClassNotLoadedException,
                                                       com.sun.jdi.IncompatibleThreadStateException,
                                                       com.sun.jdi.InvalidTypeException,
                                                       com.sun.jdi.InvocationException
Creates an object of the given class in the debuggee VM.
Parameters:
refType - Class of object to create.
arguments - List of argument values to pass to constructor.
thread - Thread in which to create new object. Must be suspended before calling this method.
Returns:
New object's reference.
Throws:
com.sun.jdi.ClassNotLoadedException - Thrown if any argument type has not yet been loaded.
com.sun.jdi.IncompatibleThreadStateException - Thrown if the thread is not suspended.
com.sun.jdi.InvalidTypeException - Thrown if argument types are not assignment-compatible with the arguments in the constructor.
com.sun.jdi.InvocationException - Thrown if there's an error calling the class's constructor.

description

public java.lang.String description()
Return a short, one-line description of this command.
Returns:
One-line description of command.

getCommandName

public java.lang.String getCommandName()
Retrieves the name of this command (similar to the class name).
Returns:
name of this command class.

findClassesByPattern

public static java.util.List findClassesByPattern(Session session,
                                                  java.lang.String pattern)
                                           throws NotActiveException
Return a list of classes and interfaces whose names match the given pattern. The pattern syntax is a fully-qualified class name in which the first part may optionally be a "*" character, to match any package name prefix.
Parameters:
session - current Session.
pattern - Classname pattern (possibly prefixed with "*.").
Returns:
List of ReferenceType objects.
Throws:
NotActiveException - Thrown if the session is not active.

getThreadByID

public static com.sun.jdi.ThreadReference getThreadByID(Session session,
                                                        java.lang.String idToken)
                                                 throws NoSuchThreadException,
                                                        NotActiveException
Finds a thread in the list of all threads whose unique ID number matches that given. The number is a natural (base 10) ID number, unique for all objects in the debuggee VM.
Parameters:
session - current Session.
idToken - thread ID token.
Returns:
ThreadReference, or null if not found.
Throws:
NoSuchThreadException - Thrown if the thread ID does not match a known thread.
NotActiveException - Thrown if the current session is not active.
java.lang.NumberFormatException - Thrown if the idToken is not a valid number.

help

public void help(Log out)
Display helpful information about this command, including the possible arguments and their interpretation. First prints the command's description.
Parameters:
out - output to write help message to.

help

protected void help(Log out,
                    java.lang.StringBuffer buf)
Display helpful information about this command, including the possible arguments and their interpretation.
Parameters:
out - output to write help message to.
buf - string buffer to use for printing.

missingArgs

public void missingArgs(Log out)
Display helpful information about this command because the user failed to provide all of the necessary arguments.
Parameters:
out - output to write help message to.

perform

public abstract void perform(Session session,
                             com.bluemarsh.util.StringTokenizer args,
                             Log out)
Perform the command using the given arguments. Any output that needs to be displayed should go to the out object.
Parameters:
session - JSwat session on which to operate.
args - Tokenized string of command arguments.
out - Output to write messages to.

receiveInput

public void receiveInput(Session session,
                         Log out,
                         CommandManager cmdman,
                         java.lang.String input)
Called by the CommandManager when new input has been received from the user. This asynchronously follows a call to CommandManager.grabInput()
Parameters:
session - JSwat session on which to operate.
out - Output to write messages to.
cmdman - CommandManager that's calling us.
input - Input from user.

resolveOverload

protected static com.sun.jdi.Method resolveOverload(java.util.List overloads,
                                                    java.util.List arguments)
Finds a method that matches the given arguments.
Parameters:
overloads - List of overloaded methods.
arguments - List of arguments for method.
Returns:
Matching method, or null if none found.