Expressions#

The nodes a server side function is built from, and the types they work with. See the server side functions tutorial for how a function is assembled and run.

public class Expression#

A server side expression.

Note

Numeric operands of differing types are converted to a common type.

Type getReturnType()#

The type of the value the expression evaluates to. Throws an exception if the value cannot be sent to a client.

Note

A function created with Expression.lambda(java.util.List<Expression>, Expression) evaluates to the value it returns. A lazily evaluated collection, such as from Expression.select(Expression, Expression), is sent once converted by Expression.toList(Expression) or Expression.toSet(Expression).

boolean getHasReturnType()#

Whether the expression evaluates to a value.

Note

An expression with no value has no Expression.getReturnType(). An empty collection and no value both encode to an empty sequence of bytes.

java.util.List<Type> getParameterTypes()#

The types of the function’s parameters.

Note

Empty for a function that is not created with Expression.lambda(java.util.List<Expression>, Expression).

static Expression constantDouble(Connection connection, double value)#

A constant value of double precision floating point type.

Parameters:
  • value (double) – The value.

static Expression constantFloat(Connection connection, float value)#

A constant value of single precision floating point type.

Parameters:
  • value (float) – The value.

static Expression constantInt(Connection connection, int value)#

A constant value of integer type.

Parameters:
  • value (int) – The value.

static Expression constantLong(Connection connection, long value)#

A constant value of long integer type.

Parameters:
  • value (long) – The value.

static Expression constantUInt(Connection connection, int value)#

A constant value of unsigned integer type.

Parameters:
  • value (int) – The value.

static Expression constantULong(Connection connection, long value)#

A constant value of unsigned long integer type.

Parameters:
  • value (long) – The value.

static Expression constantBool(Connection connection, boolean value)#

A constant value of boolean type.

Parameters:
  • value (boolean) – The value.

static Expression constantString(Connection connection, String value)#

A constant value of string type.

Parameters:
  • value (String) – The value.

static Expression constantBytes(Connection connection, byte[] value)#

A constant value of bytes type.

Parameters:
  • value (byte[]) – The value.

static Expression constantEnum(Connection connection, String service, String name, int value)#

A constant value of an enumeration a service defines.

Parameters:
  • service (String) – The name of the service the enumeration is defined in.

  • name (String) – The name of the enumeration.

  • value (int) – The value of the member of the enumeration.

static Expression constantNull(Connection connection, Type type)#

A null constant of the given type.

Parameters:
  • type (Type) – The type of the value.

Note

The type is made nullable, as by Type.nullableType(Type).

static Expression constantObject(Connection connection, long value)#

A constant object, an instance of a class a service defines.

Parameters:
  • value (long) – The object identifier of the object.

Note

The object is given by its object identifier.

static Expression call(Connection connection, krpc.schema.KRPC.ProcedureCall call)#

An RPC call.

Parameters:
  • call (krpc.schema.KRPC.ProcedureCall) – The procedure call.

Note

The instance the call is made on, and the values of its arguments, are fixed when the expression is created. A call to a procedure with no return value is evaluated for its effects, as a statement in a Expression.block(java.util.List<Expression>). A collection the procedure returns is copied, as a client would receive it.

static Expression callWithArguments(Connection connection, krpc.schema.KRPC.ProcedureCall call, java.util.Map<Integer, Expression> args)#

An RPC call, where some or all of the arguments are computed by expressions.

Parameters:
  • call (krpc.schema.KRPC.ProcedureCall) – The RPC to call.

  • args (java.util.Map) – Expressions computing the call’s arguments, by position.

Note

Position 0 is the instance of a class method or property. A position with no expression takes the argument encoded in the call, or the parameter’s default. A collection the procedure returns is copied, as a client would receive it.

static Expression equal(Connection connection, Expression arg0, Expression arg1)#

Equality comparison.

Parameters:

Note

Collections, tuples, bytes and structures compare by their contents. Throws an exception if the operands are of unrelated types.

static Expression notEqual(Connection connection, Expression arg0, Expression arg1)#

Inequality comparison.

Parameters:

Note

Collections, tuples, bytes and structures compare by their contents. Throws an exception if the operands are of unrelated types.

static Expression greaterThan(Connection connection, Expression arg0, Expression arg1)#

Greater than numerical comparison.

Parameters:
static Expression greaterThanOrEqual(Connection connection, Expression arg0, Expression arg1)#

Greater than or equal numerical comparison.

Parameters:
static Expression lessThan(Connection connection, Expression arg0, Expression arg1)#

Less than numerical comparison.

Parameters:
static Expression lessThanOrEqual(Connection connection, Expression arg0, Expression arg1)#

Less than or equal numerical comparison.

Parameters:
static Expression isNull(Connection connection, Expression value)#

Whether a value is null. Throws an exception if the type of the value cannot be null.

Parameters:
static Expression and(Connection connection, Expression arg0, Expression arg1)#

Logical or bitwise and, which evaluates both operands.

Parameters:
static Expression or(Connection connection, Expression arg0, Expression arg1)#

Logical or bitwise or, which evaluates both operands.

Parameters:
static Expression conditionalAnd(Connection connection, Expression arg0, Expression arg1)#

Logical and, which evaluates the second operand only when the first is true.

Parameters:
static Expression conditionalOr(Connection connection, Expression arg0, Expression arg1)#

Logical or, which evaluates the second operand only when the first is false.

Parameters:
static Expression exclusiveOr(Connection connection, Expression arg0, Expression arg1)#

Logical or bitwise exclusive or.

Parameters:
static Expression not(Connection connection, Expression arg)#

Logical or bitwise negation.

Parameters:
static Expression negate(Connection connection, Expression arg)#

Numerical negation, which negates a uint as a long.

Parameters:
static Expression conditional(Connection connection, Expression condition, Expression ifTrue, Expression ifFalse)#

The second argument if the condition is true, and the third argument otherwise.

Parameters:
  • condition (Expression) – The boolean condition.

  • ifTrue (Expression) – The value when the condition is true.

  • ifFalse (Expression) – The value when the condition is false.

Note

Throws an exception if the two values have no common type.

static Expression add(Connection connection, Expression arg0, Expression arg1)#

Numerical addition.

Parameters:
static Expression subtract(Connection connection, Expression arg0, Expression arg1)#

Numerical subtraction.

Parameters:
static Expression multiply(Connection connection, Expression arg0, Expression arg1)#

Numerical multiplication.

Parameters:
static Expression divide(Connection connection, Expression arg0, Expression arg1)#

Numerical division.

Parameters:
static Expression modulo(Connection connection, Expression arg0, Expression arg1)#

Numerical modulo operator.

Parameters:
Returns:

The remainder of arg0 divided by arg1

static Expression power(Connection connection, Expression arg0, Expression arg1)#

Numerical power operator.

Parameters:
Returns:

arg0 raised to the power of arg1, at the common type of the operands

static Expression leftShift(Connection connection, Expression arg0, Expression arg1)#

Bitwise left shift.

Parameters:

Note

Only the low 5 bits of the count are used for a 32-bit value, and the low 6 bits for a 64-bit value.

static Expression rightShift(Connection connection, Expression arg0, Expression arg1)#

Bitwise right shift.

Parameters:

Note

Only the low 5 bits of the count are used for a 32-bit value, and the low 6 bits for a 64-bit value.

static Expression cast(Connection connection, Expression arg, Type type)#

A value cast to the given type.

Parameters:
  • arg (Expression) – The value to cast.

  • type (Type) – Type to cast the argument to.

Note

A tuple or collection is cast element by element.

static Expression parameter(Connection connection, String name, Type type)#

A named parameter of a function.

Parameters:
  • name (String) – The name of the parameter.

  • type (Type) – The type of the parameter.

Returns:

A named parameter.

Note

A value is bound to it by name with Expression.invoke(Expression, java.util.Map<String,Expression>), or by its position in the parameters of a Expression.lambda(java.util.List<Expression>, Expression).

static Expression lambda(Connection connection, java.util.List<Expression> parameters, Expression body)#

A function with the given parameters and body.

Parameters:
Returns:

A function.

Note

The body is an expression or a block of statements, and a body with no value is evaluated for its effects. A Expression.return_(Expression) or Expression.returnNothing() statement ends the evaluation.

