public final class SExpressionBuilder
extends java.lang.Object
eval
methods of an
ExpressionClient
for evaluation.
Usage:
SExpressionBuilder builder = new SExpressionBuilder();
builder.addArgument("arg1", "x"); builder.addArgument("arg2", 2); builder.addExpression("print(paste({0},{1},sep=\"=\"))", "arg1", "arg2"); SplusDataRequest request = null; String expr = builder.build(out request); String serverUrl = "http://localhost:8080/SplusServer"; ExpressionClient expressionClient = ClientFactory.getExpressionClient(serverUrl); expressionClient.eval(expr, new SynchronousJobStartup(), request);
Constructor and Description |
---|
SExpressionBuilder() |
Modifier and Type | Method and Description |
---|---|
void |
addArgument(java.lang.String argName,
double... argValue)
Adds a double values as argument with name defined by
argName . |
void |
addArgument(java.lang.String argName,
int... argValue)
Adds an
int values as argument with name defined by argName . |
void |
addArgument(java.lang.String argName,
int argValue)
Adds an
int value as argument with name defined by argName . |
void |
addArgument(java.lang.String argName,
Splus argValue)
Adds an
Splus object as argument with name defined by argName
. |
void |
addArgument(java.lang.String argName,
SplusObject... argSplusObjectValue)
Adds an
SplusObject as argument with name defined by argName
. |
void |
addArgument(java.lang.String argName,
java.lang.String... argStringValue)
Adds a
String value as argument with name defined by argName
. |
void |
addExpression(java.lang.String expression)
Adds an expression string to this.
|
void |
addExpression(java.lang.String expressionTemplate,
java.lang.String... argNames)
Constructs an expression string from the passed in string template and
string array of argument names.
|
java.lang.String |
build(SplusDataRequest request)
Builds the expression and the request object.
|
boolean |
hasArg(java.lang.String argName)
Checks whether the passed in
argName is the name for an
existing argument added to this through one of the
AddArgumant() methods. |
public void addArgument(java.lang.String argName, double... argValue)
argName
.argName
- Name of the argument. Cannot be null or empty. Other than
that, the string is not validated as a valid argument name in
S.argValue
- Value of the argument.public void addArgument(java.lang.String argName, int argValue)
int
value as argument with name defined by argName
.argName
- Name of the argument. Cannot be null or empty. Other than
that, the string is not validated as a valid argument name in
S.argValue
- Value of the argument.public void addArgument(java.lang.String argName, int... argValue)
int
values as argument with name defined by argName
.argName
- Name of the argument. Cannot be null or empty. Other than
that, the string is not validated as a valid argument name in
S.argValue
- Value of the argument.public void addArgument(java.lang.String argName, Splus argValue)
Splus
object as argument with name defined by argName
.argName
- Name of the argument. Cannot be null or empty. Other than
that, the string is not validated as a valid argument name in
S.argValue
- Value of the argument.public void addArgument(java.lang.String argName, SplusObject... argSplusObjectValue)
SplusObject
as argument with name defined by argName
.argName
- Name of the argument. Cannot be null or empty. Other than
that, the string is not validated as a valid argument name in
S.argSplusObjectValue
- Value of the argument.public void addArgument(java.lang.String argName, java.lang.String... argStringValue)
String
value as argument with name defined by argName
.argName
- Name of the argument. Cannot be null or empty. Other than
that, the string is not validated as a valid argument name in
S.argStringValue
- Value of the argument.public void addExpression(java.lang.String expression)
addExpression(String, String...)
is preferred since it
validates the argument names against all arguments added to the
expression builder.expression
- A valid expression string.public void addExpression(java.lang.String expressionTemplate, java.lang.String... argNames)
argNames
matches the name of an
argument added to this through one of the AddArgument()
methods and then format the string template using the
argNames
and add the result to the list of expressions kept
in this. The result of formatting expressionTemplate
with
argNames
should be a valid expression.expressionTemplate
- A string template that has reference to all the argument
names.argNames
- An array of argument names.public java.lang.String build(SplusDataRequest request)
request
- An SplusDataRequest
object. Should not be null.java.lang.IllegalStateException
- if there is no expression added to this through the
addExpression(String)
or
addExpression(String, String...)
method.java.lang.NullPointerException
- if request is null.public boolean hasArg(java.lang.String argName)
argName
is the name for an
existing argument added to this through one of the
AddArgumant()
methods.argName
- Name of the argument. Cannot be null or empty. Other than
that, the string is not validated as a valid argument name in
S.true
if it is the name for an existing argument; otherwise false
.