![]() | [using it] | Interface Manipulation Package v4.0 (2008-06-25) | ![]() | ©copyright | ![]() |
java.lang.Objectimp.core.Functions
public class Functions
This factory contains core functions implementation.
let(name, value, expression) | considers name as a new local variable in the expression and return the expression. |
Value interface | |
is(value, type) | returns true if the value is of the given type. |
get(value, name-or-index) | gets the field or element of the value. |
query(value, path) | gets all field or element of the value in the given path. |
set(value, name-or-index, property) | sets the field or element of the value and return the value. |
length(value) | returns the value length. |
eq(value1, value2) | returns true or false whether the values are equal or not. |
Nested Class Summary | |
---|---|
static class |
Functions.Rule
Defines a function defined by a pattern-matching rule. |
Method Summary | |
---|---|
static boolean |
is(Value value,
Value type)
Tests if a value is of a given type. |
Value |
map(String method,
Value value)
Maps a method on the value fields/elements. |
static Value |
query(Value root,
String path)
Returns all fields/elements of the logical-structure in the given path. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static final boolean is(Value value, Value type)
value
- The value to test.type
- The type to check.
null | if the value is null |
true | if the value evaluates to true |
name | if the value is valid name in this context |
number | if the value parses as a number |
string | if the value has a string-value defined (i.e. the stringValue() method). |
string(regular-expression | if the value has a string-value matching the given regular-expression |
cyclic | if the value is cyclic (i.e. if in its field/element tree, there is a reference to itself or to a cyclic value). |
any | returns always true (used to insert side-effect functions in boolean expressions). |
IllegalArgumentException
- If the type is unknown.public Value map(String method, Value value)
method
- The Java full-qualified name of static method of signature Value method(Value)
If the method returns the Java null value it is recursively mapped onto each sub fields/elements, else the result is returned.value
- Value to be mapped.
IllegalArgumentException
- If not a valid static method namepublic static Value query(Value root, String path)
root
- The logical-structure to search in. * @param path This element | . |
The parent | .. |
The elements of the given name | name |
The elements of the given index | index |
The attributes value of the given name | #name |
All attributes values | #* |
All attributes names | #? |
All elements | * |
Preceding elements | < |
Following elements | > |
Ancestor(s) | ... |
Descendant(s) | // |
Parent/child relation | / |
Either-or (to combine two paths) | | |
Verifying a boolean condition | ; condition in which ? corresponds to path element. |
IllegalArgumentException
- If the path is an illegal construct.