static Expression invoke(Connection connection, Expression function, java.util.Map<String, Expression> args)#

A function call.

Parameters:
  • function (Expression) – The function to call.

  • args (java.util.Map) – The arguments to call the function with.

Returns:

A function call.

static Expression block(Connection connection, java.util.List<Expression> statements)#

A block of statements, whose value is that of its last statement.

Parameters:
static Expression blockWithVariables(Connection connection, java.util.List<Expression> variables, java.util.List<Expression> statements)#

A block of statements with local variables.

Parameters:

Note

The value of the block is that of its last statement. The variables are in scope for the statements of the block, including within nested functions.

static Expression variable(Connection connection, String name, Type type)#

A local variable, declared by Expression.blockWithVariables(java.util.List<Expression>, java.util.List<Expression>).

Parameters:
  • name (String) – The name of the variable.

  • type (Type) – The type of the variable.

Returns:

A local variable.

static Expression stateVariable(Connection connection, String name, Expression initialValue)#

A variable that keeps its value between evaluations of a function.

Parameters:
  • name (String) – The name of the variable.

  • initialValue (Expression) – The initial value of the variable.

Returns:

A state variable.

Note

The initial value is evaluated once, when the variable is created, and gives the variable its type. The value belongs to the variable, so every function that contains it shares it.

static Expression assign(Connection connection, Expression variable, Expression value)#

An assignment to a local variable, state variable or function parameter.

Parameters:

Note

The value’s type must be assignable to the variable’s type. A numeric value of a different type is widened, and narrowing it requires a cast.

static Expression ifThen(Connection connection, Expression condition, Expression body)#

An if statement, with no value.

Parameters:
  • condition (Expression) – The boolean condition.

  • body (Expression) – The statement evaluated when the condition is true.

Note

Use Expression.conditional(Expression, Expression, Expression) for an if-then-else that produces a value.

static Expression ifThenElse(Connection connection, Expression condition, Expression body, Expression elseBody)#

An if-else statement, with no value.

Parameters:
  • condition (Expression) – The boolean condition.

  • body (Expression) – The statement evaluated when the condition is true.

  • elseBody (Expression) – The statement evaluated when the condition is false.

Note

Use Expression.conditional(Expression, Expression, Expression) for an if-then-else that produces a value.

static Expression while_(Connection connection, Expression condition, Expression body)#

A while loop, which evaluates the body while the condition is true.

Parameters:
  • condition (Expression) – The boolean condition.

  • body (Expression) – The statement evaluated on each iteration.

Note

A Expression.break_() or Expression.continue_() in the body applies to this loop.

static Expression forEach(Connection connection, Expression variable, Expression collection, Expression body)#

A loop that evaluates the body once for each value of a collection.

Parameters:
  • variable (Expression) – The loop variable.

  • collection (Expression) – The collection to iterate over.

  • body (Expression) – The statement evaluated on each iteration.

Note

The loop variable is a local variable declared by an enclosing Expression.blockWithVariables(java.util.List<Expression>, java.util.List<Expression>), or a parameter of an enclosing Expression.lambda(java.util.List<Expression>, Expression). A Expression.break_() or Expression.continue_() in the body applies to this loop.

static Expression break_(Connection connection)#

A break statement, which ends the enclosing loop.

static Expression continue_(Connection connection)#

A continue statement, which skips to the next iteration of the enclosing loop.

static Expression return_(Connection connection, Expression value)#

A return statement, which ends the enclosing function with a value.

Parameters:
static Expression returnNothing(Connection connection)#

A return statement, which ends the enclosing function with no value.

static Expression throw_(Connection connection, String service, String name, Expression message)#

A throw statement, which raises the named exception.

Parameters:
  • service (String) – The name of the service the exception is defined in.

  • name (String) – The name of the exception.

  • message (Expression) – The message of the exception.

Note

The client receives the exception as an error from the function, or from the stream or event evaluating it. Throws an exception if the service does not declare it.

static Expression tryCatch(Connection connection, Expression body, String service, String name, Expression message, Expression handler)#

A try-catch statement that handles the named exception.

Parameters:
  • body (Expression) – The statement to evaluate.

  • service (String) – The name of the service the exception is defined in.

  • name (String) – The name of the exception.

  • message (Expression) – A string variable assigned the exception’s message, or null.

  • handler (Expression) – The statement evaluated when the exception is caught.

