|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectmatlabcontrol.MatlabProxy
matlabcontrol.LoggingMatlabProxy
public final class LoggingMatlabProxy
Wraps around a MatlabProxy to provide a log of interactions. The data is not altered. This logger is useful
for determining the Java types and structure of data returned from MATLAB.
Interaction with all methods, except those defined in Object and not overridden, is logged. Entering a
method, exiting a method, and throwing an exception are logged. Method parameters and return values are logged. The
contents of a returned array will be recursively explored and its contents logged. As is convention, all of these
interactions are logged at Level.FINER. If the logging system has not been otherwise configured, then the
ConsoleHandler which prints log messages to the console will not show these log messages as their level is
too low. To configure the ConsoleHandler to show these log messages, call showInConsoleHandler().
This class is unconditionally thread-safe.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class matlabcontrol.MatlabProxy |
|---|
MatlabProxy.DisconnectionListener, MatlabProxy.Identifier, MatlabProxy.MatlabThreadCallable<T>, MatlabProxy.MatlabThreadProxy |
| Constructor Summary | |
|---|---|
LoggingMatlabProxy(MatlabProxy delegateProxy)
Constructs the logging proxy. |
|
| Method Summary | ||
|---|---|---|
void |
addDisconnectionListener(MatlabProxy.DisconnectionListener listener)
Adds a disconnection listener that will be notified when this proxy becomes disconnected from MATLAB. |
|
boolean |
disconnect()
Disconnects the proxy from MATLAB. |
|
void |
eval(java.lang.String command)
Evaluates a command in MATLAB. |
|
void |
exit()
Exits MATLAB. |
|
void |
feval(java.lang.String functionName,
java.lang.Object... args)
Calls a MATLAB function with the name functionName, returning the result. |
|
MatlabProxy.Identifier |
getIdentifier()
Returns the unique identifier for this proxy. |
|
java.lang.Object |
getVariable(java.lang.String variableName)
Gets the value of variableName in MATLAB. |
|
|
invokeAndWait(MatlabProxy.MatlabThreadCallable<U> callable)
Runs the callable on MATLAB's main thread and waits for it to return its result. |
|
boolean |
isConnected()
Whether this proxy is connected to MATLAB. |
|
boolean |
isExistingSession()
Whether this proxy is connected to a session of MATLAB that was running previous to the request to create this proxy. |
|
boolean |
isRunningInsideMatlab()
Whether this proxy is running inside of MATLAB. |
|
void |
removeDisconnectionListener(MatlabProxy.DisconnectionListener listener)
Removes a disconnection listener. |
|
java.lang.Object[] |
returningEval(java.lang.String command,
int nargout)
Evaluates a command in MATLAB, returning the result. |
|
java.lang.Object[] |
returningFeval(java.lang.String functionName,
int nargout,
java.lang.Object... args)
Calls a MATLAB function with the name functionName, returning the result. |
|
void |
setVariable(java.lang.String variableName,
java.lang.Object value)
Sets variableName to value in MATLAB, creating the variable if it does not yet exist. |
|
static void |
showInConsoleHandler()
Configures the ConsoleHandler responsible for showing logging records to show the records that are
logged by this proxy. |
|
java.lang.String |
toString()
Returns a brief description of this proxy. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public LoggingMatlabProxy(MatlabProxy delegateProxy)
MatlabProxy will be delegated to
delegateProxy.
delegateProxy - | Method Detail |
|---|
public static void showInConsoleHandler()
ConsoleHandler responsible for showing logging records to show the records that are
logged by this proxy. This behavior is useful if you have not otherwise configured logging in your application.
public void eval(java.lang.String command)
throws MatlabInvocationException
MatlabOperationseval('command').
command - the command to be evaluated in MATLAB
MatlabInvocationException
public java.lang.Object[] returningEval(java.lang.String command,
int nargout)
throws MatlabInvocationException
MatlabOperationseval('command').
nargout. This is equivalent in MATLAB to the number of variables placed on the left hand side of an
expression. For example, in MATLAB the inmem function may be used with either 1, 2, or 3 return values
each resulting in a different behavior:
M = inmem;
[M, X] = inmem;
[M, X, J] = inmem;
The returned Object array will be of length nargout with each return argument placed into the
corresponding array position.
nargout then an exception will be
thrown.
command - the command to be evaluated in MATLABnargout - the number of arguments that will be returned from evaluating command
nargout
MatlabInvocationException
public void feval(java.lang.String functionName,
java.lang.Object... args)
throws MatlabInvocationException
MatlabOperationsfunctionName, returning the result. Arguments to the function may
be provided as args, but are not required if the function needs no arguments.
String will be converted to a MATLAB char array, not a variable name.
functionName - the name of the MATLAB function to callargs - the arguments to the function
MatlabInvocationException
public java.lang.Object[] returningFeval(java.lang.String functionName,
int nargout,
java.lang.Object... args)
throws MatlabInvocationException
MatlabOperationsfunctionName, returning the result. Arguments to the function may
be provided as args, but are not required if the function needs no arguments.
String will be converted to a MATLAB char array, not a variable name.
nargout. This is equivalent in MATLAB to the number of variables placed on the left hand side of an
expression. For example, in MATLAB the inmem function may be used with either 1, 2, or 3 return values
each resulting in a different behavior:
M = inmem;
[M, X] = inmem;
[M, X, J] = inmem;
The returned Object array will be of length nargout with each return argument placed into the
corresponding array position.
nargout then an
exception will be thrown.
functionName - the name of the MATLAB function to callnargout - the number of arguments that will be returned by functionNameargs - the arguments to the function
nargout
MatlabInvocationException
public void setVariable(java.lang.String variableName,
java.lang.Object value)
throws MatlabInvocationException
MatlabOperationsvariableName to value in MATLAB, creating the variable if it does not yet exist.
MatlabInvocationException
public java.lang.Object getVariable(java.lang.String variableName)
throws MatlabInvocationException
MatlabOperationsvariableName in MATLAB.
MatlabInvocationException
public <U> U invokeAndWait(MatlabProxy.MatlabThreadCallable<U> callable)
throws MatlabInvocationException
MatlabProxycallable on MATLAB's main thread and waits for it to return its result. This method allows for
uninterrupted access to MATLAB's main thread between two or more interactions with MATLAB.
callable must be Serializable; it may not be
Remote.
invokeAndWait in class MatlabProxyMatlabInvocationExceptionpublic void addDisconnectionListener(MatlabProxy.DisconnectionListener listener)
MatlabProxy
addDisconnectionListener in class MatlabProxypublic void removeDisconnectionListener(MatlabProxy.DisconnectionListener listener)
MatlabProxy
removeDisconnectionListener in class MatlabProxypublic boolean disconnect()
MatlabProxytrue if the proxy is now disconnected,
false otherwise.
disconnect in class MatlabProxyMatlabProxy.exit(),
MatlabProxy.isConnected()public boolean isExistingSession()
MatlabProxy
isExistingSession in class MatlabProxypublic boolean isRunningInsideMatlab()
MatlabProxy
isRunningInsideMatlab in class MatlabProxypublic boolean isConnected()
MatlabProxyfalse are if the proxy has been disconnected via
MatlabProxy.disconnect() or MATLAB has been closed (when running outside MATLAB).
isConnected in class MatlabProxyMatlabProxy.disconnect(),
MatlabProxy.exit()public MatlabProxy.Identifier getIdentifier()
MatlabProxy
getIdentifier in class MatlabProxy
public void exit()
throws MatlabInvocationException
MatlabProxyeval or feval command will cause MATLAB to
hang indefinitely.
exit in class MatlabProxyMatlabInvocationExceptionMatlabProxy.disconnect(),
MatlabProxy.isConnected()public java.lang.String toString()
MatlabProxy
toString in class MatlabProxy
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||