package bluej.debugmgr.objectbench;

import bluej.BlueJEvent;
import bluej.debugger.DebuggerObject;
import bluej.debugger.ExceptionDescription;
import bluej.debugmgr.ExecutionEvent;
import bluej.debugmgr.ExpressionInformation;
import bluej.debugmgr.ResultWatcher;
import bluej.pkgmgr.Package;
import bluej.testmgr.record.InvokerRecord;
import bluej.views.CallableView;
import bluej.views.MethodView;
import javafx.stage.Stage;


| A result watcher which handles standard invocation of methods and constructors. | public abstract class ResultWatcherBase implements ResultWatcher{ private final CallableView method; private DebuggerObject obj; private String objInstanceName; private Package pkg; private Stage parentWindow; private String className;
| Construct a new ResultWatcherBase, for a constructor or static method call. | @param pkg The package in which the call is executed | @param parentWindow The parent window for display | @param method The method/constructor being called | public ResultWatcherBase(Package pkg, Stage parentWindow, CallableView method) { this.method = method; this.className = method.getClassName(); this.pkg = pkg; this.parentWindow = parentWindow; }
| Construct a new ResultWatcherBase, for an instance method call. | @param obj The receiver of the call | @param objInstanceName The name of the receiver instance (as on the object bench) | @param pkg The package in which the call is executed | @param parentWindow The parent window for display | @param method The method being called | public ResultWatcherBase(DebuggerObject obj, String objInstanceName, Package pkg, Stage parentWindow, CallableView method) { this.method = method; this.obj = obj; this.objInstanceName = objInstanceName; this.pkg = pkg; this.parentWindow = parentWindow; this.className = obj.getClassName(); } @Override public void beginCompile() { } @Override public void beginExecution(InvokerRecord ir) { } @Override public void putResult(DebuggerObject result, String name, InvokerRecord ir) { ExecutionEvent executionEvent = new ExecutionEvent(pkg, className, objInstanceName); if (method instanceof MethodView) { MethodView mv = (MethodView) method; executionEvent.setMethodName(mv.getName()); } executionEvent.setParameters(method.getParamTypes(false), ir.getArgumentValues()); executionEvent.setResult(ExecutionEvent.NORMAL_EXIT); executionEvent.setResultObject(result); BlueJEvent.raiseEvent(BlueJEvent.EXECUTION_RESULT, executionEvent); pkg.getProject().updateInspectors(); addInteraction(ir); if (result != null && ! result.isNullObject()) { nonNullResult(result, name, ir); } }
| Handle a non-null object result. By default, the result is inspected. | @param result The result object | @param name The suggested name for use in the inspector | @param ir Details of the invocation. | protected void nonNullResult(DebuggerObject result, String name, InvokerRecord ir) { if (method instanceof MethodView) { MethodView mv = (MethodView) method; ExpressionInformation expressionInformation; if (obj != null) { expressionInformation = new ExpressionInformation(mv, objInstanceName, obj.getGenType()); } else { expressionInformation = new ExpressionInformation(mv, objInstanceName); } expressionInformation.setArgumentValues(ir.getArgumentValues()); pkg.getProject().getResultInspectorInstance(result, name, pkg, ir, expressionInformation, parentWindow); } }
| Called to record the result of an interaction, e.g. for unit | testing recording or Greenfoot's save-the-world. | protected abstract void addInteraction(InvokerRecord ir); @Override public void putError(String msg, InvokerRecord ir) { } @Override public void putException(ExceptionDescription exception, InvokerRecord ir) { ExecutionEvent executionEvent = new ExecutionEvent(pkg, className, objInstanceName); executionEvent.setParameters(method.getParamTypes(false), ir.getArgumentValues()); executionEvent.setResult(ExecutionEvent.EXCEPTION_EXIT); executionEvent.setException(exception); BlueJEvent.raiseEvent(BlueJEvent.EXECUTION_RESULT, executionEvent); pkg.getProject().updateInspectors(); pkg.exceptionMessage(exception); } @Override public void putVMTerminated(InvokerRecord ir) { ExecutionEvent executionEvent = new ExecutionEvent(pkg, className, objInstanceName); executionEvent.setParameters(method.getParamTypes(false), ir.getArgumentValues()); executionEvent.setResult(ExecutionEvent.TERMINATED_EXIT); BlueJEvent.raiseEvent(BlueJEvent.EXECUTION_RESULT, executionEvent); } }
top, use, map, abstract class ResultWatcherBase

.   ResultWatcherBase
.   ResultWatcherBase
.   beginCompile
.   beginExecution
.   putResult
.   nonNullResult
.   addInteraction
.   putError
.   putException
.   putVMTerminated




156 neLoCode + 17 LoComm