|
|
||
|
|
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface MathLink
MathLink is the low-level interface that is the root of all link objects in J/Link. The methods in MathLink correspond roughly to a subset of those in the C-language MathLink API. Most programmers will deal instead with objects of type KernelLink, a higher-level interface that extends MathLink and incorporates the assumption that the program on the other side of the link is a Mathematica kernel.
You create objects of type MathLink via the MathLinkFactory.createLink() method. Again, though, most programmers will use KernelLink instead of MathLink.
Most MathLink methods throw a MathLinkException if a link-related error occurs. Examples would be calling endPacket() before sending a complete expression, or calling getFunction() when an integer is waiting on the link.
For additional information about these methods, see the J/Link User Guide, and also the MathLink documentation in the Mathematica book. Most of these methods are substantially similar, if not identical, to their C counterparts as documented in the book.
KernelLink,
MathLinkFactory| Field Summary | |
|---|---|
static int |
BEGINDLGPKT
Constant returned by nextPacket. |
static int |
CALLPKT
Constant returned by nextPacket. |
static int |
DISPLAYENDPKT
Constant returned by nextPacket. |
static int |
DISPLAYPKT
Constant returned by nextPacket. |
static int |
ENDDLGPKT
Constant returned by nextPacket. |
static int |
ENTEREXPRPKT
Constant returned by nextPacket. |
static int |
ENTERTEXTPKT
Constant returned by nextPacket. |
static int |
EVALUATEPKT
Constant returned by nextPacket. |
static int |
EXPRESSIONPKT
|
static int |
FEPKT
|
static int |
FIRSTUSERPKT
|
static int |
ILLEGALPKT
|
static int |
INPUTNAMEPKT
Constant returned by nextPacket. |
static int |
INPUTPKT
Constant returned by nextPacket. |
static int |
INPUTSTRPKT
Constant returned by nextPacket. |
static int |
LASTUSERPKT
|
static int |
MENUPKT
Constant returned by nextPacket. |
static int |
MESSAGEPKT
Constant returned by nextPacket. |
static int |
MLABORTMESSAGE
Used in putMessage() to cause the current Mathematica evaluation to be aborted. |
static int |
MLE_ARRAY_TOO_SHALLOW
|
static int |
MLE_BAD_COMPLEX
|
static int |
MLE_CONNECT_TIMEOUT
|
static int |
MLE_CREATION_FAILED
|
static int |
MLE_FIRST_USER_EXCEPTION
|
static int |
MLE_LINK_IS_NULL
|
static int |
MLE_NON_ML_ERROR
|
static int |
MLE_OUT_OF_MEMORY
|
static int |
MLE_WRAPPED_EXCEPTION
|
static int |
MLEOK
|
static int |
MLEUSER
|
static int |
MLINTERRUPTMESSAGE
|
static int |
MLTERMINATEMESSAGE
|
static int |
MLTKERR
|
static int |
MLTKFUNC
Constant for use in putNext() or returned by getNext() and getType(). |
static int |
MLTKINT
Constant for use in putNext() or returned by getNext() and getType(). |
static int |
MLTKREAL
Constant for use in putNext() or returned by getNext() and getType(). |
static int |
MLTKSTR
Constant for use in putNext() or returned by getNext() and getType(). |
static int |
MLTKSYM
Constant for use in putNext() or returned by getNext() and getType(). |
static int |
OUTPUTNAMEPKT
Constant returned by nextPacket. |
static int |
RESUMEPKT
Constant returned by nextPacket. |
static int |
RETURNEXPRPKT
Constant returned by nextPacket. |
static int |
RETURNPKT
Constant returned by nextPacket. |
static int |
RETURNTEXTPKT
Constant returned by nextPacket. |
static int |
SUSPENDPKT
Constant returned by nextPacket. |
static int |
SYNTAXPKT
Constant returned by nextPacket. |
static int |
TEXTPKT
Constant returned by nextPacket. |
static int |
TYPE_BIGDECIMAL
Constant for use in getArray(). |
static int |
TYPE_BIGINTEGER
Constant for use in getArray(). |
static int |
TYPE_BOOLEAN
Constant for use in getArray(). |
static int |
TYPE_BYTE
Constant for use in getArray(). |
static int |
TYPE_CHAR
Constant for use in getArray(). |
static int |
TYPE_COMPLEX
Constant for use in getArray(). |
static int |
TYPE_DOUBLE
Constant for use in getArray(). |
static int |
TYPE_EXPR
Constant for use in getArray(). |
static int |
TYPE_FLOAT
Constant for use in getArray(). |
static int |
TYPE_INT
Constant for use in getArray(). |
static int |
TYPE_LONG
Constant for use in getArray(). |
static int |
TYPE_SHORT
Constant for use in getArray(). |
static int |
TYPE_STRING
Constant for use in getArray(). |
| Method Summary | |
|---|---|
void |
activate()
Same as connect(). |
boolean |
addMessageHandler(java.lang.Class cls,
java.lang.Object obj,
java.lang.String methName)
Specifies the Java method you want called as a message handler. |
int |
bytesToGet()
Returns the number of bytes that remain to be read in the element that is currently being read in textual form. |
int |
bytesToPut()
Gives the number of bytes that remain to be sent in the element that is currently being sent in textual form. |
int |
checkFunction(java.lang.String f)
Reads a function name and argument count and compares the function name with f. |
void |
checkFunctionWithArgCount(java.lang.String f,
int argCount)
Reads a function name and argument count and compares the function name with f and the argument count with argCount. |
boolean |
clearError()
Clears the link error condition, if possible. |
void |
close()
Closes the link. |
void |
connect()
Connects the link, if it has not already been connected. |
void |
connect(long timeoutMillis)
Connects the link, but waits at most timeoutMillis for a response from the other side. |
long |
createMark()
Creates a mark at the current point in the incoming MathLink data stream. |
void |
destroyMark(long mark)
Destroys a mark. |
void |
endPacket()
Call it when you are finished writing the contents of a single packet. |
int |
error()
Gives the code corresponding to the current error state of the link. |
java.lang.String |
errorMessage()
Gives a textual message describing the current error. |
void |
flush()
Immediately transmits any data buffered for sending over the link. |
int |
getArgCount()
Reads the argument count of an expression being read manually. |
java.lang.Object |
getArray(int type,
int depth)
Reads an array of the specified type and depth. |
java.lang.Object |
getArray(int type,
int depth,
java.lang.String[] heads)
Reads an array of the specified type and depth and records the heads at each level. |
boolean |
getBoolean()
Reads the Mathematica symbols True or False as a boolean. |
boolean[] |
getBooleanArray1()
Reads a list as a one-dimensional array of booleans. |
boolean[][] |
getBooleanArray2()
Reads an array as a two-dimensional array of booleans. |
byte[] |
getByteArray1()
Reads a list or array as a one-dimensional array of bytes. |
byte[][] |
getByteArray2()
Reads an array as a two-dimensional array of bytes. |
byte[] |
getByteString(int missing)
Reads a Mathematica string as an array of bytes. |
char[] |
getCharArray1()
Reads a list or array as a one-dimensional array of chars. |
char[][] |
getCharArray2()
Reads an array as a two-dimensional array of chars. |
java.lang.Object |
getComplex()
Reads a complex number. |
java.lang.Object[] |
getComplexArray1()
Reads a list as a one-dimensional array of complex numbers. |
java.lang.Object[][] |
getComplexArray2()
Reads a matrix as a two-dimensional array of complex numbers. |
java.lang.Class |
getComplexClass()
Gives the Java class that you have specified to map to Mathematica's Complex numbers. |
byte[] |
getData(int len)
Gets a specified number of bytes in the textual form of the expression currently being read. |
double |
getDouble()
Reads a Mathematica real number or integer as a double. |
double[] |
getDoubleArray1()
Reads a list or array as a one-dimensional array of doubles. |
double[][] |
getDoubleArray2()
Reads an array as a two-dimensional array of doubles. |
Expr |
getExpr()
Reads an expression from the link and creates an Expr from it. |
float[] |
getFloatArray1()
Reads a list or array as a one-dimensional array of floats. |
float[][] |
getFloatArray2()
Reads an array as a two-dimensional array of floats. |
MLFunction |
getFunction()
Reads a function name and argument count. |
int[] |
getIntArray1()
Reads a list or array as a one-dimensional array of ints. |
int[][] |
getIntArray2()
Reads an array as a two-dimensional array of ints. |
int |
getInteger()
Reads a Mathematica integer as an int. |
long[] |
getLongArray1()
Reads a list as a one-dimensional array of longs. |
long[][] |
getLongArray2()
Reads an array as a two-dimensional array of longs. |
long |
getLongInteger()
Reads a Mathematica integer as a long. |
int |
getMessage()
Deprecated. |
int |
getNext()
Gives the type of the next element in the expression currently being read. |
short[] |
getShortArray1()
Reads a list or array as a one-dimensional array of shorts. |
short[][] |
getShortArray2()
Reads an array as a two-dimensional array of shorts. |
java.lang.String |
getString()
Reads a Mathematica character string. |
java.lang.String[] |
getStringArray1()
Reads a list as a one-dimensional array of strings. |
java.lang.String[][] |
getStringArray2()
Reads an array as a two-dimensional array of strings. |
java.lang.String |
getSymbol()
Reads a Mathematica symbol as a string. |
int |
getType()
Gives the type of the current element in the expression currently being read. |
boolean |
messageReady()
Deprecated. |
java.lang.String |
name()
Gives the name of the link. |
void |
newPacket()
Discards the current packet, if it has been partially read. |
int |
nextPacket()
"Opens" the next packet arriving on the link. |
Expr |
peekExpr()
Creates an Expr from the current expression, but does not drain it off the link. |
void |
put(boolean b)
Sends the boolean value as the Mathematica symbol True or False. |
void |
put(double d)
Sends a double value. |
void |
put(int i)
Sends an integer value. |
void |
put(long i)
Sends a long value. |
void |
put(java.lang.Object obj)
Sends an object, including strings and arrays. |
void |
put(java.lang.Object obj,
java.lang.String[] heads)
Sends an array object. |
void |
putArgCount(int argCount)
Specifies the argument count for a composite expression being sent manually. |
void |
putByteString(byte[] data)
Sends an array of bytes to Mathematica as a string. |
void |
putData(byte[] data)
Used for sending elements in textual form. |
void |
putData(byte[] data,
int len)
An alternative form of putData() that lets you specify how many bytes from the array should be sent, rather than just sending the whole thing. |
void |
putFunction(java.lang.String f,
int argCount)
Sends a function name and argument count. |
void |
putMessage(int msg)
Sends a low-level MathLink message. |
void |
putNext(int type)
Identifies the type of data element that is to be sent. |
void |
putSize(int size)
Specifies the size in bytes of an element being sent in textual form. |
void |
putSymbol(java.lang.String s)
Sends a symbol name. |
boolean |
ready()
Indicates whether the link has data waiting to be read. |
boolean |
removeMessageHandler(java.lang.String methName)
Removes a message handler you previously set up with addMessageHandler. |
void |
seekMark(long mark)
Resets the current position in the incoming MathLink data stream to an earlier point. |
boolean |
setComplexClass(java.lang.Class cls)
Specifies the class you want to map to Mathematica's Complex numbers. |
void |
setError(int err)
Sets the link's error state to the specified value. |
boolean |
setYieldFunction(java.lang.Class cls,
java.lang.Object obj,
java.lang.String methName)
Sets the Java method you want called as a yield function. |
void |
transferExpression(MathLink source)
Writes a complete expression from the link source to this link. |
void |
transferToEndOfLoopbackLink(LoopbackLink source)
Writes the entire contents of the LoopbackLink source to this link. |
| Field Detail |
|---|
static final int ILLEGALPKT
static final int CALLPKT
static final int EVALUATEPKT
static final int RETURNPKT
static final int INPUTNAMEPKT
static final int ENTERTEXTPKT
static final int ENTEREXPRPKT
static final int OUTPUTNAMEPKT
static final int RETURNTEXTPKT
static final int RETURNEXPRPKT
static final int DISPLAYPKT
static final int DISPLAYENDPKT
static final int MESSAGEPKT
static final int TEXTPKT
static final int INPUTPKT
static final int INPUTSTRPKT
static final int MENUPKT
static final int SYNTAXPKT
static final int SUSPENDPKT
static final int RESUMEPKT
static final int BEGINDLGPKT
static final int ENDDLGPKT
static final int FIRSTUSERPKT
static final int LASTUSERPKT
static final int FEPKT
static final int EXPRESSIONPKT
static final int MLTERMINATEMESSAGE
static final int MLINTERRUPTMESSAGE
static final int MLABORTMESSAGE
static final int MLTKFUNC
static final int MLTKSTR
static final int MLTKSYM
static final int MLTKREAL
static final int MLTKINT
static final int MLTKERR
static final int MLEOK
static final int MLEUSER
static final int MLE_NON_ML_ERROR
static final int MLE_LINK_IS_NULL
static final int MLE_OUT_OF_MEMORY
static final int MLE_ARRAY_TOO_SHALLOW
static final int MLE_BAD_COMPLEX
static final int MLE_CREATION_FAILED
static final int MLE_CONNECT_TIMEOUT
static final int MLE_WRAPPED_EXCEPTION
static final int MLE_FIRST_USER_EXCEPTION
static final int TYPE_BOOLEAN
static final int TYPE_BYTE
static final int TYPE_CHAR
static final int TYPE_SHORT
static final int TYPE_INT
static final int TYPE_LONG
static final int TYPE_FLOAT
static final int TYPE_DOUBLE
static final int TYPE_STRING
static final int TYPE_BIGINTEGER
static final int TYPE_BIGDECIMAL
static final int TYPE_EXPR
static final int TYPE_COMPLEX
| Method Detail |
|---|
void close()
void connect()
throws MathLinkException
All the methods that read from the link will connect it if necessary. The connect() method lets you deliberately control the point in the program where the connection occurs, without having to read anything.
MathLinkException
void connect(long timeoutMillis)
throws MathLinkException
timeoutMillis - the number of milliseconds to wait
MathLinkExceptionconnect()
void activate()
throws MathLinkException
MathLinkExceptionconnect()
java.lang.String name()
throws MathLinkException
MathLinkExceptionvoid newPacket()
This is a useful cleanup function. You can call it when you are finished examining the contents of a packet that was opened with nextPacket() or waitForAnswer(), whether you have read the entire packet contents or not. You can be sure that the link is then in a state where you are ready to read the next packet.
It is also frequently used in a catch block for a MathLinkException, to clear off any unread data in a packet before returning to the normal program flow.
nextPacket()
int nextPacket()
throws MathLinkException
Most programmers will use this method rarely, if ever. J/Link provides higher-level functions in the KernelLink interface that hide these low-level details of the packet loop.
MathLinkExceptionnewPacket()
void endPacket()
throws MathLinkException
Calling endPacket() is not strictly necessary, but it is good style, and it allows J/Link to immediately generate a MathLinkException if you are not actually finished with writing the data you promised to send.
MathLinkExceptionint error()
errorMessage(),
clearError()boolean clearError()
java.lang.String errorMessage()
error()void setError(int err)
err - the error code
boolean ready()
throws MathLinkException
MathLinkException
void flush()
throws MathLinkException
Any calls that read from the link will flush it, so you only need to call flush() manually if you want to make sure data is sent right away even though you are not reading from the link immediately. Calls to ready() will not flush the link, so if you are sending something and then polling ready() waiting for the result to arrive (as opposed to just calling nextPacket() or waitForAnswer()), you must call flush to ensure that the data is sent.
MathLinkException
int getNext()
throws MathLinkException
To check the type of a partially read element without advancing to the next element, use getType().
MathLinkException
int getType()
throws MathLinkException
Unlike getNext(), getType() will not advance to the next element if the current element has only been partially read.
MathLinkExceptiongetNext()
void putNext(int type)
throws MathLinkException
putNext() is rarely needed. The two most likely uses are to put expressions whose heads are not mere symbols (e.g., Derivative[2][f]) or to put data in textual form. Calls to putNext() must be followed by putSize() and putData(), or by putArgCount() for the MLTKFUNC type. Here is how you could send Derivative[2][f]:
ml.putNext(MathLink.MLTKFUNC); // The func we are putting has head Derivative[2], arg f
ml.putArgCount(1); // this 1 is for the 'f'
ml.putNext(MathLink.MLTKFUNC); // The func we are putting has head Derivative, arg 2
ml.putArgCount(1); // this 1 is for the '2'
ml.putSymbol("Derivative");
ml.put(2);
ml.putSymbol("f");
type - one of MLTKINT, MLTKREAL, MLTKSTR, MLTKSYM, MLTKFUNC
MathLinkExceptionputSize(int),
putData(byte[]),
putArgCount(int)
int getArgCount()
throws MathLinkException
This method can be used after getNext() or getType() returns the value MLTKFUNC. The argument count is always followed by the head of the expression. The head is followed by the arguments; the argument count tells how many there will be.
MathLinkExceptiongetNext(),
getType()
void putArgCount(int argCount)
throws MathLinkException
Use it after a call to putNext() with the MLTKFUNC type.
argCount - the number of aruments in the expression being sent
MathLinkExceptionputNext(int)
void putSize(int size)
throws MathLinkException
A typical sequence would be putNext(), followed by putSize(), then putData().
size - the size of the data, in bytes, that will be written
with the following putData()
MathLinkExceptionputData(byte[]),
putNext(int)
int bytesToPut()
throws MathLinkException
After you have called putSize(), the link knows how many bytes you have promised to send. This method lets you determine how many you still need to send, in the unlikely event that you lose track after a series of putData() calls.
MathLinkExceptionputSize(int),
putData(byte[])
int bytesToGet()
throws MathLinkException
Lets you keep track of your progress reading an element through a series of getData() calls.
MathLinkException
MathLinkExceptiongetData(int)
void putData(byte[] data)
throws MathLinkException
The so-called "textual" means of sending data is rarely used. Its main use is to allow a very large string to be sent, where the string data is not held in a single String object. The most important use of this technique in the C-language MathLink API was to send integers and reals that were too large to fit into an int or double. This use is unnecessary in J/Link, since Java has BigInteger and BigDecimal classes, and these objects can be sent directly with put().
data - the textual representation of the data
MathLinkExceptionputNext(int),
putSize(int)
void putData(byte[] data,
int len)
throws MathLinkException
data - len -
MathLinkExceptionputData(byte[])
byte[] getData(int len)
throws MathLinkException
You can use bytesToGet() to determine if more getData() calls are needed to completely read the element.
len - the maximum number of bytes to read
MathLinkExceptionbytesToGet(),
getNext(),
getType()
java.lang.String getString()
throws MathLinkException
Because both Java and Mathematica strings are in Unicode, the read string is an exact match to its Mathematica representation.
MathLinkException
byte[] getByteString(int missing)
throws MathLinkException
In contrast with getString(), this method strips the incoming (16-bit Unicode) character
data into single-byte representation. Characters that cannot be represented faithfully
in single-byte form are replaced by the byte specified by the missing
parameter. This method is primarily useful if you know the incoming data contains only
ASCII characters and you want the data in the form of a byte array.
missing - the byte to replace non-ASCII characters with
MathLinkExceptiongetString()
void putByteString(byte[] data)
throws MathLinkException
Use this instead of put() if you have string data in the form of a byte array. In the C-language MathLink API, MLPutByteString was useful because the more obviously-named MLPutString required a specially-encoded string. Because Java strings and Mathematica strings are both Unicode, put() works in J/Link without requiring special encoding. Thus, putByteString() has little use.
data - the string data to send
MathLinkExceptionput(Object)
java.lang.String getSymbol()
throws MathLinkException
Because Java strings and Mathematica symbols are in Unicode, the read string is an exact match to its Mathematica representation.
MathLinkExceptiongetString()
void putSymbol(java.lang.String s)
throws MathLinkException
Both Java strings and Mathematica symbols are in Unicode, so you can send symbols with the full Unicode character set.
s - the symbol name
MathLinkException
boolean getBoolean()
throws MathLinkException
MathLinkException
void put(boolean b)
throws MathLinkException
b - the value to send
MathLinkException
int getInteger()
throws MathLinkException
MathLinkException
void put(int i)
throws MathLinkException
i - the int to send
MathLinkException
long getLongInteger()
throws MathLinkException
MathLinkException
void put(long i)
throws MathLinkException
i - the value to send
MathLinkException
double getDouble()
throws MathLinkException
MathLinkException
void put(double d)
throws MathLinkException
d - the double to send
MathLinkException
boolean[] getBooleanArray1()
throws MathLinkException
The expression being read must be a list or other depth-1 expression of the symbols True and False. The "1" suffix in the method name indicates that the returned array has depth 1.
The expression does not need to have head List. In other words, it could be List[False, True] or Foo[True, True]. The information about the heads is lost; if you need this information you will need to either use getArray(int, int, String[]) or read the expression as an Expr and examine it using the Expr methods.
MathLinkException - if the incoming expression is not a depth-1 array of True and FalsegetArray(int, int)
boolean[][] getBooleanArray2()
throws MathLinkException
The expression being read must be a matrix of the symbols True and False. The "2" suffix in the method name indicates that the returned array has depth 2.
The expression does not need to have head List. It can have any heads, at any depth. In other words, it could be List[List[True, False], List[True, True]] or Foo[Bar[True, False], Bar[True, True]]. The information about the heads is lost; if you need this information you will need to either use getArray(int, int, String[]) or read the expression as an Expr and examine it using the Expr methods.
MathLinkException - if the incoming expression is not a 2-deep array of True and FalsegetArray(int, int)
byte[] getByteArray1()
throws MathLinkException
The expression being read must be a list or deeper array of integers. Values outside the range of a byte are converted via casting. The "1" suffix in the method name indicates that the returned array has depth 1. If the arriving expression has depth greater than 1 (e.g., it is a matrix), it will be flattened to a 1-dimensional array.
The expression does not need to have head List. It can have any heads, at any depth. In other words, it could be List[List[1, 2], List[3, 4]] or Foo[Bar[1, 2], Bar[3, 4]]. The information about the heads is lost; if you need this information you will need to either use getArray(int, int, String[]) or read the expression as an Expr and examine it using the Expr methods.
MathLinkException - if the incoming expression is not an array of integersgetArray(int, int)
byte[][] getByteArray2()
throws MathLinkException
The expression being read must be a matrix or deeper array of integers. Values outside the range of a byte are converted via casting. The "2" suffix in the method name indicates that the returned array has depth 2. If the arriving expression has depth greater than 2, it will be flattened to a 2-dimensional array. If the arriving expression has a depth less than 2 (i.e., it is a flat list), a MathLinkException will be thrown.
The expression does not need to have head List. It can have any heads, at any depth. In other words, it could be List[List[1, 2], List[3, 4]] or Foo[Bar[1, 2], Bar[3, 4]]. The information about the heads is lost; if you need this information you will need to either use getArray(int, int, String[]) or read the expression as an Expr and examine it using the Expr methods.
MathLinkException - if the incoming expression is not an array of integersgetArray(int, int)
char[] getCharArray1()
throws MathLinkException
The expression being read must be a list or deeper array of integers. Values outside the range of a char are converted via casting. The "1" suffix in the method name indicates that the returned array has depth 1. If the arriving expression has depth greater than 1 (e.g., it is a matrix), it will be flattened to a 1-dimensional array.
The expression does not need to have head List. It can have any heads, at any depth. In other words, it could be List[List[1, 2], List[3, 4]] or Foo[Bar[1, 2], Bar[3, 4]]. The information about the heads is lost; if you need this information you will need to either use getArray(int, int, String[]) or read the expression as an Expr and examine it using the Expr methods.
MathLinkException - if the incoming expression is not an array of integersgetArray(int, int)
char[][] getCharArray2()
throws MathLinkException
The expression being read must be a matrix or deeper array of integers. Values outside the range of a char are converted via casting. The "2" suffix in the method name indicates that the returned array has depth 2. If the arriving expression has depth greater than 2, it will be flattened to a 2-dimensional array. If the arriving expression has a depth less than 2 (i.e., it is a flat list), a MathLinkException will be thrown.
The expression does not need to have head List. It can have any heads, at any depth. In other words, it could be List[List[1, 2], List[3, 4]] or Foo[Bar[1, 2], Bar[3, 4]]. The information about the heads is lost; if you need this information you will need to either use getArray(int, int, String[]) or read the expression as an Expr and examine it using the Expr methods.
MathLinkException - if the incoming expression is not an array of integersgetArray(int, int)
short[] getShortArray1()
throws MathLinkException
The expression being read must be a list or deeper array of integers. Values outside the range of a short are converted via casting. The "1" suffix in the method name indicates that the returned array has depth 1. If the arriving expression has depth greater than 1 (e.g., it is a matrix), it will be flattened to a 1-dimensional array.
The expression does not need to have head List. It can have any heads, at any depth. In other words, it could be List[List[1, 2], List[3, 4]] or Foo[Bar[1, 2], Bar[3, 4]]. The information about the heads is lost; if you need this information you will need to either use getArray(int, int, String[]) or read the expression as an Expr and examine it using the Expr methods.
MathLinkException - if the incoming expression is not an array of integersgetArray(int, int)
short[][] getShortArray2()
throws MathLinkException
The expression being read must be a matrix or deeper array of integers. Values outside the range of a short are converted via casting. The "2" suffix in the method name indicates that the returned array has depth 2. If the arriving expression has depth greater than 2, it will be flattened to a 2-dimensional array. If the arriving expression has a depth less than 2 (i.e., it is a flat list), a MathLinkException will be thrown.
The expression does not need to have head List. It can have any heads, at any depth. In other words, it could be List[List[1, 2], List[3, 4]] or Foo[Bar[1, 2], Bar[3, 4]]. The information about the heads is lost; if you need this information you will need to either use getArray(int, int, String[]) or read the expression as an Expr and examine it using the Expr methods.
MathLinkException - if the incoming expression is not an array of integersgetArray(int, int)
int[] getIntArray1()
throws MathLinkException
The expression being read must be a list or deeper array of integers. The "1" suffix in the method name indicates that the returned array has depth 1. If the arriving expression has depth greater than 1 (e.g., it is a matrix), it will be flattened to a 1-dimensional array.
The expression does not need to have head List. It can have any heads, at any depth. In other words, it could be List[List[1, 2], List[3, 4]] or Foo[Bar[1, 2], Bar[3, 4]]. The information about the heads is lost; if you need this information you will need to either use getArray(int, int, String[]) or read the expression as an Expr and examine it using the Expr methods.
MathLinkException - if the incoming expression is not an array of integersgetArray(int, int)
int[][] getIntArray2()
throws MathLinkException
The expression being read must be a matrix or deeper array of integers. The "2" suffix in the method name indicates that the returned array has depth 2. If the arriving expression has depth greater than 2, it will be flattened to a 2-dimensional array. If the arriving expression has a depth less than 2 (i.e., it is a flat list), a MathLinkException will be thrown.
The expression does not need to have head List. It can have any heads, at any depth. In other words, it could be List[List[1, 2], List[3, 4]] or Foo[Bar[1, 2], Bar[3, 4]]. The information about the heads is lost; if you need this information you will need to either use getArray(int, int, String[]) or read the expression as an Expr and examine it using the Expr methods.
MathLinkException - if the incoming expression is not an array of integersgetArray(int, int)