| java.lang.Object pnuts.lang.Configuration
All known Subclasses: pnuts.lang.JavaBeansConfiguration, pnuts.ext.ConfigurationAdapter,
Configuration | abstract public class Configuration implements Serializable(Code) | | This class defines the interface of runtime configuration, such as how to
find method/field candidates, how to get the field value, how to get indexed
elements, and so on.
|
Method Summary | |
synchronized Constructor[] | _getConstructors(Class cls) | synchronized Method[] | _getMethods(Class cls, String name) | abstract public Object | callConstructor(Context context, Class c, Object[] args, Class[] types) | abstract public Object | callMethod(Context context, Class c, String name, Object args, Class types, Object target) | public List | createList() | public Map | createMap(int size, Context context) Create a new Map object that corresponds to {key=>value} expression. | public String | formatObject(Object obj) Defines how objects are printed in the interactive shell. | abstract public Constructor[] | getConstructors(Class cls) Get all public constructors of the specified class. | public static Configuration | getDefault() Returns the default Configuration object. | static Configuration | getDefault(Properties properties) | protected String[] | getDefaultImports() | abstract public Object | getElement(Context context, Object target, Object key) | abstract public Object | getField(Context context, Object target, String name) Gets a field value of the target object. | protected ClassLoader | getInitialClassLoader() | static Configuration | getInstance(String className) | abstract public Method[] | getMethods(Class cls) Get all public methods of the specified class. | abstract public Object | getRange(Context context, Object target, Object idx1, Object idx2) Defines the semantices of an expression like:
target[idx1..idx2]
Parameters: context - the context Parameters: target - the target object Parameters: idx1 - the start index Parameters: idx2 - the end index. | abstract public Object | getStaticField(Context context, Class clazz, String name) Get the value of a static field. | public Object | handleUndefinedSymbol(String symbol, Context context) Handle an "not.defined" error
This method can be redefined by a subclass so that a special value (e.g. | protected void | initializeOperators() | protected static Object | invokeMethod(Context context, Class c, String name, Object args, Class types, Object target) | BigDecimal | longToBigDecimal(long lval) | public Object | makeArray(Object[] parameters, Context context) Return the value of an array expression. | abstract public void | putField(Context context, Object target, String name, Object value) Sets a field value of the specified object. | abstract public void | putStaticField(Context context, Class clazz, String name, Object value) Sets a value to the static field of the specified class. | Object | reInvoke(IllegalAccessException t, Method method, Object target, Object[] args) | void | replace(StringBuffer buf, int start, int end, String str) | abstract public void | setElement(Context context, Object target, Object key, Object value) | abstract public Object | setRange(Context context, Object target, Object idx1, Object idx2, Object value) Defines the semantices of an expression like:
target[idx1..idx2] = value
Parameters: context - the context in which the assignment is done Parameters: target - the target object Parameters: idx1 - the start index Parameters: idx2 - the end index. | abstract public Callable | toCallable(Object obj) Convert an object to Callable. | abstract public Enumeration | toEnumeration(Object obj) Convert an object to Enumeration. |
normalConfiguration | final protected static Configuration normalConfiguration(Code) | | The normal configuration, which is the fall-back of the default
configuration.
|
serialVersionUID | final static long serialVersionUID(Code) | | |
Configuration | public Configuration()(Code) | | |
callConstructor | abstract public Object callConstructor(Context context, Class c, Object[] args, Class[] types)(Code) | | Calls a constructor
Parameters: context - the context Parameters: c - class of the constructor Parameters: args - the arguments Parameters: types - type information of each arguments the result |
callMethod | abstract public Object callMethod(Context context, Class c, String name, Object args, Class types, Object target)(Code) | | Calls a method
Parameters: context - the contexct Parameters: c - the class of the method Parameters: name - the name of the method Parameters: args - arguments Parameters: types - type information of each arguments Parameters: target - the target object of the method call the result of the method call |
createMap | public Map createMap(int size, Context context)(Code) | | Create a new Map object that corresponds to {key=>value} expression.
Parameters: size - the map size a new Map object |
formatObject | public String formatObject(Object obj)(Code) | | Defines how objects are printed in the interactive shell.
Parameters: obj - the target object to print the string representation of the target object |
getConstructors | abstract public Constructor[] getConstructors(Class cls)(Code) | | Get all public constructors of the specified class.
Parameters: cls - the class an array of Constructor objects |
getDefault | public static Configuration getDefault()(Code) | | Returns the default Configuration object.
the current default configuration |
getDefaultImports | protected String[] getDefaultImports()(Code) | | Subclasses may redefines default imports
an array of imported classes, package, or statics |
getElement | abstract public Object getElement(Context context, Object target, Object key)(Code) | | Gets an array element
Parameters: context - the context Parameters: target - the target object (an array) Parameters: key - the key or the index of the element the value of the element |
getField | abstract public Object getField(Context context, Object target, String name)(Code) | | Gets a field value of the target object.
Parameters: context - the context in which the field is read Parameters: target - the target object Parameters: name - the field name the field value |
getMethods | abstract public Method[] getMethods(Class cls)(Code) | | Get all public methods of the specified class.
Parameters: cls - the class an array of Method objects |
getRange | abstract public Object getRange(Context context, Object target, Object idx1, Object idx2)(Code) | | Defines the semantices of an expression like:
target[idx1..idx2]
Parameters: context - the context Parameters: target - the target object Parameters: idx1 - the start index Parameters: idx2 - the end index. null in idx2 means open-ended. the result |
getStaticField | abstract public 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 |
handleUndefinedSymbol | public Object handleUndefinedSymbol(String symbol, Context context)(Code) | | Handle an "not.defined" error
This method can be redefined by a subclass so that a special value (e.g.
null) is returned when undefined symbol is referenced.
Parameters: symbol - the undefined symbol Parameters: context - the context in which the symbol is referenced the value to be returned |
initializeOperators | protected void initializeOperators()(Code) | | |
makeArray | public Object makeArray(Object[] parameters, Context context)(Code) | | Return the value of an array expression. e.g. [a,b,c] {1,2,3}
This method can be redefined by a subclass so that array expression
returns different type of object, such as java.util.List.
Parameters: parameters - the elements in the array expression the value of the array expression |
putField | abstract public void putField(Context context, Object target, String name, Object value)(Code) | | Sets a field value of the specified object.
Parameters: context - the context in which the field is written. Parameters: target - the target object Parameters: name - the field name Parameters: value - the field value |
putStaticField | abstract public void putStaticField(Context context, Class clazz, String name, Object value)(Code) | | Sets a value to the static field of the specified class.
Parameters: context - the context in which the field is written. Parameters: clazz - the class in which the static field is defined Parameters: name - the field name Parameters: value - the field value |
setElement | abstract public void setElement(Context context, Object target, Object key, Object value)(Code) | | Sets an element
Parameters: context - the context Parameters: target - the target object (an array) Parameters: key - the key or the index of the element Parameters: value - the new value of the element |
setRange | abstract public Object setRange(Context context, Object target, Object idx1, Object idx2, Object value)(Code) | | Defines the semantices of an expression like:
target[idx1..idx2] = value
Parameters: context - the context in which the assignment is done Parameters: target - the target object Parameters: idx1 - the start index Parameters: idx2 - the end index. null in idx2 means open-ended. Parameters: value - the new value of the indexed element the result |
toCallable | abstract public Callable toCallable(Object obj)(Code) | | Convert an object to Callable. This method is used by call expression, e.g. obj(arg1, ...).
Subclasses can override this method to register custom callable objects.
|
toEnumeration | abstract public Enumeration toEnumeration(Object obj)(Code) | | Convert an object to Enumeration. This method is used by foreach
statements. Subclasses can override this method to customize the behavior
of foreach statements.
|
|
|