public class LispCall
extends java.lang.Object
Typical usage style:
Connection methods:
connect(String, int, int)
connect(String, int, int, int)
advertise(int, int)
advertise(String, String, int, int)
disconnect()
Components of a LispCall instance:
Modifier and Type | Class and Description |
---|---|
static class |
LispCall.JlinkerState
This enum defines the constants that identify the states of a Jlinker connection.
|
Modifier and Type | Field and Description |
---|---|
static java.lang.Object |
connectError
Additional information about a failed connection attempt.
|
static int |
defaultPollCount
How many times to attempt making a connection.
|
static int |
defaultPollInterval
How often to attempt making a connection.
|
static int |
defaultPortTimeout
How long a client should wait for a port to be available for a call to Lisp.
|
static int |
discardBatchSize
The batch size for discardInLisp() operations.
|
java.lang.Object |
queryError
Additional information about a failed call to query().
|
static int |
readTimeout
Timeout value for a read operations on a socket.
|
static int |
replyTimeout
How long a client call should wait for a reply to begin.
|
static int |
requestTimeout
How long the server will wait for another client request.
|
static int |
RES_BOOLEAN
Result type constant: boolean.
|
static int |
RES_DOUBLE_ARRAY
Result type constant: array of floating point numbers.
|
static int |
RES_ERROR
Result type constant: remote reference to a Lisp error.
|
static int |
RES_INT_ARRAY
Result type constant: array of integer values.
|
static int |
RES_INTEGER
Result type constant: integer.
|
static int |
RES_JAVA_POINTER
Result type constant: Java Object instance.
|
static int |
RES_LISP_POINTER
Result type constant: remote reference to a Lisp object.
|
static int |
RES_LONG
Result type constant: long integer.
|
static int |
RES_MISSING
Result type constant: missing result.
|
static int |
RES_NULL
Result type constant: null.
|
static int |
RES_REAL
Result type constant: floating point number.
|
static int |
RES_STRING
Result type constant: string.
|
static int |
RES_STRING_ARRAY
Result type constant: array of strings.
|
static int |
RES_SYMBOL
Result type constant: remote reference to a Lisp symbol.
|
static int |
RES_UNKNOWN
Result type constant: unknown type.
|
static int |
RES_WRAPPER
Result type constant: wrapped result.
|
static int |
RES_WRONG_STATE
Result type constant: incorrect LispCall state..
|
static int |
STATE_CLOSED
Internal state constant: arguments and values discarded.
|
static int |
STATE_COLLECTING
Internal state constant: collecting arguments to call.
|
static int |
STATE_DONE
Internal state constant: call completed, value(s) available.
|
static int |
STATE_NEW
Internal state constant: new, uninitialized instance.
|
static int |
STATE_READY
Internal state constant: ready to make call.
|
static int |
STATE_WAITDONE
Internal state constant: call completed, but value(s) not retrieved.
|
static int |
STATE_WAITING
Internal state constant: waiting for call to complete.
|
static int |
STYLE_ASYNC_BR
Call style constant: asynchronous call.
|
static int |
STYLE_ASYNC_GO
Call style constant: asynchronous call.
|
static int |
STYLE_COPY
Call style constant: default call returning Java data values if possible.
|
static int |
STYLE_IGNORE
Call style constant: call with ignored value(s).
|
static int |
STYLE_ONEWAY
Call style constant: one-way call.
|
static int |
STYLE_REF
Call style constant: call returning remote reference(s) if possible.
|
static int |
verifiedConnectTimeout
How long to wait for a verified connection response.
|
Constructor and Description |
---|
LispCall()
Create a LispCall instance with default style and default retention strategy.
|
LispCall(boolean r)
Create a LispCall instance with default style and the specified retention strategy.
|
LispCall(int s)
Create a LispCall instance with the specified call style.
|
LispCall(java.lang.String op)
Create a LispCall instance to call the specified Lisp function.
|
Modifier and Type | Method and Description |
---|---|
int |
addArg(boolean x)
Add a boolean argument to the call.
|
int |
addArg(byte x)
Add a byte argument to the call.
|
int |
addArg(byte[] x)
Add a byte array argument to the call.
|
int |
addArg(double x)
Add a double float argument to the call.
|
int |
addArg(double[] x)
Add a double float array argument to the call.
|
int |
addArg(float x)
Add an argument to the call.
|
int |
addArg(float[] x)
Add a float array argument to the call.
|
int |
addArg(int x)
Add an integer argument to the call.
|
int |
addArg(int[] x)
Add an argument to the call.
|
int |
addArg(long x)
Add a long integer argument to the call.
|
int |
addArg(java.lang.Object x)
Add an Java Object argument to the call.
|
int |
addArg(short x)
Add a short integer argument to the call.
|
int |
addArg(short[] x)
Add an argument to the call.
|
int |
addArg(java.lang.String x)
Add an argument to the call.
|
int |
addArg(java.lang.String[] x)
Add an argument to the call.
|
int |
addSymbol(java.lang.String x)
Add a Lisp symbol argument to the call.
|
int |
addSymbol(java.lang.String x,
java.lang.String pk)
Add a Lisp symbol argument to the call.
|
int |
addSymbol(java.lang.String x,
java.lang.String pk,
int action)
Add a Lisp symbol or a value referenced by a Lisp symbol as an argument to the call.
|
static boolean |
advertise(int port,
int timeoutSeconds)
Allow a Lisp server to connect to the Java application.
|
static boolean |
advertise(java.lang.String l2j,
java.lang.String host,
int port,
int timeoutSeconds)
Advertise the Java host and port in a file.
|
boolean |
booleanValue()
Get the first or only boolean value returned from Lisp.
|
boolean |
booleanValue(int i)
Get the i-th value returned from Lisp
when it is expected to be of type boolean.
|
int |
call()
Call a function in Lisp.
|
int |
callAsyncBr()
Call a function in Lisp after setting the style to STYLE_ASYNC.
|
int |
callAsyncGo()
Call a function in Lisp after setting the style to STYLE_ASYNC_GO.
|
int |
callCopy()
Call a function in Lisp after setting the style to STYLE_COPY.
|
int |
callIgnore()
Call a function in Lisp.
|
int |
callOneWay()
Call a function in Lisp.
|
int |
callRef()
Call a function in Lisp.
|
void |
close()
Discard all arguments and results.
|
static boolean |
connect(java.lang.String com,
int pollInterval,
int pollCount)
Connect to a Lisp server when the host and port are published in a file.
|
static boolean |
connect(java.lang.String host,
int port,
int pollInterval,
int pollCount)
Connect to a Lisp server at a known host and port.
|
static long |
discardInLisp(java.lang.Object... x)
Discard remote references to Lisp objects.
|
static void |
disconnect()
End the connection to a Lisp server.
|
static int |
dispatchEvent(java.lang.String ev,
java.lang.Object target,
java.lang.String[] s,
int[] l)
Dispatch an event to the Lisp handler.
|
static int |
dispatchEvent(java.lang.String ev,
java.lang.Object target,
java.lang.String[] s,
int[] l,
int timeout)
Dispatch an event to the Lisp handler.
|
double[] |
doubleArrayValue()
Get the first or only double[] value returned from Lisp.
|
double[] |
doubleArrayValue(int i)
Get the i-th value returned from Lisp
when it is expected to be of type double[].
|
double |
doubleValue()
Get the first or only double float value returned from Lisp.
|
double |
doubleValue(int i)
Get the i-th value returned from Lisp
when it is expected to be of type float or double.
|
static int[] |
getDefaultConnectionPool()
Return an array that describes the default connection pool parameters.
|
java.lang.Object |
getOp()
Get the Lisp operation.
|
boolean |
getRetain()
Get the retention strategy.
|
int |
getState()
Get the state of the LispCall instance.
|
int |
getStyle()
Get the call style of the LispCall instance.
|
JLWrapper.TypeCode |
getTypeCode()
Query the type of the first or only value returned from Lisp.
|
JLWrapper.TypeCode |
getTypeCode(int i)
Query the type of the i-th value returned from Lisp.
|
java.lang.Object |
getValue()
Get the first or only raw value returned by a call to Lisp.
|
java.lang.Object |
getValue(int i)
Get the i-th raw value returned by a call to Lisp.
|
static java.lang.Object |
identity(java.lang.Object arg)
Returns the argument (or an equivalent object).
|
int[] |
intArrayValue()
Get the first or only int[] value returned from Lisp.
|
int[] |
intArrayValue(int i)
Get the i-th value returned from Lisp
when it is expected to be of type int[].
|
int |
intValue()
Get the first or only value returned from Lisp
when it is expected to be of type int.
|
int |
intValue(int i)
Get the i-th value returned from Lisp
when it is expected to be of type int.
|
static boolean |
isJlinkerReady()
Query the state of the Jlinker connection.
|
static boolean |
isJlinkerState(LispCall.JlinkerState... targets)
Query the state of the Jlinker connection.
|
static boolean |
isJlinkerState(long timeout,
LispCall.JlinkerState... targets)
Query the state of the Jlinker connection.
|
java.lang.String |
lispType()
Identify the Lisp type of the first or only returned value.
|
java.lang.String |
lispType(int i)
Identify the Lisp type of a returned value.
|
long |
longValue()
Get the first or only value returned from Lisp.
|
long |
longValue(int i)
Get the i-th value returned from Lisp
when it is expected to be of type long.
|
int |
mayCall()
Query if it is allowed to call Lisp in this thread.
|
static java.lang.String |
nameOfType(int type)
Translate an integer type code to a descriptive string.
|
java.lang.Object |
objectValue()
Get the first or only Object value returned from Lisp.
|
java.lang.Object |
objectValue(int i)
Get the i-th value returned from Lisp
when it is expected to be of type Object.
|
int |
query()
Query the state of a call to Lisp.
|
int |
query(boolean doquery,
boolean dofetch)
Query the state of a call to Lisp.
|
java.lang.String |
queryAsyncName()
Query the name of the Lisp process where the call is run.
|
static java.lang.Object |
queryConnectionPool()
Query the state of the connection pool.
|
boolean |
reset()
Discard the results but keep the arguments.
|
void |
setArg(int i,
boolean arg)
Set or modify a specified argument position with a boolean value.
|
void |
setArg(int i,
double arg)
Set or modify a specified argument position with a double value.
|
void |
setArg(int i,
double[] arg)
Set or modify a specified argument position with a copy of
an array of double values.
|
void |
setArg(int i,
int arg)
Set or modify a specified argument position with an int value.
|
void |
setArg(int i,
int[] arg)
Set or modify a specified argument position with a copy of an array of int values.
|
void |
setArg(int i,
long arg)
Set or modify a specified argument position with a long value.
|
void |
setArg(int i,
java.lang.Object arg)
Set or modify a specified argument position with a reference to a Java Object
or a pre-wrapped Java or Lisp object.
|
void |
setArg(int i,
java.lang.String arg)
Set or modify a specified argument position with a String value.
|
void |
setArg(int i,
java.lang.String[] arg)
Set or modify a specified argument position with a copy
of an array of String values.
|
static void |
setDefaultConnectionPool(int lispMin,
int lispMax,
int lispIdle,
int javaMin,
int javaMax,
int javaIdle)
Modify the default connection pool parameters.
|
void |
setOp(java.lang.Object op)
Specify the Lisp function that will be called.
|
void |
setOp(java.lang.String op)
Specify the Lisp function that will be called.
|
void |
setRetain(boolean r)
Set the retention strategy.
|
void |
setStyle(int s)
Specify the call style.
|
void |
setSymbol(int i,
java.lang.String name)
Set or modify a specified argument position with a reference to a Lisp symbol.
|
void |
setSymbol(int i,
java.lang.String name,
java.lang.String pkg)
Set or modify a specified argument position with a reference to a Lisp symbol.
|
void |
setSymbol(int i,
java.lang.String name,
java.lang.String pkg,
int mode)
Set or modify a specified argument position with a reference to a Lisp symbol.
|
java.lang.String[] |
stringArrayValue()
Get the first or only String[] value returned from Lisp.
|
java.lang.String[] |
stringArrayValue(int i)
Get the i-th value returned from Lisp
when it is expected to be of type String[].
|
java.lang.String |
stringValue()
Get the first or only String value returned from Lisp.
|
java.lang.String |
stringValue(int i)
Get the i-th value returned from Lisp.
|
java.lang.String |
symbolName()
Get the name of the Lisp symbol returned as the first or only
value of a call.
|
java.lang.String |
symbolName(int i)
Get the name of the Lisp symbol returned as the i-th
value of a call.
|
java.lang.String |
symbolPackage()
Get the name of the package of a Lisp symbol returned as the first or only
value of a call.
|
java.lang.String |
symbolPackage(int i)
Get the name of the package of a Lisp symbol returned as the i-th
value of a call.
|
int |
typeOf()
Deprecated.
use
getTypeCode() |
int |
typeOf(int i)
Deprecated.
use
getTypeCode(int) |
public static final int STYLE_ONEWAY
This style constant identifies a one-way Lisp call. A STYLE_ONEWAY call starts a call in Lisp and returns to the Java caller immediately without waiting for a result from Lisp.
public static final int STYLE_IGNORE
This style constant identifies a synchronous call to Lisp where the value(s) are ignored. A STYLE_IGNORE call to Lisp waits for the result to be computed, but the computed value or values are not returned to Java. When the values are ignored, the time taken to encode, transmit, and decode the values is saved.
public static final int STYLE_REF
This style constant identifies a synchronous call to Lisp; the Lisp values are returned as remote references if at all possible.
public static final int STYLE_COPY
This style constant identifies a synchronous call to Lisp; the Lisp values are returned as Java values if at all possible.
public static final int STYLE_ASYNC_BR
This style constant identifies an asynchronous Lisp call. Control returns to Java before the Lisp call is completed. The Lisp call is initiated in a separate Lisp thread and the Java program can test when the operation is completed. The query() method is used to test the progress of the operation.
An important side-effect of this style of call is that Lisp errors are handled in the Lisp thread, and are not just returned to Java.
public static final int STYLE_ASYNC_GO
This style constant identifies an asynchronous Lisp call. Control returns to Java before the Lisp call is completed. The Lisp call is initiated in a separate Lisp thread and the Java program can test when the operation is completed. The query() method is used to test the progress of the operation.
Lisp errors are caught and returned to Java.
public static final int STATE_NEW
This constant identifies the state of a newly created LispCall instance. The Lisp operation must be specified before arguments may be added or a call can be made.
public static final int STATE_COLLECTING
This constant identifies the state of a LispCall instance when it is collecting arguments to be passed to Lisp.
public static final int STATE_READY
This constant identifies the state of a LispCall instance when it is ready to make a call to Lisp.
public static final int STATE_DONE
This constant identifies the state of a LispCall instance when the call is complete and the value or values returned from Lisp are available.
public static final int STATE_WAITING
This constant identifies the state of a LispCall instance when a call in the STYLE_ASYNC style is waiting for results.
public static final int STATE_WAITDONE
This constant identifies the state of a LispCall instance when a call in the STYLE_ASYNC style is done but the results have not been retrieved from Lisp.
public static final int STATE_CLOSED
This constant identifies the state of a LispCall instance when arguments and values have been discarded.
public static final int RES_NULL
This constant represents a result data type when the result is null.
public static final int RES_BOOLEAN
This constant represents a result data type when the result is a boolean value.
public static final int RES_INTEGER
This constant represents a result data type when the result is an integer value.
public static final int RES_LONG
This constant represents a result data type when the result is a long integer value.
public static final int RES_REAL
This constant represents a result data type when the result is floating point number.
public static final int RES_STRING
This constant represents a result data type when the result is a string.
public static final int RES_SYMBOL
This constant represents a result data type when the result is a remote reference to a Lisp symbol.
public static final int RES_LISP_POINTER
This constant represents a result data type when the result is a remote reference to a Lisp object.
public static final int RES_ERROR
This constant represents a result data type when the result is a remote reference to a Lisp error.
public static final int RES_INT_ARRAY
This constant represents a result data type when the result is an array of integer values.
public static final int RES_DOUBLE_ARRAY
This constant represents a result data type when the result is an array of floating point numbers.
public static final int RES_STRING_ARRAY
This constant represents a result data type when the result is an array of strings.
public static final int RES_JAVA_POINTER
This constant represents a result data type when the result is a pointer to a Java Object instance.
public static final int RES_WRONG_STATE
This constant represents a result data type when an attempt is made to extract a result from a LispCall instance in a state where results are not available.
public static final int RES_MISSING
This constant represents a result data type when an attempt is made to extract a result that is not present in a LispCall instance.
public static final int RES_WRAPPER
This constant represents a result data type when an attempt is made to extract a result that is still wrapped in a LispCall instance.
public static final int RES_UNKNOWN
This constant represents a result data type when the result is of unknown type. This value should only occur if a system error is encountered.
public java.lang.Object queryError
public static int defaultPollInterval
The initial value is 1000.
A value of -1 specifies that only one attempt will be made.
public static int defaultPollCount
The value of this field is the number of connection attempts when the Lisp application is advertising and pollInterval is positive.
The initial value is 300.
public static java.lang.Object connectError
After a failed call to connect() or advertise(), this field holds an Object instance that describes the failure, usually an instance of IllegalArgumentException.
public static int readTimeout
This timeout prevents an indefinite hangup in the event that a network connection becomes inoperative. If the network between client and server is very slow this value may need to be larger. If a quicker response to a broken network is desired, this value can be smaller. The initial setting is 30000 milliseconds.
In the event of a timeout as a result of the readTimeout or replyTimeout, the sequence of events on the socket has been disrupted and the socket can no longer be used. The only possible recovery action is to close the connection that caused the timeout and start a new connection.
public static int defaultPortTimeout
The initial value is -1 to denote a value a few seconds longer than replyTimeout (if a port is busy, it should be free after a normal reply delay).
public static int replyTimeout
If the application can expect a call to last longer, then this value should be increased. The initial setting is 300000 milliseconds. A small value allows a Java application to detect a network problem or Lisp problem sooner but limits the amount of work a Lisp call can do. If a short timeout is used, the STYLE_ASYNC calls can be used to allow Lisp calls to run as long a necessary.
In the event of a timeout as a result of the readTimeout or replyTimeout, the sequence of events on the socket has been disrupted and the socket can no longer be used. The only possible recovery action is to close the connection that caused the timeout and start a new connection.
public static int requestTimeout
The initial setting is 0 for an indefinite wait. If a positive value is specified, the connection will be terminated if a remote call does not arrive before the timeout.
public static int verifiedConnectTimeout
In a verified connection situation, there is an immediate exchange of information
once a connection is established. A timeout can mean that the Lisp program supports an
older version of the connection protocol, a version that does not support verified
connections. If the Lisp program is known to be up to date and legitimate connections
are rejected this timeout value may need
to be increased.
This setting can be modified when a Java VM is started by setting the system property
"com.franz.jlinker.verifytimeout".
public static int discardBatchSize
When discardInLisp() is called the data is collected until the batch size is reached.
To force immediate flushing of the data, set this field to zero or call discardInLisp(0).
public LispCall()
The default constructor creates and initializes a LispCall instance with the default style of STYLE_COPY and the default retention strategy.
The programmer must supply a Lisp function and any required arguments before making the call. Argument wrappers and results are retained until released with a call to close().
public LispCall(boolean r)
Create and initialize a LispCall instance with the default style of STYLE_COPY and a retention strategy specified by the parameter.
The programmer must supply a Lisp function and any required arguments before making the call.
r
- A boolean value that specifies the retention strategy.
A true value specifies that arguments and results are retained
until released with a call to close().
A false values specifies that argument wrappers are discarded immediately
after the call to Lisp is made.public LispCall(int s)
Create and initialize a LispCall instance with the default retention strategy and a specified call style.
The programmer must supply a Lisp function and any required arguments before making the call.
s
- An integer that specifies the call style.
It must be one of the constants
STYLE_ONEWAY, STYLE_IGNORE, STYLE_REF, STYLE_COPY, STYLE_ASYNC.public LispCall(java.lang.String op)
Create and initialize a LispCall instance with the default retention strategy and default call style to call the specified Lisp function.
op
- A string that specifies a Lisp function name.public static boolean isJlinkerReady()
The call to connect() or advertise() can take some time in one thread. If another thread attempt to use the connection before it is ready, an IllegalStateException is thrown. To avoid the exception, a thread should query the state and make a call only in the READY state.
Introduced in version 7001002.
public static boolean isJlinkerState(LispCall.JlinkerState... targets)
In a single-threaded application, the state of the Jlinker connection is only seen as IDLE, READY, or DISCONNECTED. The other intermediate states can only be seen in parallel threads while a connection is completed or severed.
In multi-threaded applications, a thread should make calls to Lisp only
when the connection is ready. If the connection is not ready, call() will throw
IllegalStateException
.
Introduced in version 7001002.
targets
- One or more of the state tokens.public static boolean isJlinkerState(long timeout, LispCall.JlinkerState... targets)
Introduced in version 7001002.
timeout
- The number of milliseconds to wait until desired state is reached.targets
- One or more of the state tokens.public static int[] getDefaultConnectionPool()
{ lispMin, lispMax, lispIdle, javaMin, javaMax, javaIdle }
public static void setDefaultConnectionPool(int lispMin, int lispMax, int lispIdle, int javaMin, int javaMax, int javaIdle)
Introduced in version 7001000.
lispMin
- lispMax
- lispIdle
- javaMin
- javaMax
- javaIdle
- public static java.lang.Object queryConnectionPool()
{ lispMin lispMax lispIdle javaMin javaMax javaIdle }If the pool is running, the value is an array of 8 integers:
{ lispMin lispCur lispMax lispIdle javaMin javaCur javaMax javaIdle }
Introduced in version 7001000.
public int getState()
public java.lang.Object getOp()
public int getStyle()
public void setOp(java.lang.String op)
op
- A string that specifies a Lisp function name.public void setOp(java.lang.Object op)
This method is useful when the Java application is holding a pre-wrapped pointer to the Lisp function, or a function pointer that was returned by a previous call to Lisp.
op
- A wrapper instance that specifies a Lisp function.public void setStyle(int s)
s
- An integer that specifies the call style.
It must be one of the constants
STYLE_ONEWAY, STYLE_IGNORE, STYLE_REF, STYLE_COPY, STYLE_ASYNC.java.lang.IllegalArgumentException
- if the argument is not suitable.public boolean getRetain()
public void setRetain(boolean r)
r
- A boolean value that specifies the new retention strategy.public int addArg(byte x)
This method wraps and adds a byte argument to the list of arguments that will be passed to the Lisp function when it is called.
x
- A byte
value that will be passed to Lisp.public int addArg(short x)
This method wraps and adds a short argument to the list of arguments that will be passed to the Lisp function when it is called.
x
- A short
value that will be passed to Lisp.public int addArg(int x)
This method wraps and adds an int argument to the list of arguments that will be passed to the Lisp function when it is called.
x
- An int
value that will be passed to Lisp.public int addArg(long x)
x
- A long
value that will be passed to Lisp.public int addArg(boolean x)
This method wraps and adds a boolean argument to the list of arguments that will be passed to the Lisp function when it is called.
x
- A boolean
value that will be passed to Lisp in a wrapper.public int addArg(byte[] x)
This method wraps and adds a byte array argument to the list of arguments that will be passed to the Lisp function when it is called.
x
- A byte
vector that will be passed to Lisp.public int addArg(short[] x)
x
- A short
vector that will be passed to Lisp.public int addArg(int[] x)
x
- An int
vector that will be passed to Lisp in a wrapper.public int addArg(java.lang.String x)
x
- A String
value that will be passed to Lisp in a wrapper.public int addArg(java.lang.String[] x)
x
- A String
vector that will be passed to Lisp in a wrapper.public int addArg(float x)
x
- A float
value that will be passed to Lisp.public int addArg(double x)
This method wraps and adds a double argument to the list of arguments that will be passed to the Lisp function when it is called.
x
- A double
value that will be passed to Lisp.public int addArg(float[] x)
This method wraps and adds a float array argument to the list of arguments that will be passed to the Lisp function when it is called.
x
- A float
vector that will be passed to Lisp.public int addArg(double[] x)
This method wraps and adds a double array argument to the list of arguments that will be passed to the Lisp function when it is called.
x
- A double
vector that will be passed to Lisp.public int addArg(java.lang.Object x)
This method wraps and adds a pointer argument to the list of arguments that will be passed to the Lisp function when it is called.
x
- An Object
value that will be passed to Lisp.public int addSymbol(java.lang.String x)
This method wraps and adds a Lisp symbol reference to the list of arguments that will be passed to the Lisp function when it is called. The symbol is interned with read-from-string.
x
- A String
value that will be passed to read-from-string
to create the symbol. The string may contain a package prefix as well
as a symbol name.
If the entire string is not consumed to create the
symbol a Lisp error is signaled. Special characters must be escaped
with the Lisp escape character.public int addSymbol(java.lang.String x, java.lang.String pk)
This method wraps and adds a Lisp symbol reference to the list of arguments that will be passed to the Lisp function when it is called. The symbol is interned with read-from-string.
x
- A String
value that will be passed to read-from-string
to create the symbol. The string may contain a package prefix as well
as a symbol name.pk
- A String
value that specifies the Lisp package context
for read-from-string.
public int addSymbol(java.lang.String x, java.lang.String pk, int action)
This method wraps and adds a Lisp symbol reference to the list of arguments that will be passed to the Lisp function when it is called. The symbol is interned with read-from-string.
x
- A String
value that will be passed to read-from-string
to create the symbol. The string may contain a package prefix as well
as a symbol name.pk
- A String
value that specifies the Lisp package context
for read-from-string.action
- public int call() throws JLinkerLispThrow, JLinkerInvokeException, JLinkerLispException, JLinkerPortException
JLinkerLispException
- if an error is detected
during the call.JLinkerInvokeException
- if an error interrupts the normal sequence of events.
After this exception, the connection must be re-established before it can be
used again.JLinkerLispThrow
- if the Lisp function call was terminated with a throw.JLinkerPortException
- if a port to Lisp was not available within the default port timeout interval.java.lang.IllegalStateException
- if a previous call is not complete.public int callOneWay() throws JLinkerLispThrow, JLinkerInvokeException, JLinkerLispException, JLinkerPortException
JLinkerLispException
JLinkerInvokeException
JLinkerLispThrow
JLinkerPortException
public int callIgnore() throws JLinkerLispThrow, JLinkerInvokeException, JLinkerLispException, JLinkerPortException
JLinkerLispException
JLinkerInvokeException
JLinkerLispThrow
JLinkerPortException
public int callRef() throws JLinkerLispThrow, JLinkerInvokeException, JLinkerLispException, JLinkerPortException
JLinkerLispException
- if there
was some error in the call.JLinkerInvokeException
JLinkerLispThrow
JLinkerPortException
public int callCopy() throws JLinkerLispThrow, JLinkerInvokeException, JLinkerLispException, JLinkerPortException
JLinkerLispException
- if there
was some error in the call.JLinkerInvokeException
JLinkerLispThrow
JLinkerPortException
public int callAsyncBr() throws JLinkerLispThrow, JLinkerInvokeException, JLinkerLispException, JLinkerPortException
JLinkerLispException
- if there
was some error in the call.JLinkerInvokeException
JLinkerLispThrow
JLinkerPortException
public int callAsyncGo() throws JLinkerLispThrow, JLinkerInvokeException, JLinkerLispException, JLinkerPortException
JLinkerLispException
- if there
was some error in the call.JLinkerInvokeException
JLinkerLispThrow
JLinkerPortException
public java.lang.Object getValue()
public java.lang.Object getValue(int i)
i
- The index of the desired value.WrongStateException
- if
public static java.lang.String nameOfType(int type)
The returned value is one of the strings:
Integer type code | String name |
---|---|
RES_NULL | "Null" |
RES_BOOLEAN | "Boolean" |
RES_INTEGER | "Integer" |
RES_LONG | "Long" |
RES_REAL | "Real" |
RES_STRING | "String" |
RES_ERROR | "Error" |
RES_SYMBOL | "Symbol" |
RES_LISP_POINTER | "Lisp-Pointer" |
RES_INT_ARRAY | "Int-Array" |
RES_DOUBLE_ARRAY | "Double-Array" |
RES_STRING_ARRAY | "String-Array" |
RES_UNKNOWN | "Unknown" |
RES_JAVA_POINTER | "Java-Pointer" |
RES_WRONG_STATE | "Wrong-State" |
RES_MISSING | "Missing" |
"Unknown-nn" where nn is the integer type code |
public static java.lang.Object identity(java.lang.Object arg)
One use for this method is to dereference Java values that were passed to Lisp by reference but can be automatically copied by the interface.
For example, (jnew-array "java.lang.String" 17)
returns a
remote reference to a Java array. To obtain a copy of the contents of
the array, the Lisp code can call
(jstatic "identity" "com.franz.jlinker.LispCall" ref [:copy])The
:copy
argument is optional since the default is to
copy string arrays.arg
- public int typeOf()
getTypeCode()
public int typeOf(int i)
getTypeCode(int)
i
- The index of the value queried.public JLWrapper.TypeCode getTypeCode()
public JLWrapper.TypeCode getTypeCode(int i)
i
- The index of the value queried.public int intValue()
java.lang.UnsupportedOperationException
- when the value returned from Lisp
is not convertible to int.ArrayOutOfBoundsException
- when the i-th value is not there.public int intValue(int i)
i
- The index of the desired value.java.lang.UnsupportedOperationException
- when the i-th value returned from Lisp
is not convertible to int.ArrayOutOfBoundsException
- when the i-th value is not there.public long longValue()
public long longValue(int i)
i
- The index of the desired value.java.lang.UnsupportedOperationException
- when the i-th value returned from Lisp
is not convertible to long.ArrayOutOfBoundsException
- when the i-th value is not there.public double doubleValue()
public double doubleValue(int i)
i
- The index of the desired value.java.lang.UnsupportedOperationException
- when the i-th value returned from Lisp
is not convertible to double.ArrayOutOfBoundsException
- when the i-th value is not there.public boolean booleanValue()
public boolean booleanValue(int i)
i
- The index of the desired value.java.lang.UnsupportedOperationException
- when the i-th value returned from Lisp
is not boolean.ArrayOutOfBoundsException
- when the i-th value is not there.public java.lang.String stringValue()
public java.lang.String stringValue(int i)
i
- The index of the desired value.java.lang.UnsupportedOperationException
- when the i-th value returned from Lisp
is not String.ArrayOutOfBoundsException
- when the i-th value is not there.public int[] intArrayValue()
public int[] intArrayValue(int i)
i
- The index of the desired value.java.lang.UnsupportedOperationException
- when the i-th value returned from Lisp
is not int[].ArrayOutOfBoundsException
- when the i-th value is not there.public java.lang.String[] stringArrayValue()
public java.lang.String[] stringArrayValue(int i)
i
- The index of the desired value.java.lang.UnsupportedOperationException
- when the i-th value returned from Lisp
is not String[].ArrayOutOfBoundsException
- when the i-th value is not there.public double[] doubleArrayValue()
public double[] doubleArrayValue(int i)
i
- The index of the desired value.java.lang.UnsupportedOperationException
- when the i-th value returned from Lisp
is not double[].ArrayOutOfBoundsException
- when the i-th value is not there.public java.lang.Object objectValue()
public java.lang.Object objectValue(int i)
i
- The index of the desired value.java.lang.UnsupportedOperationException
- when the i-th value returned from Lisp
is not Object.ArrayOutOfBoundsException
- when the i-th value is not there.public java.lang.String symbolName()
java.lang.UnsupportedOperationException
- when the returned value is not
a Lisp symbol.public java.lang.String symbolName(int i)
java.lang.UnsupportedOperationException
- when the returned value is not
a Lisp symbol.public java.lang.String symbolPackage()
java.lang.UnsupportedOperationException
- when the returned value is not
a Lisp symbol.public java.lang.String symbolPackage(int i)
java.lang.UnsupportedOperationException
- when the returned value is not
a Lisp symbol.public java.lang.String lispType()
public java.lang.String lispType(int i)
If the returned value has been converted to a Java data value or Object, the string is one of the strings returned by nameOfType().
If the returned value is a remote reference to a Lisp object, then the string is the Lisp format ~A representation of the Lisp type.
public int query()
The following results will be returned if the call was a synchronous call, or if an asynchronous call has completed and the results have been fetched to Java:
The remaining values will only be seen if the style is set to STYLE_ASYNC and the call is still in progress. In these cases, additional information can be obtained by calling query(true,true).
public int query(boolean doquery, boolean dofetch) throws JLinkerLispThrow, JLinkerInvokeException, JLinkerLispException
If the call was with style STYLE_ASYNC, then query the progress of the call in Lisp and fetch the results. If a STYLE_ASYNC call has finally completed, fetch the Lisp values.
doquery
- When this argument is true, call Lisp to fetch a more detailed description
of the state of the STYLE_ASYNC call. Once a call instance is
identified as completed, this argument does not trigger a call to Lisp.dofetch
- When this argument is true, and an STYLE_ASYNC call is complete
in Lisp, fetch the values of the call. Once the results are fetched,
this argument does not trigger a call to Lisp.The following results will be returned if the call was a synchronous call, or if the asynchronous call has completed and the results have been fetched to Java:
If the Lisp call was terminated by an error in Lisp, the result will be 3 and the 3 results in Java are the integer -98, a string containing a description of the Lisp error, and a remote reference to the Lisp error object.
The following values will be returned by query(true, false) if the style was set to STYLE_ASYNC and the call is still in progress. In these cases, additional information can be obtained by calling query(true,true).
To monitor the completion of an asynchronous call:
Call query(true, false) repeatedly if the result is non-negative, the call is completed call query(true, true) to fetch the results if the result is -98, the call was terminated call query(true, true) to fetch the error information if the result is -99, the call was terminated there is no additional information to fetch otherwise, the call is still in progress
JLinkerLispException
- If an error occurs when fetching the
the state or results of a STYLE_ASYNC call.JLinkerInvokeException
JLinkerLispThrow
public java.lang.String queryAsyncName() throws JLinkerLispThrow, JLinkerInvokeException, JLinkerLispException
This value may be of interest in an application that may need to terminate a LispCall in
STYLE_ASYNC. The name can be used to interrupt or terminate the Lisp thread by using the Lisp
functions process-name-to-process
, process-interrupt
, or process-kill
.
JLinkerLispException
JLinkerInvokeException
JLinkerLispThrow
public void close()
The style, retention strategy, and Lisp operator are retained if previously set. A call to reset() is needed before new arguments may be added.
Note that if a STYLE_ASYNC operation is in progress in Lisp, it continues but any state or result will no longer be available in Java.
public boolean reset()
Discard results but keep arguments so that the LispCall instance may be re-used for another call. The style, retention strategy, and Lisp operator are retained if previously set.
When the returned value is false, the LispCall instance is in the STATE_NEW or STATE_COLLECTING state and is not ready for another call.
public void setArg(int i, boolean arg)
public void setArg(int i, int arg)
public void setArg(int i, long arg)
public void setArg(int i, double arg)
public void setArg(int i, java.lang.String arg)
public void setArg(int i, java.lang.Object arg)
public void setArg(int i, int[] arg)
public void setArg(int i, double[] arg)
public void setArg(int i, java.lang.String[] arg)
public void setSymbol(int i, java.lang.String name)
The symbol is interned with read-from-string.
If the entire string is not consumed to create the symbol a Lisp error is signaled. Special characters must be escaped with the Lisp escape character
i
- The index of the modified argument.name
- A String
value that will be passed to read-from-string
to create the symbol. The string may contain a package prefix as well
as a symbol name.public void setSymbol(int i, java.lang.String name, java.lang.String pkg)
The symbol is interned with read-from-string.
If the pkg argument is the empty string, the current package is used. If the pkg argument is the string ":", the keyword package is used. Otherwise, the string specifies a package name. The package name is interned with read-from-string to avoid case-mode issues.
If the entire string is not consumed to create the symbol a Lisp error is signaled. Special characters must be escaped with the Lisp escape character.
i
- The index of the modified argument.name
- A String
value that will be passed to read-from-string
to create the symbol. The string may contain a package prefix as well
as a symbol name.pkg
- A String
value that specifies the Lisp package context
for read-from-string.public void setSymbol(int i, java.lang.String name, java.lang.String pkg, int mode)
The symbol is interned with read-from-string.
i
- The index of the modified argument.name
- A String
value that will be passed to read-from-string
to create the symbol. The string may contain a package prefix as well
as a symbol name.pkg
- A String
value that specifies the Lisp package context
for read-from-string.action
- public int mayCall()
Some Lisp implementations allow callback only in the thread in which the Lisp application called Java in the first place.
public static int dispatchEvent(java.lang.String ev, java.lang.Object target, java.lang.String[] s, int[] l, int timeout)
ev
- is a String that names the event. This is the name that
was used in the call to register-handler on the
Lisp side.target
- is the Object instance associated with the
event when it was registereds
- is an array of String data associated with the event.l
- is an array of int data associated with the event.timeout
- The number of milliseconds to wait for an available port.
If zero, make the call only if a port is available immediately.
If negative, wait indefinitely.public static int dispatchEvent(java.lang.String ev, java.lang.Object target, java.lang.String[] s, int[] l)
ev
- is a String that names the event. This is the name that
was used in the call to register-handler on the
Lisp side.target
- is the Object instance associated with the
event when it was registereds
- is an array of String data associated with the event.l
- is an array of int data associated with the event.public static boolean connect(java.lang.String host, int port, int pollInterval, int pollCount)
host
- The name of the host, "" denotes the loopback host.port
- The port number.pollInterval
- A polling interval in milliseconds. If the value is negative, use the value of defaultPollInterval.pollCount
- The number of times to try. If the value is negative, use the value of defaultPollCount.public static boolean connect(java.lang.String com, int pollInterval, int pollCount)
com
- The pathname to the host and port file.pollInterval
- A polling interval in milliseconds. If the value is negative, use the value of defaultPollInterval.pollCount
- The number of times to try. If the value is negative, use the value of defaultPollCount.public static boolean advertise(int port, int timeoutSeconds)
port
- The port number where Java will listen.timeoutSeconds
- Listen for this many seconds.If the connection attempt failed, return false. An Object instance describing the failure may be available in the field connectError.
public static boolean advertise(java.lang.String l2j, java.lang.String host, int port, int timeoutSeconds)
l2j
- The pathname to a file.host
- The host name where Lisp should connect.port
- The port number where Lisp should connect. If zero, a system assigned port will be used.timeoutSeconds
- Listen for this many seconds.public static void disconnect()
public static long discardInLisp(java.lang.Object... x)
When a remote reference to a Lisp object is abandonned in Java, the finalization for the wrapper instance makes a note of it. When enough dead references are collected (as specified by discardBatchSize), Lisp is notified.
If this method is called with a single integer argument, the argument is treated as a temporary batch size and Lisp is notified immediately if this size is exceeded at the moment. Thus calling discardInLisp(0) clears the current list of dead references.
x
- A wrapper instance. If the wrapper is not a Lisp reference, it is ignored.