public class Interpreter extends Object
Modifier and Type | Field and Description |
---|---|
static EvaluationEnvironment |
SIMPLE_EVALUATION_ENVIRONMENT
Evaluates function calls to itself.
|
Modifier and Type | Method and Description |
---|---|
static String |
dump(Object value)
Converts an object to a TDD-like representation (not necessary valid
TDD).
|
static Object |
eval(Fragment fragment,
EvaluationEnvironment ee,
boolean forceStringValues)
Evaluates a
Fragment as single TDD expression. |
static Object |
eval(String text)
Same as
eval(text, null, false, null) . |
static Object |
eval(String text,
EvaluationEnvironment ee,
boolean forceStringValues,
String fileName)
Evaluates text as single TDD expression.
|
static Object |
eval(String text,
String fileName)
Same as
eval(text, null, false, fileName) . |
static Map |
evalAsHash(String text)
Same as
evalAsHash(text, null, false, null) . |
static Map |
evalAsHash(String text,
EvaluationEnvironment ee,
boolean forceStringValues,
String fileName)
Evaluates text as a list of key:value pairs.
|
static Map |
evalAsHash(String text,
String fileName)
Same as
evalAsHash(text, null, false, fileName) . |
static List |
evalAsSequence(String text)
Same as
evalAsList(text, null, false, null) . |
static List |
evalAsSequence(String text,
EvaluationEnvironment ee,
boolean forceStringValues,
String fileName)
Evaluates text as a list values.
|
static List |
evalAsSequence(String text,
String fileName)
Same as
evalAsList(text, null, false, fileName) . |
EvaluationEnvironment |
getEvaluationEnvironment() |
String |
getFileName() |
int |
getPosition() |
String |
getText() |
static String |
getTypeName(Object value) |
static String |
loadTdd(byte[] b,
String defaultEncoding)
Loads a TDD file with utilizing #encoding:enc header.
|
static String |
loadTdd(InputStream in,
String defaultEncoding)
Loads a TDD file with utilizing #encoding:enc header.
|
public static final EvaluationEnvironment SIMPLE_EVALUATION_ENVIRONMENT
public static Object eval(String text, EvaluationEnvironment ee, boolean forceStringValues, String fileName) throws EvalException
text
- the text to interpret.ee
- the EvaluationEnvironment
used to resolve function
calls. If it is null
then
SIMPLE_EVALUATION_ENVIRONMENT
will be used.forceStringValues
- specifies if expressions as true and
123 should be interpreted as strings, or as boolean and
number respectively.fileName
- the path of the source file, or other description of the
source. It is used for informative purposes only, as in error
messages.Map
, but never null
.EvalException
public static Object eval(Fragment fragment, EvaluationEnvironment ee, boolean forceStringValues) throws EvalException
Fragment
as single TDD expression. The expression
can be surrounded with superfluous white-space.EvalException
eval(String, EvaluationEnvironment, boolean, String)
public static Object eval(String text, String fileName) throws EvalException
eval(text, null, false, fileName)
.EvalException
eval(String, EvaluationEnvironment, boolean, String)
public static Object eval(String text) throws EvalException
eval(text, null, false, null)
.EvalException
eval(String, EvaluationEnvironment, boolean, String)
public static Map evalAsHash(String text, EvaluationEnvironment ee, boolean forceStringValues, String fileName) throws EvalException
text
- the text to interpret.ee
- the EvaluationEnvironment
used to resolve function
calls. If it is null
then
SIMPLE_EVALUATION_ENVIRONMENT
will be used.forceStringValues
- specifies if expressions as true and
123 should be interpreted as strings, or as boolean and
number respectively.fileName
- the path of the source file, or other description of the
source. It is used for informative purposes only, as in error
messages.Map
, but never null
.EvalException
public static Map evalAsHash(String text) throws EvalException
evalAsHash(text, null, false, null)
.EvalException
evalAsHash(String, EvaluationEnvironment, boolean, String)
public static Map evalAsHash(String text, String fileName) throws EvalException
evalAsHash(text, null, false, fileName)
.EvalException
evalAsHash(String, EvaluationEnvironment, boolean, String)
public static List evalAsSequence(String text, EvaluationEnvironment ee, boolean forceStringValues, String fileName) throws EvalException
text
- the text to interpret.ee
- the EvaluationEnvironment
used to resolve function
calls. If it is null
then
SIMPLE_EVALUATION_ENVIRONMENT
will be used.forceStringValues
- specifies if expressions as true and
123 should be interpreted as strings, or as boolean and
number respectively.fileName
- the path of the source file, or other description of the
source. It is used for informative purposes only, as in error
messages.List
, but never null
.EvalException
public static List evalAsSequence(String text) throws EvalException
evalAsList(text, null, false, null)
.EvalException
evalAsSequence(String, EvaluationEnvironment, boolean, String)
public static List evalAsSequence(String text, String fileName) throws EvalException
evalAsList(text, null, false, fileName)
.EvalException
evalAsSequence(String, EvaluationEnvironment, boolean, String)
public static String loadTdd(InputStream in, String defaultEncoding) throws IOException
in
- the stream that reads the content of the file.IOException
public static String loadTdd(byte[] b, String defaultEncoding) throws IOException
b
- the content of the file.IOException
public static String dump(Object value)
value
- the object to convertpublic int getPosition()
public String getText()
public String getFileName()
public EvaluationEnvironment getEvaluationEnvironment()