sleep.engine

Class ObjectUtilities

public class ObjectUtilities extends Object

This class is sort of the center of the HOES universe containing several methods for mapping between Sleep and Java and resolving which mappings make sense.
Field Summary
static intARG_MATCH_MAYBE
when looking for a Java method that matches the sleep args, we save the maybes and use them as a last resort if no yes match is found
static intARG_MATCH_NO
when looking for a Java method that matches the sleep args, we immediately drop all of the no answers.
static intARG_MATCH_YES
when looking for a Java method that matches the sleep args, we use a Yes match immediately
Method Summary
static ObjectbuildArgument(Class type, Scalar value, ScriptInstance script)
static Object[]buildArgumentArray(Class[] types, Stack arguments, ScriptInstance script)
static StringbuildArgumentErrorMessage(Class theClass, String method, Class[] expected, Object[] parameters)
static ScalarBuildScalar(boolean primitives, Object value)
static ClassconvertDescriptionToClass(String description)
converts the one character class description to the specified Class type, i.e. z = boolean, c = char, b = byte, i = integer, etc..
static ClassconvertScalarDescriptionToClass(Scalar description)
this function checks if the specified scalar is a Class literal and uses that if it is, otherwise description is converted to a string and the convertDescriptionToClass method is used
static ConstructorfindConstructor(Class theClass, Stack arguments)
static MethodfindMethod(Class theClass, String method, Stack arguments)
static ClassgetArrayType(Scalar value, Class defaultc)
Determines the primitive type of the specified array.
static voidhandleExceptionFromJava(Throwable ex, ScriptEnvironment env, String description, int lineNumber)
Standard method to handle a Java exception from a HOES call.
static intisArgMatch(Class[] check, Stack arguments)
convienence method to determine wether or not the stack of values is a safe match for the specified method signature
static intisArgMatch(Class check, Scalar scalar)
determined if the specified scalar can be rightfully cast to the specified class

Field Detail

ARG_MATCH_MAYBE

public static final int ARG_MATCH_MAYBE
when looking for a Java method that matches the sleep args, we save the maybes and use them as a last resort if no yes match is found

ARG_MATCH_NO

public static final int ARG_MATCH_NO
when looking for a Java method that matches the sleep args, we immediately drop all of the no answers.

ARG_MATCH_YES

public static final int ARG_MATCH_YES
when looking for a Java method that matches the sleep args, we use a Yes match immediately

Method Detail

buildArgument

public static Object buildArgument(Class type, Scalar value, ScriptInstance script)

buildArgumentArray

public static Object[] buildArgumentArray(Class[] types, Stack arguments, ScriptInstance script)

buildArgumentErrorMessage

public static String buildArgumentErrorMessage(Class theClass, String method, Class[] expected, Object[] parameters)

BuildScalar

public static Scalar BuildScalar(boolean primitives, Object value)

convertDescriptionToClass

public static Class convertDescriptionToClass(String description)
converts the one character class description to the specified Class type, i.e. z = boolean, c = char, b = byte, i = integer, etc..

convertScalarDescriptionToClass

public static Class convertScalarDescriptionToClass(Scalar description)
this function checks if the specified scalar is a Class literal and uses that if it is, otherwise description is converted to a string and the convertDescriptionToClass method is used

findConstructor

public static Constructor findConstructor(Class theClass, Stack arguments)

findMethod

public static Method findMethod(Class theClass, String method, Stack arguments)

getArrayType

public static Class getArrayType(Scalar value, Class defaultc)
Determines the primitive type of the specified array. Primitive Sleep values (int, long, double) will return the appropriate Number.TYPE class. This is an important distinction as Double.TYPE != new Double().getClass()

handleExceptionFromJava

public static void handleExceptionFromJava(Throwable ex, ScriptEnvironment env, String description, int lineNumber)
Standard method to handle a Java exception from a HOES call. Basically this places the exception into Sleep's throw mechanism and collects the stack frame.

isArgMatch

public static int isArgMatch(Class[] check, Stack arguments)
convienence method to determine wether or not the stack of values is a safe match for the specified method signature

isArgMatch

public static int isArgMatch(Class check, Scalar scalar)
determined if the specified scalar can be rightfully cast to the specified class