|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.vub.at.objects.mirrors.Reflection
Reflection is an auxiliary class meant to serve as a repository for methods related to 'up' and 'down' Java values properly into and out of the AmbientTalk base level. Keep the following mental picture in mind: ^ Java = implementation-level | to deify | Java AT objects = meta-level | to reify (= to up) | ------------------------------------------ | (= to down) (= to absorb) | AmbientTalk = base-level v (= to reflect) Although deification and reification are more accurate terms, we will use 'up' and 'down' because they are the clearest terminology, and clarity matters. In this class, the following conventions hold: - methods start with either 'up' or 'down', denoting whether they deify or reify something - arguments start with either 'j' or 'at', denoting whether they represent Java or AmbientTalk values With 'java values' is meant 'java objects representing mirrors'
Field Summary | |
static java.lang.String |
_BASE_PREFIX_
|
static java.lang.String |
_BGET_PREFIX_
|
static java.lang.String |
_BSET_PREFIX_
|
static java.lang.String |
_MAGET_PREFIX_
|
static java.lang.String |
_MAGIC_PREFIX_
|
static java.lang.String |
_MASET_PREFIX_
|
static java.lang.String |
_META_PREFIX_
|
static java.lang.String |
_MGET_PREFIX_
|
static java.lang.String |
_MSET_PREFIX_
|
private static java.util.regex.Pattern |
oprCode
|
private static java.util.regex.Pattern |
symbol
|
Constructor Summary | |
Reflection()
|
Method Summary | |
static ATSymbol |
downBaseFieldAccessSelector(java.lang.String jSelector)
Transforms a Java selector prefixed with base_get into an equivalent AmbientTalk selector. |
static ATSymbol |
downBaseFieldMutationSelector(java.lang.String jSelector)
Transforms a Java selector prefixed with base_set into an equivalent AmbientTalk selector. |
static ATField |
downBaseLevelField(ATObject natObject,
ATSymbol atSelector)
|
static ATField[] |
downBaseLevelFields(ATObject atObj)
Returns, for a given AmbientTalk object atObj, an array of NativeField objects corresponding to all non-static methods of that object's Java class, where each method's name is prefixed with 'base_get' |
static ATMethod |
downBaseLevelMethod(ATObject natObject,
ATSymbol atSelector)
|
static ATMethod[] |
downBaseLevelMethods(ATObject atObj)
Returns, for a given AmbientTalk object atObj, an array of NativeMethod objects corresponding to all non-static methods of that object's class, where each method's name: - is prefixed with 'base_' - is not prefixed with 'base_get' - is not prefixed with 'base_set' |
static ATSymbol |
downBaseLevelSelector(java.lang.String jSelector)
Transforms a Java selector prefixed with base_ into an AmbientTalk selector without the prefix. |
static ATField |
downField(ATObject natObject,
ATSymbol atSelector,
java.lang.String getPrefix,
java.lang.String setPrefix)
Constructs an AmbientTalk ATField from a pair of accessor/mutator methods of a Java object. |
static ATSymbol |
downFieldName(java.lang.String jName)
A field name "Field" passed from the Java to the AmbientTalk level undergoes the following transformations: - the same transformations applicable to downSelector |
static ATObject |
downInvocation(ATObject atRcvr,
java.lang.reflect.Method jMethod,
ATObject[] jArgs)
downInvocation takes an implicit Java invocation and turns it into an explicit AmbientTalk invocation process. |
static ATSymbol |
downMetaFieldAccessSelector(java.lang.String jSelector)
Transforms a Java selector prefixed with meta_get into an equivalent AmbientTalk selector Example: downMetaFieldAccessSelector("meta_getReceiver") => ATSymbol("receiver") |
static ATSymbol |
downMetaFieldMutationSelector(java.lang.String jSelector)
Transforms a Java selector prefixed with meta_set into an equivalent AmbientTalk selector. |
static ATField |
downMetaLevelField(ATObject natObject,
ATSymbol atSelector)
|
static ATField[] |
downMetaLevelFields(ATObject atObj)
Returns, for a given AmbientTalk object atObj, an array of NativeField objects corresponding to all non-static methods of that object's Java class, where each method's name is prefixed with 'meta_get' |
static ATMethod |
downMetaLevelMethod(ATObject natObject,
ATSymbol atSelector)
|
static ATMethod[] |
downMetaLevelMethods(ATObject natObj)
Returns, for a given AmbientTalk object natObj, an array of NativeMethod objects corresponding to all non-static methods of that object's class, where each method's name: - is prefixed with 'meta_' - is not prefixed with 'meta_get' - is not prefixed with 'meta_set' |
static ATSymbol |
downMetaLevelSelector(java.lang.String jSelector)
Transforms a Java selector prefixed with meta_ into an AmbientTalk selector without the prefix. |
static ATMethod |
downMethod(ATObject natObject,
java.lang.String jSelector,
ATSymbol origName)
Constructs an AmbientTalk ATMethod from a Java method. |
static ATObject |
downObject(ATObject metaObject)
Pass an AmbientTalk meta-level object into the base-level |
static ATSymbol |
downSelector(java.lang.String jSelector)
A selector passed from the Java to the AmbientTalk level undergoes the following transformations: - any pattern of the form _op{code}_ is transformed to a symbol corresponding to the operator code Operator codes are: pls -> + mns -> - tms -> * div -> / bsl -> \ and -> & not -> ! |
private static java.lang.String |
javaToAmbientTalkSelector(java.lang.String jSelector)
|
private static java.lang.String |
oprCode2Symbol(java.lang.String code)
|
private static java.lang.String |
stripPrefix(java.lang.String input,
java.lang.String prefix)
|
private static java.lang.String |
symbol2oprCode(java.lang.String symbol)
|
static java.lang.String |
upBaseFieldAccessSelector(ATSymbol atName)
Transforms an AmbientTalk selector into an equivalent Java selector uppercased and prefixed with "base_get". |
static java.lang.String |
upBaseFieldMutationSelector(ATSymbol atName)
Transforms an AmbientTalk selector into an equivalent Java selector uppercased and prefixed with "base_set". |
static java.lang.String |
upBaseLevelSelector(ATSymbol atSelector)
Transforms an AmbientTalk selector into a Java-level selector prefixed with base_. |
static ATObject |
upExceptionCreation(InterpreterException jRcvr,
ATTable atInitargs)
|
static ATObject |
upFieldAssignment(ATObject atOrigRcvr,
java.lang.String jSelector,
ATObject value)
upFieldAssignment takes an explicit AmbientTalk field assignment and turns it into an implicitly performed Java field assignment by invoking a mutator method, if such a method exists. |
static java.lang.String |
upFieldName(ATSymbol atName)
A field name "field" passed from the AmbientTalk to the Java level undergoes the following transformations: - the same transformations applicable to upSelector |
static ATObject |
upFieldSelection(ATObject atOrigRcvr,
java.lang.String jSelector)
upFieldSelection takes an explicit AmbientTalk field selection and turns it into an implicitly performed Java selection by invoking a getter method, if such a getter method exists. |
static ATObject |
upInstanceCreation(ATObject jRcvr,
ATTable atInitargs)
upInstanceCreation takes an explicit AmbientTalk 'new' invocation and turns it into an implicit Java instance creation by calling a constructor. |
static ATObject |
upInvocation(ATObject atOrigRcvr,
java.lang.String jSelector,
ATTable atArgs)
upInvocation takes an explicit AmbientTalk method invocation and turns it into an implicitly performed Java invocation. |
static java.lang.String |
upMagicFieldAccessSelector(ATSymbol atName)
Transforms an AmbientTalk selector into an equivalent Java selector uppercased and prefixed with "meta_get". |
static java.lang.String |
upMagicFieldMutationSelector(ATSymbol atName)
Transforms an AmbientTalk selector into an equivalent Java selector uppercased and prefixed with "meta_set". |
static java.lang.String |
upMagicLevelSelector(ATSymbol atSelector)
Transforms an AmbientTalk selector into a Java-level selector prefixed with magic_. |
static java.lang.String |
upMetaFieldAccessSelector(ATSymbol atName)
Transforms an AmbientTalk selector into an equivalent Java selector uppercased and prefixed with "meta_get". |
static java.lang.String |
upMetaFieldMutationSelector(ATSymbol atName)
Transforms an AmbientTalk selector into an equivalent Java selector uppercased and prefixed with "meta_set". |
static java.lang.String |
upMetaLevelSelector(ATSymbol atSelector)
Transforms an AmbientTalk selector into a Java-level selector prefixed with meta_. |
static NativeClosure |
upMethodSelection(ATObject atOrigRcvr,
java.lang.String jSelector,
ATSymbol origSelector)
upMethodSelection takes an explicit AmbientTalk field selection and checks whether a Java method exists that matches the selector. |
static ATObject |
upObject(ATObject baseObject)
Pass an AmbientTalk base-level object to the meta-level |
static boolean |
upRespondsTo(ATObject jRcvr,
java.lang.String jSelector)
upRespondsTo transforms an explicit AmbientTalk respondsTo meta-level request into an implicit check whether the given jRcvr java object has a method corresponding to the given selector, prefixed with base_ |
static java.lang.String |
upSelector(ATSymbol atSelector)
A selector passed from the AmbientTalk to the Java level undergoes the following transformations: - any colons (:) are replaced by underscores (_) - any operator symbol is replaced by _op{code}_ where code is generated as follows: Operator codes are: + -> pls - -> mns * -> tms / -> div \ -> bsl & -> and ! |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final java.lang.String _BASE_PREFIX_
public static final java.lang.String _BGET_PREFIX_
public static final java.lang.String _BSET_PREFIX_
public static final java.lang.String _META_PREFIX_
public static final java.lang.String _MGET_PREFIX_
public static final java.lang.String _MSET_PREFIX_
public static final java.lang.String _MAGIC_PREFIX_
public static final java.lang.String _MAGET_PREFIX_
public static final java.lang.String _MASET_PREFIX_
private static final java.util.regex.Pattern oprCode
private static final java.util.regex.Pattern symbol
Constructor Detail |
public Reflection()
Method Detail |
public static final ATSymbol downSelector(java.lang.String jSelector)
public static final ATSymbol downBaseLevelSelector(java.lang.String jSelector) throws InterpreterException
InterpreterException
public static final ATSymbol downMetaLevelSelector(java.lang.String jSelector) throws InterpreterException
InterpreterException
public static final ATSymbol downBaseFieldAccessSelector(java.lang.String jSelector) throws InterpreterException
InterpreterException
public static final ATSymbol downBaseFieldMutationSelector(java.lang.String jSelector) throws InterpreterException
InterpreterException
public static final ATSymbol downMetaFieldAccessSelector(java.lang.String jSelector) throws InterpreterException
InterpreterException
public static final ATSymbol downMetaFieldMutationSelector(java.lang.String jSelector) throws InterpreterException
InterpreterException
public static final ATSymbol downFieldName(java.lang.String jName) throws InterpreterException
InterpreterException
- the first letter is transformed into lower case (as it was uppercased for Java conventions)
public static final java.lang.String upSelector(ATSymbol atSelector) throws InterpreterException
InterpreterException
public static final java.lang.String upBaseLevelSelector(ATSymbol atSelector) throws InterpreterException
InterpreterException
public static final java.lang.String upMetaLevelSelector(ATSymbol atSelector) throws InterpreterException
InterpreterException
public static final java.lang.String upMagicLevelSelector(ATSymbol atSelector) throws InterpreterException
InterpreterException
public static final java.lang.String upFieldName(ATSymbol atName) throws InterpreterException
InterpreterException
- the first letter is transformed into upper case such that it can be accessed using respectively
"getField" | "setField" methods at the Java level.
public static final java.lang.String upBaseFieldAccessSelector(ATSymbol atName) throws InterpreterException
InterpreterException
public static final java.lang.String upBaseFieldMutationSelector(ATSymbol atName) throws InterpreterException
InterpreterException
public static final java.lang.String upMetaFieldAccessSelector(ATSymbol atName) throws InterpreterException
InterpreterException
public static final java.lang.String upMetaFieldMutationSelector(ATSymbol atName) throws InterpreterException
InterpreterException
public static final java.lang.String upMagicFieldAccessSelector(ATSymbol atName) throws InterpreterException
InterpreterException
public static final java.lang.String upMagicFieldMutationSelector(ATSymbol atName) throws InterpreterException
InterpreterException
public static final ATField downField(ATObject natObject, ATSymbol atSelector, java.lang.String getPrefix, java.lang.String setPrefix) throws InterpreterException
natObject
- the native AT object in whose class the accessor/mutator methods should be foundatSelector
- the AmbientTalk name of the field
InterpreterException
public static final ATField downBaseLevelField(ATObject natObject, ATSymbol atSelector) throws InterpreterException
InterpreterException
public static final ATField downMetaLevelField(ATObject natObject, ATSymbol atSelector) throws InterpreterException
InterpreterException
public static final ATMethod downMethod(ATObject natObject, java.lang.String jSelector, ATSymbol origName) throws InterpreterException
natObject
- the native AmbientTalk object in whose class the method should be foundjSelector
- a selector which should yield a method in natObjectorigName
- the original AmbientTalk name of the method
InterpreterException
public static final ATMethod downBaseLevelMethod(ATObject natObject, ATSymbol atSelector) throws InterpreterException
InterpreterException
public static final ATMethod downMetaLevelMethod(ATObject natObject, ATSymbol atSelector) throws InterpreterException
InterpreterException
public static final ATObject downInvocation(ATObject atRcvr, java.lang.reflect.Method jMethod, ATObject[] jArgs) throws InterpreterException
atRcvr
- the AmbientTalk object having received the Java method invocationjArgs
- the arguments to the Java method invocation (normally all args are ATObjects)
jArgs may be null, indicating that there are no arguments
InterpreterException
public static final ATObject upInvocation(ATObject atOrigRcvr, java.lang.String jSelector, ATTable atArgs) throws InterpreterException
atOrigRcvr
- the original AmbientTalk object that received the invocationjSelector
- the selector of the message to be invoked, converted to a Java selectoratArgs
- the arguments to the AmbientTalk method invocation
InterpreterException
public static final boolean upRespondsTo(ATObject jRcvr, java.lang.String jSelector) throws InterpreterException
jRcvr
- the Java object being queried for a certain selectorjSelector
- the selector of the message to be invoked, converted to a Java selector
InterpreterException
public static final ATObject upFieldSelection(ATObject atOrigRcvr, java.lang.String jSelector) throws InterpreterException
atOrigRcvr
- the original AmbientTalk object that received the selectionjSelector
- the selector of the message to be invoked, already converted to a Java selector
InterpreterException
public static final ATObject upFieldAssignment(ATObject atOrigRcvr, java.lang.String jSelector, ATObject value) throws InterpreterException
atOrigRcvr
- the original AmbientTalk object that received the assignField requestjSelector
- the selector of the message to be invoked, already converted to a Java selector
InterpreterException
public static final NativeClosure upMethodSelection(ATObject atOrigRcvr, java.lang.String jSelector, ATSymbol origSelector) throws InterpreterException
atOrigRcvr
- the original AmbientTalk object that received the selectionjSelector
- the selector of the message to be invoked, converted to a Java selector
InterpreterException
public static final ATObject upInstanceCreation(ATObject jRcvr, ATTable atInitargs) throws InterpreterException
jRcvr
- the Java object having received the call to newatInitargs
- the arguments to the constructor
InterpreterException
public static final ATObject upExceptionCreation(InterpreterException jRcvr, ATTable atInitargs) throws InterpreterException
InterpreterException
public static final ATObject downObject(ATObject metaObject) throws InterpreterException
InterpreterException
public static final ATObject upObject(ATObject baseObject)
public static final ATField[] downBaseLevelFields(ATObject atObj) throws InterpreterException
InterpreterException
public static final ATField[] downMetaLevelFields(ATObject atObj) throws InterpreterException
InterpreterException
public static final ATMethod[] downBaseLevelMethods(ATObject atObj) throws InterpreterException
InterpreterException
public static final ATMethod[] downMetaLevelMethods(ATObject natObj) throws InterpreterException
InterpreterException
private static java.lang.String stripPrefix(java.lang.String input, java.lang.String prefix)
private static final java.lang.String oprCode2Symbol(java.lang.String code)
private static final java.lang.String symbol2oprCode(java.lang.String symbol)
private static final java.lang.String javaToAmbientTalkSelector(java.lang.String jSelector)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |