| java.lang.Object pnuts.lang.Runtime
All known Subclasses: pnuts.lang.PnutsInterpreter, pnuts.lang.SimpleFunctionSerializer, pnuts.lang.DefaultFunctionSerializer, pnuts.lang.Function, pnuts.lang.PnutsFunction, pnuts.lang.PnutsImpl,
Runtime | public class Runtime implements Executable(Code) | | This class provides runtime supports for Pnuts compiler/interpreter. Most of
the methods are protected static, so that only subclasses can access them.
|
Inner Class :protected static class TypeMap | |
Inner Class :protected static class Accessor | |
Inner Class :static class BeanInfoParam | |
Inner Class :static class RangeGenerator extends Generator | |
Inner Class :static class ThreadLocalContext extends ThreadLocal | |
Inner Class :public static interface FunctionSerializer | |
Constructor Summary | |
protected | Runtime() |
Method Summary | |
protected Object | _callConstructor(Context context, Class c, Object args, Class types) | protected Object | _callMethod(Context context, Class c, String name, Object args, Class types, Object target) | protected Object | _getField(Context context, Class c, String name, Object target) | protected void | _putField(Context context, Class cls, String name, Object target, Object value) | final public static Object | add(Object n1, Object n2) | final protected static Object | add(Object n1, Object n2, Context context) | final public static Object | add1(Object n) | final protected static Object | add1(Object n, Context context) | public static void | addImport(Context context, String name) | public static void | addStaticMembers(Context context, String name, boolean wildcard) | final public static Object | and(Object n1, Object n2) | final protected static Object | and(Object n1, Object n2, Context context) | public static Object | applyGenerator(Generator g, PnutsFunction closure, Context context) | public static Class | arrayType(Class c, int dim) | protected static int | arraydim(Object o) | final public static Object | call(Context context, Object target, Object[] args, Class[] casts) | final public static Object | call(Context context, Object target, Object[] args, Class[] casts, int line, int column) | public static Object | callConstructor(Context context, Class c, Object args, Class types) | final protected static Object | callFunction(Context context, PnutsFunction func, Object[] args) | public static Object | callMethod(Context context, Class c, String name, Object args, Class types, Object target) | public static Object | cast(Context context, Class type, Object object, boolean flag) | protected static void | catchException(Class type, PnutsFunction func, Context context) | protected static void | checkException(Context context, Throwable throwable) | protected static void | checkException(Context context, Throwable throwable, TypeMap tmap) Check if any exception handler is registered to the specified exception.
If any an exception handler is executed. | static int | compareArrays(Object a1, Object a2) | static int | compareListToArray(List ol, Object array) | static int | compareLists(List ol1, List ol2) | public static int | compareObjects(Object e1, Object e2) Compare two objects
Elements of List and array are recursively compared. | final public static int | compareTo(Object n1, Object n2) | final protected static int | compareTo(Object n1, Object n2, Context context) | static Number | compress(Number n) | public static Cache | createCache() | protected static List | createList(Context context) | protected static Map | createMap(int size, Context context) | public static Map | createWeakMap() | static Number | decimalNumber(String s, int radix) | protected static PnutsFunction | defineTopLevelFunction(Function f, String symbol, Package pkg, Context context) | protected static PnutsFunction | defineUnboundFunction(Function f, String symbol, Package pkg) | static void | deserializePnutsFunction(PnutsFunction pnutsFunction, ObjectInputStream s) | final public static Object | divide(Object n1, Object n2) | final protected static Object | divide(Object n1, Object n2, Context context) | final public static boolean | eq(Object n1, Object n2) | final protected static boolean | eq(Object n1, Object n2, Context context) | protected static void | escape(Object v) | protected Object | exec(Context context) This method is overrided by classes generated by the compiler. | public Object | execute(Context context) Executes a compiled script. | public static URL | fileToURL(File file) | protected static Method | findCallableMethod(Class clazz, String name, Class args) | public static String | format(Object object, int maxArrayLength) Get the String representation of the specified object. | public static String | format(Object object, int maxArrayLength, int maxFormatSize) | public static String | format(Object object, int maxArrayLength, int maxFormatSize, char[] paren) | static void | format(Object object, int maxArrayLength, int maxFormatSize, char[] paren, Set formattedObjects, StringBuffer sb) | static void | formatElement(Object obj, int maxArrayLength, int maxFormatSize, char[] paren, Set formattedObjects, StringBuffer sb) | final public static boolean | ge(Object n1, Object n2) | final protected static boolean | ge(Object n1, Object n2, Context context) | final public static int | getArrayLength(Object array) | public static Object | getBeanProperty(Context context, Object target, String name) Gets a Bean property of the specified bean. | public Object | getBeanProperty(Object target, String name) Gets a Bean property of the specified bean. | protected Object | getBeanProperty(Object target, String name, Class stopClass) Gets a Bean property of the specified bean. | public Class | getBeanPropertyType(Class cls, String name) | protected static int | getBeginColumn(Context context) | protected static int | getBeginLine(Context context) | public static boolean | getBoolean(String key) | public static Class | getBottomType(Class clazz) Get true component type from an array type. | static String | getClassName(Class cls) | public static Executable | getCompiledScript(String name, Context context) This method is called by Pnuts.load() when the property
"pnuts.compiled.script.prefix" is defined, to load pre-compiled scripts.
Parameters: name - the script name Parameters: context - the context in which the class is loaded. | protected static Constructor[] | getConstructors(Context context, Class cls) | static ImportEnv | getDefaultImports(Context context) | public static Runtime | getDefaultRuntime() | public static Object | getElement(Object target, Object key, Context context) | public static Object | getElementAt(Object target, int idx, Context context) | protected static int | getEndLine(Context context) | public static Object | getField(Context context, Object target, String name) Get the value of a instance field. | protected Field | getField(Class cls, String name) | protected static Function | getFunction(PnutsFunction pf, int nargs) | protected static Function | getFunction(Context context) | protected static Enumeration | getFunctions(PnutsFunction pf) | protected static String | getMessage(String bundleName, String key, Object a) | protected static Method[] | getMethods(Context context, Class cls) | public static String | getProperty(String key) | public static Object | getRange(Object target, Object idx1, Object idx2, Context context) Range expression 'target[idx1..idx2]'.
the intersection of the whole range of the target object and therange [idx1..idx2]. | protected static Runtime | getRuntime(Context context) | public static Reader | getScriptReader(InputStream in, Context context) Gets a Reader to read script files
If context.getScriptEncoding() is non-null, it would be used as the
encoding. | protected static Object | getScriptSource(Context context) | public static URL | getScriptURL(String name, Context context) | public static Object | getStaticField(Context context, Class clazz, String name) Get the value of a static field. | public static Context | getThreadContext() | final public static boolean | gt(Object n1, Object n2) | final protected static boolean | gt(Object n1, Object n2, Context context) | final public static boolean | isArray(Object obj) | public static boolean | isGenerator(SimpleNode node) | protected static void | jump(Object v) | final public static boolean | le(Object n1, Object n2) | final protected static boolean | le(Object n1, Object n2, Context context) | public static SimpleNode | loadNode(String str) | static Object | lookupTopLevelValue(String symbol, Context context) | final public static boolean | lt(Object n1, Object n2) | final protected static boolean | lt(Object n1, Object n2, Context context) | protected static Object | makeArray(Object[] parameters, Context context) | protected static int | matchType(Class type, Object obj) | final public static Object | mod(Object n1, Object n2) | final protected static Object | mod(Object n1, Object n2, Context context) | final public static Object | multiply(Object n1, Object n2) | final protected static Object | multiply(Object n1, Object n2, Context context) | final public static boolean | ne(Object n1, Object n2) | final protected static boolean | ne(Object n1, Object n2, Context context) | final public static Object | negate(Object n) | final protected static Object | negate(Object n, Context context) | protected static Object | newInstance(Context context, Class c, Object[] args, Class[] casts) | final public static Object | not(Object n) | final protected static Object | not(Object n, Context context) | final public static Object | or(Object n1, Object n2) | final protected static Object | or(Object n1, Object n2, Context context) | public static Character | parseChar(String str) Parse a character literal. | public static Object[] | parseFloat(String str) Parse a floating point number. | public static Object[] | parseInt(String str) Parse an integer. | static Object[] | parseInt(String str, int radix, boolean shrink) | public static String | parseString(String str, int offset) Parse a string literal. | public static Object | primitive(Context context, Class primitiveType, Object param, boolean flag) | static Object | primitive(Class primitiveType, Object param, boolean flag, int radix) | public static void | printError(Throwable t, Context context) | public static void | putField(Context context, Object target, String name, Object expr) Assign an object to a instance field. | public static void | putStaticField(Context context, Class clazz, String name, Object expr) Assign an object to a static field. | public static Object | quantity(Number number, String numberString, String unit, Context context) | static void | recoverParseError(PnutsParser parser, int tokenType) | public static String | replaceChar(String str, Number n, Object expr) | public Object | run(Context context) Executes a compiled script. | public static String | saveNode(SimpleNode node) | static void | serializePnutsFunction(PnutsFunction pnutsFunction, ObjectOutputStream s) | public static void | setBeanProperty(Context context, Object target, String name, Object value) Sets a Bean property of the specified bean. | public void | setBeanProperty(Object target, String name, Object value) Sets a Bean property of the specified bean. | protected void | setBeanProperty(Object target, String name, Object value, Class stopClass) Sets a Bean property of the specified bean. | public static void | setElement(Object target, Object key, Object value, Context context) | public static void | setExitHook(Context context, PnutsFunction func) | protected static void | setLine(Context context, int beginLine, int beginColumn) | public static void | setLine(Context context, int line) | protected static void | setPackage(Package pkg, Context context) | public static Object | setRange(Object target, Object idx1, Object idx2, Object expr, Context context) | public static void | setThreadContext(Context context) | protected static void | setupPropertyChangeListeners(Map table, Context context) | public static Object | shiftArithmetic(Object n1, Object n2) | final protected static Object | shiftArithmetic(Object n1, Object n2, Context context) | final public static Object | shiftLeft(Object n1, Object n2) | final protected static Object | shiftLeft(Object n1, Object n2, Context context) | final public static Object | shiftRight(Object n1, Object n2) | final protected static Object | shiftRight(Object n1, Object n2, Context context) | final public static Object | subtract(Object n1, Object n2) | final protected static Object | subtract(Object n1, Object n2, Context context) | final public static Object | subtract1(Object n) | final protected static Object | subtract1(Object n, Context context) | public static void | throwException(Object arg, Context context) | public static Boolean | toBoolean(Object param) | public static Enumeration | toEnumeration(Object target, Context context) | protected static SimpleNode | toFunctionNode(SimpleNode body) | public static Object | transform(Class type, Object obj) | public static Object | transform(Class type, Object obj, Context context) | public static String | unparse(SimpleNode node, Context context) | protected static void | watchProperty(Map table, Object obj, String property, Object memberTarget, String memberName, Callable rhs) | final public static Object | xor(Object n1, Object n2) | final protected static Object | xor(Object n1, Object n2, Context context) |
BOOLEAN_SYMBOL | final protected static String BOOLEAN_SYMBOL(Code) | | |
DOUBLE_SYMBOL | final protected static String DOUBLE_SYMBOL(Code) | | |
EXCEPTOIN_FIELD_SYMBOL | final protected static String EXCEPTOIN_FIELD_SYMBOL(Code) | | |
FLOAT_SYMBOL | final protected static String FLOAT_SYMBOL(Code) | | |
SHORT_SYMBOL | final protected static String SHORT_SYMBOL(Code) | | |
functionSerializer | static FunctionSerializer functionSerializer(Code) | | |
Runtime | protected Runtime()(Code) | | |
_callConstructor | protected Object _callConstructor(Context context, Class c, Object args, Class types)(Code) | | Call a constructor
Parameters: context - the context in which the constructor is called Parameters: c - the class of method Parameters: args - the paramters Parameters: types - the types of the formal arguments the created instance |
_callMethod | protected Object _callMethod(Context context, Class c, String name, Object args, Class types, Object target)(Code) | | Call a method
Parameters: context - the context Parameters: c - the class of method Parameters: name - the method name Parameters: args - the paramters Parameters: types - the types of the formal arguments Parameters: target - the target object the return value |
addStaticMembers | public static void addStaticMembers(Context context, String name, boolean wildcard)(Code) | | |
arrayType | public static Class arrayType(Class c, int dim)(Code) | | Creates an array type
Parameters: c - the component type Parameters: dim - the number of dimensions |
callConstructor | public static Object callConstructor(Context context, Class c, Object args, Class types)(Code) | | Call a constructor
Parameters: context - the context in which the constructor is called Parameters: c - the class of method Parameters: args - the paramters Parameters: types - the types of the formal arguments the created instance |
callFunction | final protected static Object callFunction(Context context, PnutsFunction func, Object[] args)(Code) | | Call a function
Parameters: context - the context in which the function is called Parameters: func - the function to be called Parameters: args - the arguments |
callMethod | public static Object callMethod(Context context, Class c, String name, Object args, Class types, Object target)(Code) | | Call a method
Parameters: context - the context in which the method is called Parameters: c - the class of method Parameters: name - the method name Parameters: args - the paramters Parameters: types - the types of the paramters Parameters: target - the target object the return value of the call |
cast | public static Object cast(Context context, Class type, Object object, boolean flag)(Code) | | This method is called by the syntax "(Class)object"
Parameters: context - the context Parameters: type - the type Parameters: flag - object_array <->primitive_array conversion |
catchException | protected static void catchException(Class type, PnutsFunction func, Context context)(Code) | | This method is called when catch() function is called in a
package(non-local) scope
Parameters: type - the exception type of which an exception handler is registered Parameters: func - the function to be registered as an exception handler Parameters: context - the context in which the exception handler is registered |
checkException | protected static void checkException(Context context, Throwable throwable, TypeMap tmap)(Code) | | Check if any exception handler is registered to the specified exception.
If any an exception handler is executed. If not, the exception is thrown.
Parameters: context - the Context in which the exception is checked Parameters: throwable - the exception Parameters: tmap - the exception handler table |
compareObjects | public static int compareObjects(Object e1, Object e2)(Code) | | Compare two objects
Elements of List and array are recursively compared.
|
compareTo | final public static int compareTo(Object n1, Object n2)(Code) | | Compares n1 with n2
|
createWeakMap | public static Map createWeakMap()(Code) | | |
exec | protected Object exec(Context context)(Code) | | This method is overrided by classes generated by the compiler.
Parameters: context - the context in which this object is executed the result of the execution |
execute | public Object execute(Context context)(Code) | | Executes a compiled script. Exceptions are checked if an exception
handler is registered with the catch() function. Output stream of the
specified context is flushed after the script is executed or an exception
is thrown.
Parameters: context - the context in which this object is executed the result of the execution |
fileToURL | public static URL fileToURL(File file) throws IOException(Code) | | Gets a URL from a File
Parameters: file - the File object the resulting URL object |
format | public static String format(Object object, int maxArrayLength)(Code) | | Get the String representation of the specified object.
Parameters: object - the target object. Parameters: maxArrayLength - When the target object is an array and maxArrayLength isgreater than zero, only the first maxArrayLength elements areprinted and the rest of the elements are omitted as "...". |
format | public static String format(Object object, int maxArrayLength, int maxFormatSize)(Code) | | |
format | public static String format(Object object, int maxArrayLength, int maxFormatSize, char[] paren)(Code) | | |
format | static void format(Object object, int maxArrayLength, int maxFormatSize, char[] paren, Set formattedObjects, StringBuffer sb)(Code) | | |
formatElement | static void formatElement(Object obj, int maxArrayLength, int maxFormatSize, char[] paren, Set formattedObjects, StringBuffer sb)(Code) | | |
getArrayLength | final public static int getArrayLength(Object array)(Code) | | Gets an array's length
Parameters: array - the array the length |
getBeanProperty | public static Object getBeanProperty(Context context, Object target, String name)(Code) | | Gets a Bean property of the specified bean.
Parameters: context - the context Parameters: target - the target bean Parameters: name - the Bean property name |
getBeanPropertyType | public Class getBeanPropertyType(Class cls, String name)(Code) | | Gets the type of a bean property
Parameters: cls - the class of the bean Parameters: name - the property name of the bean property the type of the property |
getBeginColumn | protected static int getBeginColumn(Context context)(Code) | | |
getBeginLine | protected static int getBeginLine(Context context)(Code) | | |
getBoolean | public static boolean getBoolean(String key)(Code) | | |
getBottomType | public static Class getBottomType(Class clazz)(Code) | | Get true component type from an array type. e.g. int[][] ==> int,
String[] ==> String
Parameters: clazz - An array type to be examined The component type of the array type. |
getCompiledScript | public static Executable getCompiledScript(String name, Context context)(Code) | | This method is called by Pnuts.load() when the property
"pnuts.compiled.script.prefix" is defined, to load pre-compiled scripts.
Parameters: name - the script name Parameters: context - the context in which the class is loaded. pnuts.lang.Runtime object if the class is found, otherwise null. |
getField | public static Object getField(Context context, Object target, String name)(Code) | | Get the value of a instance field.
Parameters: context - the context in which the field is accessed Parameters: target - the target object of the field Parameters: name - the name of the field the value |
getRange | public static Object getRange(Object target, Object idx1, Object idx2, Context context)(Code) | | Range expression 'target[idx1..idx2]'.
the intersection of the whole range of the target object and therange [idx1..idx2]. This method never throwArrayIndexOutOfBoundsException. |
getScriptReader | public static Reader getScriptReader(InputStream in, Context context)(Code) | | Gets a Reader to read script files
If context.getScriptEncoding() is non-null, it would be used as the
encoding. Otherwise, the platform encoding is used.
Parameters: in - the input stream Parameters: context - the executing context the resulting reader object |
getStaticField | public static Object getStaticField(Context context, Class clazz, String name)(Code) | | Get the value of a static field.
Parameters: context - the context in which the field is accessed Parameters: clazz - the class in which the static field is defined Parameters: name - the name of the static field the value |
getThreadContext | public static Context getThreadContext()(Code) | | Sets the context bound to the current thread
the context |
isArray | final public static boolean isArray(Object obj)(Code) | | Check if the parameter is an array
Parameters: obj - the object to be checked true if the obj is an array, false otherwise. |
parseFloat | public static Object[] parseFloat(String str)(Code) | | Parse a floating point number.
an array [Number number, int offset_of_unit_symbol] |
primitive | public static Object primitive(Context context, Class primitiveType, Object param, boolean flag)(Code) | | This method is called by the syntax "primitiveType(object)" and
"(primitiveType)object"
Parameters: context - the context Parameters: primitiveType - a primitive type Parameters: param - the parameter Parameters: flag - string <->number conversion |
putField | public static void putField(Context context, Object target, String name, Object expr)(Code) | | Assign an object to a instance field.
Parameters: context - the context in which the field is accessed Parameters: target - the target object of the field Parameters: name - the name of the field Parameters: expr - the value to be assigned |
putStaticField | public static void putStaticField(Context context, Class clazz, String name, Object expr)(Code) | | Assign an object to a static field.
Parameters: context - the context in which the field is accessed Parameters: clazz - the class in which the static field is defined Parameters: name - the name of the static field Parameters: expr - the value to be assigned |
quantity | public static Object quantity(Number number, String numberString, String unit, Context context)(Code) | | Creates an object from a number literal and a unit symbol
Parameters: number - a number object Parameters: numberString - a symbol of the number literal Parameters: unit - a unit symbol Parameters: context - a context in which the quantity is created |
recoverParseError | static void recoverParseError(PnutsParser parser, int tokenType)(Code) | | |
run | public Object run(Context context)(Code) | | Executes a compiled script. Exceptions are checked if an exception
handler is registered with the catch() function. Output stream of the
specified context is flushed after the script is executed or an exception
is thrown.
Parameters: context - the context in which this object is executed the result of the execution |
setBeanProperty | public static void setBeanProperty(Context context, Object target, String name, Object value)(Code) | | Sets a Bean property of the specified bean.
Parameters: context - the context Parameters: target - the target bean Parameters: name - the Bean property name Parameters: value - the value of the Bean property |
setBeanProperty | protected void setBeanProperty(Object target, String name, Object value, Class stopClass) throws IllegalAccessException, InvocationTargetException(Code) | | Sets a Bean property of the specified bean.
Parameters: target - the target bean Parameters: name - the Bean property name Parameters: value - the new property value Parameters: stopClass - the Introspector's "stopClass" |
setElement | public static void setElement(Object target, Object key, Object value, Context context)(Code) | | This method is called by the syntax "target[key] = value"
|
setLine | protected static void setLine(Context context, int beginLine, int beginColumn)(Code) | | Set line number information for error reporting
|
setLine | public static void setLine(Context context, int line)(Code) | | |
setThreadContext | public static void setThreadContext(Context context)(Code) | | Gets the context bound to the current thread
Parameters: context - the context |
setupPropertyChangeListeners | protected static void setupPropertyChangeListeners(Map table, Context context)(Code) | | public static String unparseNode(SimpleNode node){
StringBuffer sbuf = new StringBuffer();
node.accept(new org.pnuts.lang.UnparseVisitor(sbuf), null);
return sbuf.toString();
}
|
subtract1 | final public static Object subtract1(Object n)(Code) | | Subtracts 1 from a object (integer)
|
toBoolean | public static Boolean toBoolean(Object param)(Code) | | Convert a given object to a boolean value
|
|
|