|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectsleep.runtime.SleepUtils
This class contains generalized utilities for instantiating/wrapping data into the sleep Scalar type. Included for free are methods for executing sleep blocks as well.
Block
,
SleepClosure
,
Scalar
,
ScalarType
,
ScalarArray
,
ScalarHash
Field Summary | |
protected static ScalarType |
nullScalar
a shared instance of the dreaded null scalar... |
Constructor Summary | |
SleepUtils()
|
Method Summary | |
static void |
addKeyword(String keyword)
registers "keyword" as a keyword with the parser. |
static Scalar |
getArrayScalar()
returns a Scalar variable containing a SLEEP array as its value (everything in SLEEP is stored as a Scalar |
static Scalar |
getArrayScalar(ScalarArray value)
Creates a scalar with the specified ScalarArray as the value |
static Scalar |
getArrayWrapper(Collection dataStructure)
An easy way to make your programs data structures available in the script environment. |
static Scalar |
getEmptyScalar()
returns the null scalar, which will always be equal to 0, "", and null simultaneously. |
static SleepClosure |
getFunctionFromScalar(Scalar value,
ScriptInstance script)
extracts a callable Function from the passed in Scalar. |
static Scalar |
getHashScalar()
returns an empty hashmap scalar |
static Scalar |
getHashScalar(ScalarHash value)
Creates a scalar with the specified ScalarHash as the value |
static Scalar |
getHashWrapper(Map dataStructure)
An easy way to make your programs data structures available in the script environment. |
static Scalar |
getScalar(boolean x)
if x is true, the value will be 1, if x is false the value will be the empty scalar |
static Scalar |
getScalar(double x)
returns a double scalar with value x |
static Scalar |
getScalar(int x)
returns an int scalar with value x |
static Scalar |
getScalar(long x)
returns a long scalar with value x |
static Scalar |
getScalar(Object x)
returns an object scalar with value x |
static Scalar |
getScalar(Scalar x)
Forces a copy of the value of the passed in scalar to be made. |
static Scalar |
getScalar(String x)
returns a string scalar with value x |
static boolean |
isEmptyScalar(Scalar value)
returns true if the passed in scalar value is equivalent to the empty scalar or null |
static boolean |
isFunctionScalar(Scalar value)
determines if the passed in scalar represents a "function" value |
static Scalar |
runCode(Block code,
ScriptEnvironment env)
"safely" run a snippet of code. |
static Scalar |
runCode(ScriptInstance owner,
Block code)
"safely" run a snippet of code. |
static Scalar |
runCode(ScriptInstance owner,
Block code,
HashMap locals)
"safely" run a snippet of code. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected static ScalarType nullScalar
Constructor Detail |
public SleepUtils()
Method Detail |
public static void addKeyword(String keyword)
public static Scalar runCode(Block code, ScriptEnvironment env)
code
- the block of code we want to executeenv
- the environment to run the code in
public static Scalar runCode(ScriptInstance owner, Block code, HashMap locals)
owner
- the owning script instance of this block of codecode
- the block of code we want to executelocals
- a hashmap containing Scalar objects that should be installed into the local scope. The keys should be Strings representing the $names for each of the Scalar variables.
public static Scalar runCode(ScriptInstance owner, Block code)
owner
- the owning script instance of this block of codecode
- the block of code we want to execute
public static Scalar getArrayWrapper(Collection dataStructure)
public static Scalar getHashWrapper(Map dataStructure)
public static Scalar getHashScalar(ScalarHash value)
public static Scalar getArrayScalar(ScalarArray value)
public static Scalar getArrayScalar()
public static Scalar getEmptyScalar()
public static boolean isEmptyScalar(Scalar value)
public static boolean isFunctionScalar(Scalar value)
public static SleepClosure getFunctionFromScalar(Scalar value, ScriptInstance script)
public static Scalar getHashScalar()
public static Scalar getScalar(int x)
public static Scalar getScalar(double x)
public static Scalar getScalar(Scalar x)
public static Scalar getScalar(long x)
public static Scalar getScalar(String x)
public static Scalar getScalar(Object x)
public static Scalar getScalar(boolean x)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |