edu.rice.cs.drjava.model.repl
Interface InteractionsModelCallback

All Known Implementing Classes:
DefaultInteractionsModel, InteractionsModel, InteractionsModelTest.BadSyntaxInteractionsModel, InteractionsModelTest.IncompleteInputInteractionsModel, InteractionsModelTest.TestInteractionsModel, MainJVM.DummyInteractionsModel, RMIInteractionsModel, SimpleInteractionsModel

public interface InteractionsModelCallback

Callback interface which allows an InteractionsModel to respond to events in a remote Java interpreter. These methods may run outside the event thread!

Version:
$Id: InteractionsModelCallback.java 5175 2010-01-20 08:46:32Z mgricken $

Method Summary
 void changeInputListener(InputListener oldListener, InputListener newListener)
          Changes the input listener.
 List<File> getCompilerBootClassPath()
          A compiler can instruct DrJava to include additional elements for the boot class path of the Interactions JVM.
 String getConsoleInput()
          Called when input is request from System.in.
 int getDebugPort()
          Returns an available port number to use for debugging a remote interpreter.
 void interpreterReady(File wd)
          Called to assert that a fresh Java interpreter is ready for use either after a start or a restart.
 void interpreterResetFailed(Throwable th)
          This method is called by the Main JVM if the Interpreter JVM cannot be exited (likely because of its having a security manager)
 void interpreterResetting()
          Called when the interpreter starts to reset.
 void interpreterWontStart(Exception e)
          Called when the slave JVM fails to startup
 void replCalledSystemExit(int status)
          Signifies that the most recent interpretation contained a call to System.exit.
 void replReturnedResult(String result, String style)
          Signifies that the most recent interpretation completed successfully, returning a value.
 void replReturnedSyntaxError(String errorMessage, String interaction, int startRow, int startCol, int endRow, int endCol)
          Signifies that the most recent interpretation was preempted by a syntax error.
 void replReturnedVoid()
          Signifies that the most recent interpretation completed successfully, returning no value.
 void replSystemErrPrint(String s)
          Called when the repl prints to System.err.
 void replSystemOutPrint(String s)
          Called when the repl prints to System.out.
 void replThrewException(String message)
          Signifies that the most recent interpretation was ended due to an exception being thrown.
 void replThrewException(String message, StackTraceElement[] stackTrace)
          Signifies that the most recent interpretation was ended due to an exception being thrown.
 void setInputListener(InputListener listener)
          Sets the listener for any type of single-source input event.
 String transformCommands(String interactionsString)
          Transform the command line to be interpreted into something the Interactions JVM can use.
 

Method Detail

getDebugPort

int getDebugPort()
                 throws IOException
Returns an available port number to use for debugging a remote interpreter.

Throws:
IOException - if unable to get a valid port number.

replSystemOutPrint

void replSystemOutPrint(String s)
Called when the repl prints to System.out.

Parameters:
s - String to print

replSystemErrPrint

void replSystemErrPrint(String s)
Called when the repl prints to System.err.

Parameters:
s - String to print

getConsoleInput

String getConsoleInput()
Called when input is request from System.in.

Returns:
the input given to System.in

setInputListener

void setInputListener(InputListener listener)
Sets the listener for any type of single-source input event. The listener can only be changed with the changeInputListener method.

Parameters:
listener - a listener that reacts to input requests
Throws:
IllegalStateException - if the input listener is locked

changeInputListener

void changeInputListener(InputListener oldListener,
                         InputListener newListener)
Changes the input listener. Takes in the old listener to ensure that the owner of the original listener is aware that it is being changed.

Parameters:
oldListener - the previous listener
newListener - the listener to install
Throws:
IllegalArgumentException - if oldListener is not the currently installed listener

replReturnedVoid

void replReturnedVoid()
Signifies that the most recent interpretation completed successfully, returning no value.


replReturnedResult

void replReturnedResult(String result,
                        String style)
Signifies that the most recent interpretation completed successfully, returning a value.

Parameters:
result - The .toString-ed version of the value that was returned by the interpretation. We must return the String form because returning the Object directly would require the data type to be serializable.

replThrewException

void replThrewException(String message)
Signifies that the most recent interpretation was ended due to an exception being thrown.

Parameters:
message - The exception's message

replThrewException

void replThrewException(String message,
                        StackTraceElement[] stackTrace)
Signifies that the most recent interpretation was ended due to an exception being thrown.

Parameters:
message - The exception's message

replReturnedSyntaxError

void replReturnedSyntaxError(String errorMessage,
                             String interaction,
                             int startRow,
                             int startCol,
                             int endRow,
                             int endCol)
Signifies that the most recent interpretation was preempted by a syntax error.

Parameters:
errorMessage - The syntax error message
startRow - The starting row of the error
startCol - The starting column of the error
endRow - The end row of the error
endCol - The end column of the error

replCalledSystemExit

void replCalledSystemExit(int status)
Signifies that the most recent interpretation contained a call to System.exit.

Parameters:
status - The exit status that will be returned.

interpreterResetFailed

void interpreterResetFailed(Throwable th)
This method is called by the Main JVM if the Interpreter JVM cannot be exited (likely because of its having a security manager)

Parameters:
th - The Throwable thrown by System.exit

interpreterWontStart

void interpreterWontStart(Exception e)
Called when the slave JVM fails to startup


interpreterResetting

void interpreterResetting()
Called when the interpreter starts to reset.


interpreterReady

void interpreterReady(File wd)
Called to assert that a fresh Java interpreter is ready for use either after a start or a restart. Is sometimes preceded by a call to interpreterResetting(), but not when the interpreter is first starting or is already fresh.


getCompilerBootClassPath

List<File> getCompilerBootClassPath()
A compiler can instruct DrJava to include additional elements for the boot class path of the Interactions JVM.


transformCommands

String transformCommands(String interactionsString)
Transform the command line to be interpreted into something the Interactions JVM can use. This replaces "java MyClass a b c" with Java code to call MyClass.main(new String[]{"a","b","c"}). "import MyClass" is not handled here.

Parameters:
interactionsString - unprocessed command line
Returns:
command line with commands transformed