Java Doc for InteractionsModel.java in  » IDE » DrJava » edu » rice » cs » drjava » model » repl » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » IDE » DrJava » edu.rice.cs.drjava.model.repl 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   edu.rice.cs.drjava.model.repl.InteractionsModel

All known Subclasses:   edu.rice.cs.drjava.model.repl.RMIInteractionsModel,  edu.rice.cs.drjava.model.repl.SimpleInteractionsModel,
InteractionsModel
abstract public class InteractionsModel implements InteractionsModelCallback(Code)
A model which can serve as the glue between an InteractionsDocument and a JavaInterpreter. This abstract class provides common functionality for all such models.
version:
   $Id: InteractionsModel.java 4264 2007-11-15 01:33:48Z mgricken $


Field Summary
final public static  StringBANNER_PREFIX
     Banner prefix.
final protected  ConsoleDocumentInterface_adapter
    
final protected  InteractionsDocument_document
     InteractionsDocument containing the commands and history.
protected volatile  InputListener_inputListener
     The input listener to listen for requests to System.in.
protected volatile  Pair<String, String>_lastError
     Last error, or null if successful.
final public static  String_newLine
    
final protected  InteractionsEventNotifier_notifier
     Keeps track of any listeners to the model.
protected volatile  Pair<String, String>_secondToLastError
    
protected volatile  boolean_waitingForFirstInterpreter
     Whether we are waiting for the interpreter to register for the first time.
protected volatile  File_workingDirectory
     The working directory for the current interpreter.
final public  Object_writerLock
     A lock object to prevent print calls to System.out or System.err from flooding the JVM, ensuring the UI remains responsive.

Constructor Summary
public  InteractionsModel(ConsoleDocumentInterface adapter, File wd, int historySize, int writeDelay)
     Constructs an InteractionsModel.

Method Summary
protected  void_createNewDebugPort()
     Generates an available port for use with the debugger.
protected static  String_deleteSemiColon(String s)
     Deletes the last character of a string.
protected  ArrayList<String>_getHistoryText(FileOpenSelector selector)
     Opens the files chosen in the given file selector, and returns an ArrayList with one history string for each selected file.
public  void_interactionIsOver()
     Any common behavior when an interaction ends.
abstract protected  void_interpret(String toEval)
     Interprets the given command.
abstract protected  void_interpreterResetFailed(Throwable t)
     Any extra action to perform (beyond notifying listeners) when the interpreter fails to reset.
abstract protected  void_notifyInteractionEnded()
     Notifies listeners that an interaction has ended.
abstract protected  void_notifyInteractionIncomplete()
     Notifies the view that the current interaction is incomplete.
abstract protected  void_notifyInteractionStarted()
     Notifies listeners that an interaction has started.
abstract protected  void_notifyInterpreterExited(int status)
     Notifies listeners that the interpreter has exited unexpectedly.
abstract public  void_notifyInterpreterReady(File wd)
     Notifies listeners that the interpreter is ready.
abstract protected  void_notifyInterpreterResetFailed(Throwable t)
     Notifies listeners that the interpreter reset failed.
abstract protected  void_notifyInterpreterResetting()
     Notifies listeners that the interpreter is resetting.
abstract protected  void_notifySlaveJVMUsed()
     Notifies listeners that the slave JVM has been used.
abstract protected  void_notifySyntaxErrorOccurred(int offset, int length)
    
protected  ArrayList<String>_removeSeparators(String text)
     Removes the interaction-separator comments from a history, so that they will not appear when executing the history.
Parameters:
  text - The full, formatted text of an interactions history (obtained from _getHistoryText) A list of strings representing each interaction in the history.
abstract protected  void_resetInterpreter(File wd)
     Resets the Java interpreter.
protected static  String_testClassCall(String s)
     Assumes a trimmed String.
public  void_writerDelay()
     Waits for a small amount of time on a shared writer lock.
abstract public  voidaddBuildDirectoryClassPath(File f)
    
abstract public  voidaddExternalFilesClassPath(File f)
    
