org.hecl.java
Class Reflector
- java.lang.Object
-
- org.hecl.java.Reflector
-
public class Reflector extends java.lang.ObjectTheReflectorclass maps between Java types and Hecl types in order to make it possible to call Java methods from Hecl.
-
-
Constructor Summary
Constructors Constructor and Description Reflector(java.lang.String classname)Creates a newReflectorinstance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description Thingconstructors()Theconstructorsmethod returns a Hecl list of types that would work as constructors for this object type.Thingevaluate(java.lang.Object o, java.lang.String cmd, Thing[] argv)Theevaluatemethod takes a target object to operate on, a methodname, and some Hecl values, and attempts to find and call a Java method with the supplied values.ThinggetConstField(java.lang.String name)getConstFieldfetches a constant field value.ThinggetField(java.lang.Object target, java.lang.String name)ThegetFieldmethod returns the value of an instance's field.booleanheclTypeToJavaType(java.lang.Object[] retval, java.lang.Class rtype, Thing heclparm)TheheclTypeToJavaTypemethod takes a Class and a Hecl Thing, turns the Thing into an Object based on the Class type, and returns the Object.Thinginstantiate(Thing[] argv)Theinstantiatemethod is called to create an instance of a class (new, in other words).ThingjavaTypeToHeclType(java.lang.Class rtype, java.lang.Object o)ThejavaTypeToHeclTypemethod takes a Java type, and a Java Object, and returns a Thing.Thingmethods()Themethodsmethod returns a Hecl list of method signatures in the form methodName type type type.voidsetField(java.lang.Object target, java.lang.String name, Thing newvalue)ThesetFieldmethod takes an object, a field name, and a new Thing value, and sets the object's field to the value of Thing.
-
-
-
Constructor Detail
-
Reflector
public Reflector(java.lang.String classname) throws HeclExceptionCreates a newReflectorinstance.- Parameters:
classname- aStringvalue describing the full name (including package) of a Java class.- Throws:
HeclException- if an error occurs
-
-
Method Detail
-
instantiate
public Thing instantiate(Thing[] argv) throws HeclException
Theinstantiatemethod is called to create an instance of a class (new, in other words).- Parameters:
argv- aThingvalue that is mapped onto Java parameters and passed to the appropriate constructor for the class.- Returns:
- a
Thingvalue - Throws:
HeclException- if an error occurs
-
getField
public Thing getField(java.lang.Object target, java.lang.String name) throws HeclException
ThegetFieldmethod returns the value of an instance's field.- Parameters:
target- anObjectvaluename- aStringvalue- Returns:
- a
Thingvalue - Throws:
HeclException- if an error occurs
-
setField
public void setField(java.lang.Object target, java.lang.String name, Thing newvalue) throws HeclExceptionThesetFieldmethod takes an object, a field name, and a new Thing value, and sets the object's field to the value of Thing.- Parameters:
target- anObjectvaluename- aStringvaluenewvalue- aThingvalue- Throws:
HeclException- if an error occurs
-
getConstField
public Thing getConstField(java.lang.String name) throws HeclException
getConstFieldfetches a constant field value.- Parameters:
name- aStringvalue- Returns:
- a
Thingvalue - Throws:
HeclException- if an error occurs
-
evaluate
public Thing evaluate(java.lang.Object o, java.lang.String cmd, Thing[] argv) throws HeclException
Theevaluatemethod takes a target object to operate on, a methodname, and some Hecl values, and attempts to find and call a Java method with the supplied values.- Parameters:
o- anObjectvaluecmd- aStringvalueargv- aThingvalue- Returns:
- a
Thingvalue - Throws:
HeclException- if an error occurs
-
heclTypeToJavaType
public boolean heclTypeToJavaType(java.lang.Object[] retval, java.lang.Class rtype, Thing heclparm) throws HeclExceptionTheheclTypeToJavaTypemethod takes a Class and a Hecl Thing, turns the Thing into an Object based on the Class type, and returns the Object.- Parameters:
retval- anObjectvaluertype- aClassvalueheclparm- aThingvalue- Returns:
- an
Objectvalue - Throws:
HeclException- if an error occurs
-
javaTypeToHeclType
public Thing javaTypeToHeclType(java.lang.Class rtype, java.lang.Object o)
ThejavaTypeToHeclTypemethod takes a Java type, and a Java Object, and returns a Thing.- Parameters:
rtype- aClassvalueo- anObjectvalue- Returns:
- a
Thingvalue
-
methods
public Thing methods() throws HeclException
Themethodsmethod returns a Hecl list of method signatures in the form methodName type type type.- Returns:
- a
Thingvalue - Throws:
HeclException- if an error occurs
-
constructors
public Thing constructors()
Theconstructorsmethod returns a Hecl list of types that would work as constructors for this object type.- Returns:
- a
Thingvalue
-
-
DataMelt 3.0 © DataMelt by jWork.ORG