Note

Only an exception a service declares can be named, and Expression.tryCatchAll(Expression, Expression, Expression) handles any exception. Throws an exception if the service does not declare it.

static Expression tryCatchAll(Connection connection, Expression body, Expression message, Expression handler)#

A try-catch statement that handles any exception.

Parameters:
  • body (Expression) – The statement to evaluate.

  • message (Expression) – A string variable assigned the exception’s message, or null.

  • handler (Expression) – The statement evaluated when an exception is caught.

static Expression tryFinally(Connection connection, Expression body, Expression finalizer)#

A try-finally statement.

Parameters:
  • body (Expression) – The statement to evaluate.

  • finalizer (Expression) – The statement evaluated after the body.

Note

The finalizer is evaluated after the body, whether or not the body raises an exception. A break, continue or return cannot leave the finalizer.

static Expression createTuple(Connection connection, java.util.List<Expression> elements)#

A tuple of the given elements. Throws an exception if there are no elements or more than seven.

Parameters:
Returns:

The tuple.

static Expression createStruct(Connection connection, Type type, java.util.List<Expression> fieldValues)#

A structure with the given field values. Throws an exception if the field values do not match its fields.

Parameters:
  • type (Type) – The type of the structure.

  • fieldValues (java.util.List) – The values of the structure’s fields, in the order the structure declares them.

Returns:

The structure.

static Expression createList(Connection connection, java.util.List<Expression> values)#

A list of the given values, with numbers widened to their common type. Throws an exception if there are no values.

Parameters:
Returns:

The list.

static Expression createSet(Connection connection, java.util.Set<Expression> values)#

A set of the given values, with numbers widened to their common type. Throws an exception if there are no values, or a value is null.

Parameters:
Returns:

The set.

Note

The values are evaluated in an unspecified order.

static Expression createDictionary(Connection connection, java.util.List<Expression> keys, java.util.List<Expression> values)#

A dictionary of the given keys and corresponding values, with numbers widened to their common type. Throws an exception if there are no keys, the counts differ, the keys are not of a valid key type, or a key is null.

Parameters:
Returns:

The dictionary.

Note

A repeated key takes the last of its values.

static Expression createEmptyList(Connection connection, Type valueType)#

An empty list of the given value type.

Parameters:
  • valueType (Type) – The type of the values the list holds.

Returns:

The empty list.

static Expression createEmptySet(Connection connection, Type valueType)#

An empty set of the given value type. Throws an exception if the value type is nullable.

Parameters:
  • valueType (Type) – The type of the values the set holds.

Returns:

The empty set.

static Expression createEmptyDictionary(Connection connection, Type keyType, Type valueType)#

An empty dictionary of the given key and value types. Throws an exception if the key type is nullable or not a valid key type.

Parameters:
  • keyType (Type) – The type of the dictionary’s keys.

  • valueType (Type) – The type of the dictionary’s values.

Returns:

The empty dictionary.

static Expression append(Connection connection, Expression collection, Expression value)#

A statement adding a value to a list or a set.

Parameters:

Note

The value goes on the end of a list. A set holding the value is left unchanged.

static Expression set(Connection connection, Expression collection, Expression index, Expression value)#

A statement setting an element of a list, or an entry of a dictionary.

Parameters:
  • collection (Expression) – The list or dictionary.

  • index (Expression) – The index of the element, counting from zero, or the key of the entry.

  • value (Expression) – The value to set.

Note

A key the dictionary does not hold is added. Throws an exception if the index is out of range for the list.

static Expression remove(Connection connection, Expression collection, Expression value)#

A removal of a value from a list or a set, or of an entry from a dictionary.

Parameters:
  • collection (Expression) – The list, set or dictionary.

  • value (Expression) – The value to remove, or the key of the entry to remove.

Returns:

Whether the collection held the value.

Note

The first occurrence is removed from a list.

static Expression removeAt(Connection connection, Expression list, Expression index)#

A statement removing the element at an index of a list.

Parameters:
  • list (Expression) – The list.

  • index (Expression) – The index of the element, counting from zero.

Note