abstract public  voidaddExtraClassPath(File f)
    
public  voidaddListener(InteractionsListener listener)
     Add an InteractionsListener to the model.
public  voidaddNewLine()
    
abstract public  voidaddProjectClassPath(File f)
     These add the given path to the classpaths used in the interpreter.
abstract public  voidaddProjectFilesClassPath(File f)
    
public  voidappend(String s, String styleName)
     Appends a string to the given document using a named style.
public  voidchangeInputListener(InputListener oldListener, InputListener newListener)
     Changes the input listener.
public  StringgetBanner()
    
public static  StringgetBanner(File wd)
    
abstract public  ConsoleDocumentgetConsoleDocument()
    
public  StringgetConsoleInput()
     Returns a line of text entered by the user at the equivalent of System.in.
public  intgetDebugPort()
     Returns the port number to use for debugging the interactions JVM.
public  InteractionsDocumentgetDocument()
     Returns the InteractionsDocument stored by this model.
public  Pair<String, String>getLastError()
     Return the last error as a pair (exception class name, message), or null if successful.
public  Pair<String, String>getSecondToLastError()
     Return the second to last error as a pair (exception class name, message), or null if successful.
public  StringgetStartUpBanner()
    
abstract public  StringgetVariableClassName(String var)
     Gets the class name of a variable in the current interpreter.
abstract public  StringgetVariableToString(String var)
     Gets the string representation of the value of a variable in the current interpreter.
public  FilegetWorkingDirectory()
     Returns the working directory for the current interpreter.
public  voidinteractionContinues()
    
final public  voidinterpret(String toEval)
     Interprets the given command.
Parameters:
  toEval - command to be evaluated.
public  voidinterpretCurrentInteraction()
     Interprets the current given text at the prompt in the interactions doc.
public  voidinterpreterReady(File wd)
     Called when a new Java interpreter has registered and is ready for use.
public  voidinterpreterResetFailed(Throwable t)
    
public  voidinterpreterResetting()
     Called when the interpreter starts to reset.
public  voidloadHistory(FileOpenSelector selector)
     Interprets the files selected in the FileOpenSelector.
public  InteractionsScriptModelloadHistoryAsScript(FileOpenSelector selector)
    
public  voidremoveAllInteractionListeners()
     Removes all InteractionsListeners from this model.
public  StringremoveLastFromHistory()
     Returns the last history item and then removes it, or returns null if the history is empty.
public  voidremoveListener(InteractionsListener listener)
     Remove an InteractionsListener from the model.
public  voidreplCalledSystemExit(int status)
     Signifies that the most recent interpretation contained a call to System.exit.
