public abstract class DSession
extends java.lang.Object
Modifier | Constructor and Description |
---|---|
protected |
DSession() |
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the session.
|
static DSession |
createSession()
Creates a local DSession.
|
static DSession |
createSession(java.net.URL url)
Creates a remote DSession.
|
abstract java.lang.Object |
evaluate(java.lang.String expr)
Evaluates a Duro D/T expression.
|
abstract <T> T |
evaluate(java.lang.String expr,
java.lang.Class<T> destClass)
Evaluates expr, stores the result in an instance of class
destClass
and returns that instance. |
abstract void |
evaluate(java.lang.String expr,
java.lang.Object dest)
Evaluates the expression
expr and stores the
value in dest . |
abstract void |
execute(java.lang.String code)
Executes Duro D/T code.
|
abstract void |
setVar(java.lang.String name,
java.lang.Object v)
Assigns a value to a variable.
|
public static DSession createSession()
DException
- if a Duro error occurspublic static DSession createSession(java.net.URL url)
DException
public void close()
DException
- If a Duro error occurspublic abstract void execute(java.lang.String code)
User-defined operators implemented in Java can be created by using the OPERATOR statement with the EXTERN keyword.
Creating a user-defined read-only operator implemented by a Java method:
OPERATOR <opname>(<parameter_list>) RETURNS <type>
EXTERN 'Java' '<classname>.<methodname>';
END OPERATOR;
The method must be static. Parameter types and return type map to Java
types as described in evaluate
.
Creating a user-defined update operator implemented by a Java method:
OPERATOR <opname>(<parameter_list>) UPDATES { <update_param_list> }
EXTERN 'Java' '<classname>.<methodname>';
END OPERATOR;
The method must be static. Non-update parameter types map to Java types
as described in evaluate
.
Update parameter types map to Java classes as follows:
boolean
UpdatableBoolean
string
integer
UpdatableInteger
float
UpdatableDouble
binary
ByteArray
tuple { ... }
Tuple
relation { ... }
array
PossrepObject
code
- The code to executeDException
- If the code could not be executed.public abstract java.lang.Object evaluate(java.lang.String expr)
Duro types map to Java classes as follows:
boolean
java.lang.Boolean
string
java.lang.String
integer
java.lang.Integer
float
java.lang.Double
binary
byte[]
tuple { ... }
Tuple
relation { ... }
java.util.Set
array
array integer
is converted to
java.lang.Integer[]
.PossrepObject
expr
- The expression to evaluateDException
- If the expression could not be evaluated.public abstract void evaluate(java.lang.String expr, java.lang.Object dest)
expr
and stores the
value in dest
.
The type of expr
must have possreps and dest
must have a setter for each property.expr
- the expression to evaluatedest
- the destination objectDException
public abstract <T> T evaluate(java.lang.String expr, java.lang.Class<T> destClass)
destClass
and returns that instance.
If destClass
is an interface, a dynamic proxy is created.
Otherwise, the default constructor of destClass
is called.expr
- the expression to evaluatedestClass
- the class or interface the returned object is an instance of.destClass
representing the result value.DException
public abstract void setVar(java.lang.String name, java.lang.Object v)
name
- The name of the variablev
- The valueDException
- If a Duro error occurs.java.lang.IllegalArgumentException
- If v does not match the type of the variable.