public abstract class BaseRuntime<T> extends Object implements Adapter<T>
Adapter directly,
in order to not have to implement a few of the methods that have non-specific
implementations, like Adapter.functionRegistry(), Adapter.typeOf(T)
or the Comparable interface. Subclasses are encouraged to override
these methods if they have more efficient means to perform the same job.| Constructor and Description |
|---|
BaseRuntime()
Create a new runtime with a default function registry.
|
BaseRuntime(FunctionRegistry functionRegistry)
Create a new runtime with a custom function registry.
|
| Modifier and Type | Method and Description |
|---|---|
int |
compare(T value1,
T value2)
Basic implementation of
Comparator.compare(T, T). |
Expression<T> |
compile(String expression)
Compile a JMESPath expression into a reusable expression object.
|
boolean |
equals(Object o)
Required method from the
Comparator interface, returns
true when the argument is of the same class, or a subclass of, the receiver. |
protected String |
escapeString(String str) |
FunctionRegistry |
functionRegistry()
Returns a function registry that can be used by the expression compiler
to look up functions.
|
int |
hashCode() |
NodeFactory<T> |
nodeFactory()
Returns a node factory that can be used by the expression compiler to build
the interpreter AST.
|
protected String |
unparse(T object)
Helper method to render a value as JSON.
|
protected String |
unparseArray(T array) |
protected String |
unparseBoolean(T object) |
protected String |
unparseNull(T object) |
protected String |
unparseNumber(T object) |
protected String |
unparseObject(T object) |
protected String |
unparseString(T object) |
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitcreateArray, createBoolean, createNull, createNumber, createNumber, createObject, createString, getProperty, getProperty, getPropertyNames, isTruthy, parseString, toList, toNumber, toString, typeOfcomparing, comparing, comparingDouble, comparingInt, comparingLong, naturalOrder, nullsFirst, nullsLast, reversed, reverseOrder, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLongpublic BaseRuntime()
public BaseRuntime(FunctionRegistry functionRegistry)
public Expression<T> compile(String expression)
JmesPathThe expression objects should be stateless and thread safe, but the exact details are up to the concrete implementations.
public int compare(T value1, T value2)
Comparator.compare(T, T).
Subclasses should override this method if they have a more efficient way to
compare booleans, numbers and strings than to convert them to Java types
using Adapter.isTruthy(T), Adapter.toNumber(T),
Adapter.toString(T), etc.
This only implements Comparator.compare(T, T) fully for
null, number and string, for
boolean array and object it only
does equality – specifically this means that it will return 0 for equal
booleans, objects or arrays, and -1 otherwise. The reason is that JMESPath
doesn't have any mechanisms for comparing objects or arrays, and doesn't
define how objects and arrays should be compared.
When the arguments are not of the same type -1 is returned.
compare in interface Comparator<T>public FunctionRegistry functionRegistry()
AdapterfunctionRegistry in interface Adapter<T>public NodeFactory<T> nodeFactory()
AdapternodeFactory in interface Adapter<T>public boolean equals(Object o)
Comparator interface, returns
true when the argument is of the same class, or a subclass of, the receiver.equals in interface Comparator<T>equals in class Objectprotected String unparse(T object)
null, number and boolean
render themseves correctly with toString, and that
string renders itself as an unquoted string.Copyright © 2016. All rights reserved.