public  voidreplReturnedResult(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.
public  voidreplReturnedSyntaxError(String errorMessage, String interaction, int startRow, int startCol, int endRow, int endCol)
     Signifies that the most recent interpretation was preempted by a syntax error.
public  voidreplReturnedVoid()
     Signifies that the most recent interpretation completed successfully, returning no value.
public  voidreplSystemErrPrint(String s)
     Called when the repl prints to System.err.
public  voidreplSystemOutPrint(String s)
     Called when the repl prints to System.out.
public  voidreplThrewException(String exceptionClass, String message, String stackTrace, String shortMessage)
     Signifies that the most recent interpretation was ended due to an exception being thrown.
final public  voidresetInterpreter(File wd)
     Resets the Java interpreter with working directry wd.
public  voidresetLastErrors()
     Reset the information about the last and second to last error.
public  voidsetDebugPort(int port)
     Sets the port number to use for debugging the interactions JVM.
public  voidsetInputListener(InputListener listener)
     Sets the listener for any type of single-source input event.
public  voidsetWaitingForFirstInterpreter(boolean waiting)
     Sets this model's notion of whether it is waiting for the first interpreter to connect.
public  voidslaveJVMUsed()
     Called when the slave JVM has been used for interpretation or unit testing.

Field Detail
BANNER_PREFIX
final public static String BANNER_PREFIX(Code)
Banner prefix.



_adapter
final protected ConsoleDocumentInterface _adapter(Code)
The embedded interactions document (a SwingDocument in native DrJava)



_document
final protected InteractionsDocument _document(Code)
InteractionsDocument containing the commands and history.



_inputListener
protected volatile InputListener _inputListener(Code)
The input listener to listen for requests to System.in.



_lastError
protected volatile Pair<String, String> _lastError(Code)
Last error, or null if successful.



_newLine
final public static String _newLine(Code)



_notifier
final protected InteractionsEventNotifier _notifier(Code)
Keeps track of any listeners to the model.



_secondToLastError
protected volatile Pair<String, String> _secondToLastError(Code)



_waitingForFirstInterpreter
protected volatile boolean _waitingForFirstInterpreter(Code)
Whether we are waiting for the interpreter to register for the first time.



_workingDirectory
protected volatile File _workingDirectory(Code)
The working directory for the current interpreter.



_writerLock
final public Object _writerLock(Code)
A lock object to prevent print calls to System.out or System.err from flooding the JVM, ensuring the UI remains responsive. Only public for testing purposes.




Constructor Detail
InteractionsModel
public InteractionsModel(ConsoleDocumentInterface adapter, File wd, int historySize, int writeDelay)(Code)
Constructs an InteractionsModel.
Parameters:
  adapter - DocumentAdapter to use in the InteractionsDocument
Parameters:
  wd - Working directory for the interpreter
Parameters:
  historySize - Number of lines to store in the history
Parameters:
  writeDelay - Number of milliseconds to wait after each println




Method Detail
_createNewDebugPort
protected void _createNewDebugPort() throws IOException(Code)
Generates an available port for use with the debugger.
throws:
  IOException - if unable to get a valid port number.



_deleteSemiColon
protected static String _deleteSemiColon(String s)(Code)
Deletes the last character of a string. Assumes semicolon at the end, but does not check. Helper for _testClassCall(String).
Parameters:
  s - the String containing the semicolon a substring of s with one less character



_getHistoryText
protected ArrayList<String> _getHistoryText(FileOpenSelector selector) throws IOException, OperationCanceledException(Code)
Opens the files chosen in the given file selector, and returns an ArrayList with one history string for each selected file.
Parameters:
  selector - A file selector supporting multiple file selection a list of histories (one for each selected file)



_interactionIsOver
public void _interactionIsOver()(Code)
Any common behavior when an interaction ends. Subclasses might want to additionally notify listeners here. (Do this after calling super()), public for testing purposes.



_interpret
abstract protected void _interpret(String toEval)(Code)
Interprets the given command. This should only be called from interpret, never directly.
Parameters:
  toEval - command to be evaluated



_interpreterResetFailed
abstract protected void _interpreterResetFailed(Throwable t)(Code)
Any extra action to perform (beyond notifying listeners) when the interpreter fails to reset.
Parameters:
  t - The Throwable thrown by System.exit



_notifyInteractionEnded
abstract protected void _notifyInteractionEnded()(Code)
Notifies listeners that an interaction has ended. (Subclasses must maintain listeners.)



_notifyInteractionIncomplete
abstract protected void _notifyInteractionIncomplete()(Code)
Notifies the view that the current interaction is incomplete.



_notifyInteractionStarted
abstract protected void _notifyInteractionStarted()(Code)
Notifies listeners that an interaction has started. (Subclasses must maintain listeners.)



_notifyInterpreterExited
abstract protected void _notifyInterpreterExited(int status)(Code)
Notifies listeners that the interpreter has exited unexpectedly. (Subclasses must maintain listeners.)
Parameters:
  status - Status code of the dead process



_notifyInterpreterReady
abstract public void _notifyInterpreterReady(File wd)(Code)
Notifies listeners that the interpreter is ready. (Subclasses must maintain listeners.)



_notifyInterpreterResetFailed
abstract protected void _notifyInterpreterResetFailed(Throwable t)(Code)
Notifies listeners that the interpreter reset failed. (Subclasses must maintain listeners.)
Parameters:
  t - Throwable explaining why the reset failed.



_notifyInterpreterResetting
abstract protected void _notifyInterpreterResetting()(Code)
Notifies listeners that the interpreter is resetting. (Subclasses must maintain listeners.)



_notifySlaveJVMUsed
abstract protected void _notifySlaveJVMUsed()(Code)
Notifies listeners that the slave JVM has been used. (Subclasses must maintain listeners.)



_notifySyntaxErrorOccurred
abstract protected void _notifySyntaxErrorOccurred(int offset, int length)(Code)
Handles a syntax error being returned from an interaction
Parameters:
  offset - the first character of the error in the InteractionsDocument
Parameters:
  length - the length of the error.



_removeSeparators
protected ArrayList<String> _removeSeparators(String text)(Code)
Removes the interaction-separator comments from a history, so that they will not appear when executing the history.
Parameters:
  text - The full, formatted text of an interactions history (obtained from _getHistoryText) A list of strings representing each interaction in the history. If no separators are present, the entire history is treated as one interaction.



_resetInterpreter
abstract protected void _resetInterpreter(File wd)(Code)
Resets the Java interpreter. This should only be called from resetInterpreter, never directly.



_testClassCall
protected static String _testClassCall(String s)(Code)
Assumes a trimmed String. Returns a string of the main call that the interpretor can use.



_writerDelay
public void _writerDelay()(Code)
Waits for a small amount of time on a shared writer lock.



addBuildDirectoryClassPath
abstract public void addBuildDirectoryClassPath(File f)(Code)



addExternalFilesClassPath
abstract public void addExternalFilesClassPath(File f)(Code)



addExtraClassPath
abstract public void addExtraClassPath(File f)(Code)



addListener
public void addListener(InteractionsListener listener)(Code)
Add an InteractionsListener to the model.
Parameters:
  listener - a listener that reacts to Interactions events



addNewLine
public void addNewLine()(Code)



addProjectClassPath
abstract public void addProjectClassPath(File f)(Code)
These add the given path to the classpaths used in the interpreter.
Parameters:
  path - Path to add



addProjectFilesClassPath
abstract public void addProjectFilesClassPath(File f)(Code)



append
public void append(String s, String styleName)(Code)
Appends a string to the given document using a named style. Also waits for a small amount of time (_writeDelay) to prevent any one writer from flooding the model with print calls to the point that the user interface could become unresponsive.
Parameters:
  s - String to append to the end of the document
Parameters:
  styleName - Name of the style to use for s



changeInputListener
public void changeInputListener(InputListener oldListener, InputListener newListener)(Code)
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. It is therefore important NOT to include a public accessor to the input listener on the model.
Parameters:
  oldListener - the listener that was installed
Parameters:
  newListener - the listener to be installed



getBanner
public String getBanner()(Code)



getBanner
public static String getBanner(File wd)(Code)



getConsoleDocument
abstract public ConsoleDocument getConsoleDocument()(Code)
Gets the console tab document for this interactions model



getConsoleInput
public String getConsoleInput()(Code)
Returns a line of text entered by the user at the equivalent of System.in.



getDebugPort
public int getDebugPort() throws IOException(Code)
Returns the port number to use for debugging the interactions JVM. Generates an available port if one has not been set manually.
throws:
  IOException - if unable to get a valid port number.



getDocument
public InteractionsDocument getDocument()(Code)
Returns the InteractionsDocument stored by this model.



getLastError
public Pair<String, String> getLastError()(Code)
Return the last error as a pair (exception class name, message), or null if successful.



getSecondToLastError
public Pair<String, String> getSecondToLastError()(Code)
Return the second to last error as a pair (exception class name, message), or null if successful.



getStartUpBanner
public String getStartUpBanner()(Code)



getVariableClassName
abstract public String getVariableClassName(String var)(Code)
Gets the class name of a variable in the current interpreter.
Parameters:
  var - the name of the variable



getVariableToString
abstract public String getVariableToString(String var)(Code)
Gets the string representation of the value of a variable in the current interpreter.
Parameters:
  var - the name of the variable



getWorkingDirectory
public File getWorkingDirectory()(Code)
Returns the working directory for the current interpreter.



interactionContinues
public void interactionContinues()(Code)



interpret
final public void interpret(String toEval)(Code)
Interprets the given command.
Parameters:
  toEval - command to be evaluated.



interpretCurrentInteraction
public void interpretCurrentInteraction()(Code)
Interprets the current given text at the prompt in the interactions doc.



interpreterReady
public void interpreterReady(File wd)(Code)
Called when a new Java interpreter has registered and is ready for use.



interpreterResetFailed
public void interpreterResetFailed(Throwable t)(Code)
This method is called by the Main JVM if the Interpreter JVM cannot be exited
Parameters:
  t - The Throwable thrown by System.exit



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



loadHistory
public void loadHistory(FileOpenSelector selector) throws IOException(Code)
Interprets the files selected in the FileOpenSelector. Assumes all strings have no trailing whitespace. Interprets the array all at once so if there are any errors, none of the statements after the first erroneous one are processed.



loadHistoryAsScript
public InteractionsScriptModel loadHistoryAsScript(FileOpenSelector selector) throws IOException, OperationCanceledException(Code)



removeAllInteractionListeners
public void removeAllInteractionListeners()(Code)
Removes all InteractionsListeners from this model.



removeLastFromHistory
public String removeLastFromHistory()(Code)
Returns the last history item and then removes it, or returns null if the history is empty.



removeListener
public void removeListener(InteractionsListener listener)(Code)
Remove an InteractionsListener from the model. If the listener is not currently listening to this model, this method has no effect.
Parameters:
  listener - a listener that reacts to Interactions events



replCalledSystemExit
public void replCalledSystemExit(int status)(Code)
Signifies that the most recent interpretation contained a call to System.exit.
Parameters:
  status - The exit status that will be returned.



replReturnedResult
public void replReturnedResult(String result, String style)(Code)
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.



replReturnedSyntaxError
public void replReturnedSyntaxError(String errorMessage, String interaction, int startRow, int startCol, int endRow, int endCol)(Code)
Signifies that the most recent interpretation was preempted by a syntax error. The integer parameters support future error highlighting.
Parameters:
  errorMessage - The syntax error message
Parameters:
  startRow - The starting row of the error
Parameters:
  startCol - The starting column of the error
Parameters:
  endRow - The end row of the errorparam endCol The end column of the error



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



replSystemErrPrint
public void replSystemErrPrint(String s)(Code)
Called when the repl prints to System.err. Includes a delay to prevent flooding the interactions document.
Parameters:
  s - String to print



replSystemOutPrint
public void replSystemOutPrint(String s)(Code)
Called when the repl prints to System.out. Includes a delay to prevent flooding the interactions document.
Parameters:
  s - String to print



replThrewException
public void replThrewException(String exceptionClass, String message, String stackTrace, String shortMessage)(Code)
Signifies that the most recent interpretation was ended due to an exception being thrown.
Parameters:
  exceptionClass - The name of the class of the thrown exception
Parameters:
  message - The exception's message
Parameters:
  stackTrace - The stack trace of the exception



resetInterpreter
final public void resetInterpreter(File wd)(Code)
Resets the Java interpreter with working directry wd.



resetLastErrors
public void resetLastErrors()(Code)
Reset the information about the last and second to last error.



setDebugPort
public void setDebugPort(int port)(Code)
Sets the port number to use for debugging the interactions JVM.
Parameters:
  port - Port to use to debug the interactions JVM



setInputListener
public void setInputListener(InputListener listener)(Code)
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



setWaitingForFirstInterpreter
public void setWaitingForFirstInterpreter(boolean waiting)(Code)
Sets this model's notion of whether it is waiting for the first interpreter to connect. The interactionsReady event is not fired for the first interpreter.



slaveJVMUsed
public void slaveJVMUsed()(Code)
Called when the slave JVM has been used for interpretation or unit testing.



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.