Throws an exception if the index is out of range.

static Expression clear(Connection connection, Expression collection)#

A statement removing every value from a list or a set, or every entry from a dictionary.

Parameters:
  • collection (Expression) – The list, set or dictionary.

static Expression dictionaryKeys(Connection connection, Expression dictionary)#

The keys of a dictionary, as a list.

Parameters:
Returns:

The keys of the dictionary.

Note

The collection operations take the keys of a dictionary from here, and its values from Expression.dictionaryValues(Expression).

static Expression dictionaryValues(Connection connection, Expression dictionary)#

The values of a dictionary, as a list.

Parameters:
Returns:

The values of the dictionary.

static Expression toList(Connection connection, Expression arg)#

A collection as a list.

Parameters:
Returns:

The collection as a list.

static Expression toSet(Connection connection, Expression arg)#

A collection as a set.

Parameters:
Returns:

The collection as a set.

Note

Throws an exception if a value is null.

static Expression buildDictionary(Connection connection, Expression arg, Expression keyFunc, Expression valueFunc)#

A dictionary built from a collection, with a key and a value computed from each element.

Parameters:
  • arg (Expression) – The list or set.

  • keyFunc (Expression) – The function computing an element’s key.

  • valueFunc (Expression) – The function computing an element’s value.

Returns:

The dictionary.

Note

A repeated key takes the last of its values.

static Expression get(Connection connection, Expression arg, Expression index)#

An element of a tuple, list or dictionary.

Parameters:
  • arg (Expression) – The tuple, list or dictionary.

  • index (Expression) – The index or key of the element.

Returns:

The element.

Note

A tuple takes a constant integer index, a list a zero indexed integer and a dictionary a key. Throws an exception if the index is out of range or the key is missing, and for a tuple when the expression is created.

static Expression getField(Connection connection, Expression arg, String name)#

The value of a field of a structure. Throws an exception if the value is not a structure, or has no field of the given name.

Parameters:
  • arg (Expression) – The structure.

  • name (String) – The name of the field to access.

Returns:

The value of the field.

static Expression convertToString(Connection connection, Expression arg)#

The string representation of a value.

Parameters:
Returns:

The string representation of the value.

Note

A value other than a number, boolean, string or enumeration converts as .NET formats it, which for a collection is the name of its type. Throws an exception if the value is null.

static Expression stringConcat(Connection connection, java.util.List<Expression> args)#

The concatenation of strings.

Parameters:
Returns:

The concatenated string.

Note

Use Expression.convertToString(Expression) to convert other values to strings.

static Expression stringLength(Connection connection, Expression arg)#

The number of characters in a string.

Parameters:
Returns:

The length of the string.

static Expression stringGet(Connection connection, Expression arg, Expression index)#

The character at the given position in a string, as a string of length one.

Parameters:
  • arg (Expression) – The string.

  • index (Expression) – The position of the character, counting from zero.

Returns:

The character at the given position.

Note

Throws an exception if the index is out of range.

static Expression stringSubstring(Connection connection, Expression arg, Expression start, Expression length)#

Part of a string.

Parameters:
  • arg (Expression) – The string.

  • start (Expression) – The position to start at, counting from zero.

  • length (Expression) – The number of characters to take.

Returns:

The substring.

Note

Throws an exception if the start or the length is out of range.

static Expression stringIndexOf(Connection connection, Expression arg, Expression value)#

The position of the first occurrence of one string within another.

Parameters:
Returns:

The position of the value, counting from zero, or -1 if it does not occur.

static Expression stringContains(Connection connection, Expression arg, Expression value)#

Whether one string occurs within another.

Parameters:
Returns:

Whether the value occurs in the string.

static Expression stringStartsWith(Connection connection, Expression arg, Expression value)#

Whether a string starts with another.

Parameters:
Returns:

Whether the string starts with the value.

static Expression stringEndsWith(Connection connection, Expression arg, Expression value)#

Whether a string ends with another.

Parameters:
Returns:

Whether the string ends with the value.

static Expression stringToUpper(Connection connection, Expression arg)#

A string in upper case, independently of the game’s language.

Parameters:
Returns:

The string in upper case.

static Expression stringToLower(Connection connection, Expression arg)#

