edu.ucsb.cs.jicos.services.external.services.matlab
Class MatlabImpl

java.lang.Object
  extended by edu.ucsb.cs.jicos.services.external.services.ProxyServiceExternal
      extended by edu.ucsb.cs.jicos.services.external.services.matlab.MatlabImpl
All Implemented Interfaces:
Matlab

public final class MatlabImpl
extends edu.ucsb.cs.jicos.services.external.services.ProxyServiceExternal
implements Matlab


Field Summary
static java.lang.String DEFAULT_DebugStatus
          The default debug mode value.
static java.lang.String DEFAULT_StartCommand
          The default command used to start the Matlab engine with.
static boolean DEFAULT_StartEngine
          The default start matlab engine value.
static boolean isAvailable
          Is matlab available on this host.
static boolean isDebug
          The current debug value.
static java.lang.String PROPERTY_Base
          Base name of properties for this class.
static int TYPE_Boolean
          A boolean data type.
static int TYPE_Byte
          A byte data (uint8_t) type.
static int TYPE_Char
          A character (int8_t) data type.
static int TYPE_Double
          A double data type.
static int TYPE_Float
          A float data type.
static int TYPE_Int
          A int data type.
static int TYPE_LLong
          A long long data (int64_t) type.
static int TYPE_Long
          A long data (int32_t) type.
static int TYPE_Null
          A null(Java)/NULL(C) value.
static int TYPE_Short
          A short int data (int16_t) type.
static int TYPE_UChar
          A unsigned character (uint8_t) data type.
static int TYPE_UInt
          A unsigned int data type.
static int TYPE_ULLong
          A unsigned long long data (uint64_t) type.
static int TYPE_ULong
          A unsigned long data (uint32_t) type.
static int TYPE_Unknown
          An unknown data type.
static int TYPE_UShort
          A unsigned short data (int16_t) type.
 
Constructor Summary
MatlabImpl()
          Create a Matlab engine with the default starting arguments.
MatlabImpl(java.lang.String startCommand, java.lang.Boolean debugOn)
          Create a Matlab engine with the given start arguments and debug mode.
 
Method Summary
 void close()
          Shut down the matlab engine.
 java.lang.Object evaluate(java.lang.String command, java.lang.String resultName, java.util.Map nameValueMap)
          Evaluate a Matlab command - helper method: automatically flush vars.
 java.lang.Object evaluate(java.lang.String command, java.lang.String resultName, java.util.Map nameValueMap, boolean flushVariables)
          Evaluate a Matlab command.
 java.lang.Object getVariable(java.lang.String varName)
          Retrieve a variable from the Matlab engine.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TYPE_Unknown

public static final int TYPE_Unknown
An unknown data type.

See Also:
Constant Field Values

TYPE_Char

public static final int TYPE_Char
A character (int8_t) data type.

See Also:
Constant Field Values

TYPE_UChar

public static final int TYPE_UChar
A unsigned character (uint8_t) data type.

See Also:
Constant Field Values

TYPE_Byte

public static final int TYPE_Byte
A byte data (uint8_t) type.

See Also:
Constant Field Values

TYPE_Short

public static final int TYPE_Short
A short int data (int16_t) type.

See Also:
Constant Field Values

TYPE_UShort

public static final int TYPE_UShort
A unsigned short data (int16_t) type.

See Also:
Constant Field Values

TYPE_Int

public static final int TYPE_Int
A int data type.

See Also:
Constant Field Values

TYPE_UInt

public static final int TYPE_UInt
A unsigned int data type.

See Also:
Constant Field Values

TYPE_Long

public static final int TYPE_Long
A long data (int32_t) type.

See Also:
Constant Field Values

TYPE_ULong

public static final int TYPE_ULong
A unsigned long data (uint32_t) type.

See Also:
Constant Field Values

TYPE_LLong

public static final int TYPE_LLong
A long long data (int64_t) type.

