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 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
static int
ARG_MATCH_NO
when looking for a Java method that matches the sleep args, we immediately drop all of the no answers.
static int
ARG_MATCH_YES
when looking for a Java method that matches the sleep args, we use a Yes match immediately
static Class
BOOLEAN_TYPE
various primitives...
static Class
BYTE_TYPE
various primitives...
static Class
CHARACTER_TYPE
various primitives...
static Class
DOUBLE_TYPE
various primitives...
static Class
FLOAT_TYPE
various primitives...
static Class
INTEGER_TYPE
various primitives...
static Class
LONG_TYPE
various primitives...
static Class
OBJECT_TYPE
various primitives...
static Class
STRING_TYPE
various primitives...

Method Summary

static Object
BuildInterface(Class className, Function subroutine, ScriptInstance script)
static Scalar
BuildScalar(boolean primitives, Object value)
static Object
buildArgument(Class type, Scalar value, ScriptInstance script)
static Object[]
buildArgumentArray(Class[] types, Stack arguments, ScriptInstance script)
static String
buildArgumentErrorMessage(Class theClass, String method, Class[] expected, Object[] parameters)
static Class
convertDescriptionToClass(String description)
converts the one character class description to the specified Class type, i.e.
static Constructor
findConstructor(Class theClass, Stack arguments)
static Method
findMethod(Class theClass, String method, Stack arguments)
static Class
getArrayType(Scalar value, Class defaultc)
Determines the primitive type of the specified array.
static int
isArgMatch(Class check, Scalar scalar)
determined if the specified scalar can be rightfully cast to the specified class
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

Field Details

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
Field Value:
1

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.
Field Value:
0

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
Field Value:
3

BOOLEAN_TYPE

public static Class BOOLEAN_TYPE
various primitives... doo doo doo

BYTE_TYPE

public static Class BYTE_TYPE
various primitives... doo doo doo

CHARACTER_TYPE

public static Class CHARACTER_TYPE
various primitives... doo doo doo

DOUBLE_TYPE

public static Class DOUBLE_TYPE
various primitives... doo doo doo

FLOAT_TYPE

public static Class FLOAT_TYPE
various primitives... doo doo doo

INTEGER_TYPE

public static Class INTEGER_TYPE
various primitives... doo doo doo

LONG_TYPE

public static Class LONG_TYPE
various primitives... doo doo doo

OBJECT_TYPE

public static Class OBJECT_TYPE
various primitives... doo doo doo

STRING_TYPE

public static Class STRING_TYPE
various primitives... doo doo doo

Method Details

BuildInterface

public static Object BuildInterface(Class className,
                                    Function subroutine,
                                    ScriptInstance script)

BuildScalar

public static Scalar BuildScalar(boolean primitives,
                                 Object value)

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)

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..

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()

isArgMatch

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

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