A string in lower case, independently of the game’s language.

Parameters:
Returns:

The string in lower case.

static Expression stringTrim(Connection connection, Expression arg)#

A string with white space removed from both ends.

Parameters:
Returns:

The trimmed string.

static Expression stringTrimStart(Connection connection, Expression arg)#

A string with white space removed from its start.

Parameters:
Returns:

The trimmed string.

static Expression stringTrimEnd(Connection connection, Expression arg)#

A string with white space removed from its end.

Parameters:
Returns:

The trimmed string.

static Expression stringReplace(Connection connection, Expression arg, Expression oldValue, Expression newValue)#

A string with every occurrence of one string replaced by another.

Parameters:
  • arg (Expression) – The string to search.

  • oldValue (Expression) – The string to replace.

  • newValue (Expression) – The string to replace it with.

Returns:

The string with the replacements made.

Note

Throws an exception if the string to replace is empty.

static Expression stringSplit(Connection connection, Expression arg, Expression separator)#

The parts of a string separated by another string.

Parameters:
  • arg (Expression) – The string to split.

  • separator (Expression) – The string that separates the parts.

Returns:

The parts of the string.

static Expression stringJoin(Connection connection, Expression separator, Expression values)#

Strings joined together, separated by another string.

Parameters:
  • separator (Expression) – The string to put between the values.

  • values (Expression) – The strings to join.

Returns:

The joined string.

static Expression count(Connection connection, Expression arg)#

The number of values in a collection.

Parameters:
  • arg (Expression) – The list, set or dictionary.

Returns:

The number of elements in the collection.

static Expression sum(Connection connection, Expression arg)#

The sum of the values of a collection.

Parameters:
Returns:

The sum of the elements in the collection.

static Expression max(Connection connection, Expression arg)#

The largest value of a collection.

Parameters:
Returns:

The largest value in the collection.

Note

Throws an exception if the collection is empty and its values are not nullable.

static Expression min(Connection connection, Expression arg)#

The smallest value of a collection.

Parameters:
Returns:

The smallest value in the collection.

Note

Throws an exception if the collection is empty and its values are not nullable.

static Expression average(Connection connection, Expression arg)#

The average of the values of a collection.

Parameters:
Returns:

The average of the elements in the collection.

Note

Throws an exception if the collection is empty and its values are not nullable.

static Expression select(Connection connection, Expression arg, Expression func)#

The result of a function for each value of a collection.

Parameters:
  • arg (Expression) – The list or set.

  • func (Expression) – The function, taking an element of the collection.

Returns:

The collection of function results.

Note

The result is lazily evaluated. Expression.toList(Expression) makes it concrete.

static Expression where(Connection connection, Expression arg, Expression func)#

The values of a collection for which a predicate function returns true.

Parameters:
  • arg (Expression) – The list or set.

  • func (Expression) – The predicate function, taking an element of the collection.

Returns:

The filtered collection.

Note

The result is lazily evaluated. Expression.toList(Expression) makes it concrete.

static Expression selectMany(Connection connection, Expression arg, Expression func)#

The values of the collections a function returns for each value of a collection, flattened into one.

Parameters:
  • arg (Expression) – The list or set.

  • func (Expression) – The function, taking an element of the collection and returning a collection.

Returns:

The flattened collection of function results.

Note

The result is lazily evaluated. Expression.toList(Expression) makes it concrete.

static Expression contains(Connection connection, Expression arg, Expression value)#

Whether a collection contains a value.

Parameters:
Returns:

Whether the collection contains the value.

static Expression containsKey(Connection connection, Expression dictionary, Expression key)#

Whether a dictionary contains a key.

Parameters:
Returns:

Whether the dictionary contains the key.

static Expression aggregate(Connection connection, Expression arg, Expression func)#

The result of applying an accumulator function over a collection.

Parameters:
Returns:

The accumulated value.

Note

Throws an exception if the collection is empty.

static Expression aggregateWithSeed(Connection connection, Expression arg, Expression seed, Expression func)#

The result of applying an accumulator function over a collection, starting from a seed.

Parameters:
Returns:

The accumulated value.

Note

The seed widens to the type of the accumulated value, the function’s result.

static Expression concat(Connection connection, Expression arg1, Expression arg2)#

The values of one collection followed by those of another.

Parameters:
Returns:

The first collection followed by the second.

Note

The result is lazily evaluated. Expression.toList(Expression) makes it concrete.

static Expression skip(Connection connection, Expression arg, Expression count)#

A collection without its first count values.

Parameters:
Returns:

The collection without its first count values.

Note

The result is lazily evaluated. Expression.toList(Expression) makes it concrete.

static Expression take(Connection connection, Expression arg, Expression count)#

The first count values of a collection.

Parameters:
Returns:

The first count values of the collection.

Note

The result is lazily evaluated. Expression.toList(Expression) makes it concrete.

static Expression orderBy(Connection connection, Expression arg, Expression key)#

The values of a collection ordered by the key a function produces for each of them.

Parameters:
  • arg (Expression) – The collection to order.

  • key (Expression) – A function producing the key to order values by.

Returns:

The ordered collection.

Note

The result is lazily evaluated. Expression.toList(Expression) makes it concrete.

static Expression all(Connection connection, Expression arg, Expression predicate)#

Whether a predicate function returns true for every value of a collection.

Parameters:
Returns:

Whether all items satisfy the predicate.

static Expression any(Connection connection, Expression arg, Expression predicate)#

Whether a predicate function returns true for any value of a collection.

Parameters:
Returns:

Whether any item satisfies the predicate.

static Expression first(Connection connection, Expression arg)#

The first value of a collection.

Parameters:
Returns:

The first value.

Note

Throws an exception if the collection is empty.

static Expression last(Connection connection, Expression arg)#

The last value of a collection.

Parameters:
Returns:

The last value.

Note

Throws an exception if the collection is empty.

static Expression elementAt(Connection connection, Expression arg, Expression index)#

The value at the given position in a collection.

Parameters:
  • arg (Expression) – The collection.

  • index (Expression) – The position of the value, counting from zero.

Returns:

The value at the given position.

Note

Throws an exception if the index is out of range.

static Expression minBy(Connection connection, Expression arg, Expression key)#

The value of a collection with the smallest key.

Parameters:
  • arg (Expression) – The collection.

  • key (Expression) – A function producing the key to compare values by.

Returns:

The value with the smallest key.

Note

Throws an exception if the collection is empty.

static Expression maxBy(Connection connection, Expression arg, Expression key)#

The value of a collection with the largest key.

Parameters:
  • arg (Expression) – The collection.

  • key (Expression) – A function producing the key to compare values by.

Returns:

The value with the largest key.

Note

Throws an exception if the collection is empty.

static Expression distinct(Connection connection, Expression arg)#

The values of a collection with duplicates removed, keeping the first occurrence of each.

Parameters:
Returns:

The distinct values of the collection.

Note

The result is lazily evaluated. Expression.toList(Expression) makes it concrete.

static Expression reverse(Connection connection, Expression arg)#

The values of a collection in the opposite order.

Parameters:
Returns:

The reversed collection.

Note

The result is lazily evaluated. Expression.toList(Expression) makes it concrete.

static Expression union(Connection connection, Expression arg1, Expression arg2)#

The values in either of two collections, with duplicates removed.

Parameters:
Returns:

The union of the two collections.

Note

The result is lazily evaluated. Expression.toList(Expression) makes it concrete.

static Expression intersect(Connection connection, Expression arg1, Expression arg2)#

The values in both of two collections, with duplicates removed.

Parameters:
Returns:

The intersection of the two collections.

Note

The result is lazily evaluated. Expression.toList(Expression) makes it concrete.

static Expression except(Connection connection, Expression arg1, Expression arg2)#

The values of the first collection that are not in the second, with duplicates removed.

Parameters:
Returns:

The difference between the two collections.

Note

The result is lazily evaluated. Expression.toList(Expression) makes it concrete.

static Expression zip(Connection connection, Expression arg1, Expression arg2, Expression func)#

The results of a function applied to the values of two collections in pairs.

Parameters:
  • arg1 (Expression) – The first collection.

  • arg2 (Expression) – The second collection.

  • func (Expression) – A function combining a value from each collection.

Returns:

The combined collection.

Note

The result is as long as the shorter of the two collections. It is lazily evaluated, and Expression.toList(Expression) makes it concrete.

static Expression groupBy(Connection connection, Expression arg, Expression key)#

The values of a collection grouped by the key a function produces for each of them.

Parameters:
  • arg (Expression) – The collection.

  • key (Expression) – A function producing the key to group values by.

Returns:

A dictionary of each key to the values that produced it.

public class Type#

The type of a value a procedure takes or returns.

static Type double_(Connection connection)#

A double precision floating point number type.

static Type float_(Connection connection)#

A single precision floating point number type.

static Type int_(Connection connection)#

A signed 32-bit integer type.

static Type long_(Connection connection)#

A signed 64-bit integer type.

static Type uInt(Connection connection)#

An unsigned 32-bit integer type.

static Type uLong(Connection connection)#

An unsigned 64-bit integer type.

static Type bool(Connection connection)#

A boolean type.

static Type string(Connection connection)#

A string type.

static Type bytes(Connection connection)#

A byte sequence type.

static Type classType(Connection connection, String service, String name)#

The type of a class defined by a service.

Parameters:
  • service (String) – The name of the service the class is defined in.

  • name (String) – The name of the class.

static Type enumerationType(Connection connection, String service, String name)#

The type of an enumeration defined by a service.

Parameters:
  • service (String) – The name of the service the enumeration is defined in.

  • name (String) – The name of the enumeration.

static Type structType(Connection connection, String service, String name)#

The type of a structure defined by a service.

Parameters:
  • service (String) – The name of the service the structure is defined in.

  • name (String) – The name of the structure.

static Type tupleType(Connection connection, java.util.List<Type> valueTypes)#

A tuple type. Throws an exception if there are no element types or more than seven.

Parameters:
  • valueTypes (java.util.List) – The types of the elements of the tuple.

static Type listType(Connection connection, Type valueType)#

A list type.

Parameters:
  • valueType (Type) – The type of the elements of the list.

static Type setType(Connection connection, Type valueType)#

A set type. Throws an exception if the element type is nullable.

Parameters:
  • valueType (Type) – The type of the elements of the set.

static Type dictionaryType(Connection connection, Type keyType, Type valueType)#

A dictionary type. Throws an exception if the key type is nullable or not a valid key type.

Parameters:
  • keyType (Type) – The type of the keys of the dictionary.

  • valueType (Type) – The type of the values of the dictionary.

static Type nullableType(Connection connection, Type valueType)#

A nullable type, holding a value of the given type or null.

Parameters:
  • valueType (Type) – The type of the value.

TypeCode getCode()#

The kind of the type.

String getService()#

The service a class, enumeration or structure type is defined in, or an empty string.

String getName()#

The name of a class, enumeration or structure type, or an empty string.

java.util.List<Type> getTypes()#

The types of the elements of a tuple, list, set or dictionary type.

Note

The value types of a tuple, the value type of a list or set, or the key and value types of a dictionary. An empty list for any other type.

boolean getNullable()#

Whether a value of the type may be null.

Note

Any type can be nullable. A string or class value of a type that is not nullable is never null.

public enum TypeCode#

The kind of a type, with the values of the communication protocol’s type codes.

public TypeCode DOUBLE#

A double precision floating point number.

public TypeCode FLOAT#

A single precision floating point number.

public TypeCode S_INT32#

A signed 32-bit integer.

public TypeCode S_INT64#

A signed 64-bit integer.

public TypeCode U_INT32#

An unsigned 32-bit integer.

public TypeCode U_INT64#

An unsigned 64-bit integer.

public TypeCode BOOL#

A boolean.

public TypeCode STRING#

A string.

public TypeCode BYTES#

A sequence of bytes.

public TypeCode CLASS#

A class defined by a service.

public TypeCode ENUMERATION#

An enumeration defined by a service.

public TypeCode STRUCT#

A structure defined by a service.

public TypeCode TUPLE#

A tuple, with the types of its values in Type.getTypes().

public TypeCode LIST#

A list, with the type of its values in Type.getTypes().

public TypeCode SET#

A set, with the type of its values in Type.getTypes().

public TypeCode DICTIONARY#

A dictionary, with the types of its keys and values in Type.getTypes().