See Also:
Constant Field Values

TYPE_ULLong

public static final int TYPE_ULLong
A unsigned long long data (uint64_t) type.

See Also:
Constant Field Values

TYPE_Boolean

public static final int TYPE_Boolean
A boolean data type.

See Also:
Constant Field Values

TYPE_Double

public static final int TYPE_Double
A double data type.

See Also:
Constant Field Values

TYPE_Float

public static final int TYPE_Float
A float data type.

See Also:
Constant Field Values

TYPE_Null

public static final int TYPE_Null
A null(Java)/NULL(C) value.

See Also:
Constant Field Values

isAvailable

public static final boolean isAvailable
Is matlab available on this host.


DEFAULT_StartCommand

public static final java.lang.String DEFAULT_StartCommand
The default command used to start the Matlab engine with.

See Also:
Constant Field Values

DEFAULT_DebugStatus

public static final java.lang.String DEFAULT_DebugStatus
The default debug mode value.

See Also:
Constant Field Values

DEFAULT_StartEngine

public static final boolean DEFAULT_StartEngine
The default start matlab engine value.

See Also:
Constant Field Values

PROPERTY_Base

public static final java.lang.String PROPERTY_Base
Base name of properties for this class.

See Also:
Constant Field Values

isDebug

public static boolean isDebug
The current debug value.

Constructor Detail

MatlabImpl

public MatlabImpl()
           throws MatlabProxyNotFoundException,
                  MatlabException
Create a Matlab engine with the default starting arguments.

Throws:
MatlabProxyNotFoundException - If the Matlab engine is not available on this machine.
MatlabException - If there was an exception whle starting the engine.

MatlabImpl

public MatlabImpl(java.lang.String startCommand,
                  java.lang.Boolean debugOn)
           throws MatlabProxyNotFoundException,
                  MatlabException
Create a Matlab engine with the given start arguments and debug mode.

Parameters:
startCommand - Command to start Matlab engine with.
debugOn - Turn on debugging output (especially within the JNI code).
Throws:
MatlabProxyNotFoundException - If the Matlab engine is not available on this machine.
MatlabException - If there was an exception whle starting the engine.
Method Detail

close

public void close()
           throws MatlabException
Shut down the matlab engine.

Throws:
MatlabException

evaluate

public java.lang.Object evaluate(java.lang.String command,
                                 java.lang.String resultName,
                                 java.util.Map nameValueMap)
                          throws java.lang.NumberFormatException,
                                 MatlabException
Evaluate a Matlab command - helper method: automatically flush vars.

Specified by:
evaluate in interface Matlab
Parameters:
command - The command to evaluate.
resultName - The variable with the answer (null implies "JICOS")
nameValueMap - A collection of name/value pairs.
Returns:
The result of the computation.
Throws:
java.lang.NumberFormatException - If one of the data types is unknown.
MatlabException - On error in the engine.

evaluate

public java.lang.Object evaluate(java.lang.String command,
                                 java.lang.String resultName,
                                 java.util.Map nameValueMap,
                                 boolean flushVariables)
                          throws java.lang.NumberFormatException,
                                 MatlabException
Evaluate a Matlab command.

Specified by:
evaluate in interface Matlab
Parameters:
command - The command to evaluate.
resultName - The variable with the answer (null implies "JICOS")
nameValueMap - A collection of name/value pairs.
flushVariables - Automatically remove variables when done?
Returns:
The result of the computation.
Throws:
java.lang.NumberFormatException - If one of the data types is unknown.
MatlabException - On error in the engine.

getVariable

public java.lang.Object getVariable(java.lang.String varName)
                             throws MatlabException
Retrieve a variable from the Matlab engine.

Specified by:
getVariable in interface Matlab
Parameters:
varName - The name of the variable to retrieve.
Returns:
The variable, or null if not available.
Throws:
MatlabException - On error in the engine.


Jicos: http://cs.ucsb.edu/projects/jicos