|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectsleep.bridges.BridgeUtilities
A bridge is a class that bridges your applications API and sleep. Bridges are created using interfaces from the sleep.interfaces package. Arguments are passed to bridges generally in a java.util.Stack form. The Stack of arguments contains sleep Scalar objects. The BridgeUtilities makes it safer and easier for you to extract Java types from arguments.
// some code to execute an internal add function, not a complete example public class MyAddFunction implements Function { public Scalar evaluate(String name, ScriptInstance script, Stack arguments) { if (name.equals("&add")) { int a = BridgeUtilities.getInt(arguments, 0); int b = BridgeUtilities.getInt(arguments, 0); return SleepUtils.getScalar(a + b); } return SleepUtils.getEmptyScalar(); } }
Constructor Summary | |
BridgeUtilities()
|
Method Summary | |
static ScalarArray |
getArray(Stack arguments)
grab a sleep array, if the stack is empty a scalar array with no elements will be returned. |
static double |
getDouble(Stack arguments)
grab a double. |
static double |
getDouble(Stack arguments,
double defaultValue)
grab a double, if the stack is empty the default value will be returned |
static File |
getFile(Stack arguments)
returns a File object from a string argument, the path in the string argument is transformed such that the character / will refer to the correct path separator for the current OS. |
static SleepClosure |
getFunction(Stack arguments,
ScriptInstance script)
retrieves an executable Function object from the stack. |
static ScalarHash |
getHash(Stack arguments)
grab a sleep hash, if the stack is empty a scalar hash with no members will be returned. |
static int |
getInt(Stack arguments)
grab an integer. |
static int |
getInt(Stack arguments,
int defaultValue)
grab an integer, if the stack is empty the default value will be returned |
static KeyValuePair |
getKeyValuePair(Stack arguments)
Pops a Key/Value pair object off of the argument stack. |
static long |
getLong(Stack arguments)
grab a long. |
static long |
getLong(Stack arguments,
long defaultValue)
grab a long, if the stack is empty the default value will be returned |
static Object |
getObject(Stack arguments)
grab an object, if the stack is empty then null will be returned. |
static Scalar |
getScalar(Stack arguments)
grab a scalar, if the stack is empty the empty/null scalar will be returned. |
static String |
getString(Stack arguments,
String defaultValue)
grab a string, if the stack is empty or if the value is null the default value will be returned. |
static ScalarArray |
getWorkableArray(Stack arguments)
grab a sleep array, if the stack is empty a scalar array with no elements will be returned. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public BridgeUtilities()
Method Detail |
public static int getInt(Stack arguments)
public static int getInt(Stack arguments, int defaultValue)
public static long getLong(Stack arguments)
public static long getLong(Stack arguments, long defaultValue)
public static double getDouble(Stack arguments)
public static double getDouble(Stack arguments, double defaultValue)
public static ScalarArray getArray(Stack arguments)
public static ScalarHash getHash(Stack arguments)
public static ScalarArray getWorkableArray(Stack arguments)
public static Object getObject(Stack arguments)
public static SleepClosure getFunction(Stack arguments, ScriptInstance script)
public static Scalar getScalar(Stack arguments)
public static String getString(Stack arguments, String defaultValue)
public static File getFile(Stack arguments)
public static KeyValuePair getKeyValuePair(Stack arguments)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |