edu.vub.at.objects.mirrors
Class NativeField

java.lang.Object
  extended byedu.vub.at.objects.natives.NATNil
      extended byedu.vub.at.objects.natives.NATByRef
          extended byedu.vub.at.objects.mirrors.NativeField
All Implemented Interfaces:
ATAbstractGrammar, ATConversions, ATExpression, ATField, ATNil, ATObject, ATStatement, java.io.Serializable

public class NativeField
extends NATByRef
implements ATField

Native Fields are represented in our reflective implementation as a pair of accessor and mutator methods in the class of the native AmbientTalk object. For instance, a native AmbientTalk object of class C has a field 'f' if the class C implements a method 'getF()'. If the class also implements 'setF(v)' the field is assignable.

Author:
tvcutsem, smostinc
See Also:
Serialized Form

Field Summary
private  java.lang.reflect.Method accessor_
          The native Java accessor method to be called when accessing the field
private  ATObject host_
          The AmbientTalk native object to which this field belongs
private  java.lang.reflect.Method mutator_
          The native Java mutator method to be called when assigning to the field.
private  ATSymbol name_
          The AmbientTalk name of the field
 
Fields inherited from class edu.vub.at.objects.natives.NATNil
_INSTANCE_
 
Constructor Summary
NativeField(ATObject host, ATSymbol name, java.lang.reflect.Method accessor, java.lang.reflect.Method mutator)
           
 
Method Summary
 ATField base_asField()
           
 ATSymbol base_getName()
           
 ATObject base_readField()
           
 ATNil base_writeField(ATObject newValue)
          Sets the value of the field if possible
 boolean isNativeField()
           
 ATTable meta_getStripes()
          Returns the stripes of this object.
 ATObject meta_newInstance(ATTable initargs)
          Fields can be re-initialized when installed in an object that is being cloned.
 NATText meta_print()
          Prints out the object in a human-readable way.
 
Methods inherited from class edu.vub.at.objects.natives.NATByRef
meta_pass, meta_resolve
 
Methods inherited from class edu.vub.at.objects.natives.NATNil
asAmbientTalkObject, asJavaClassUnderSymbiosis, asJavaObjectUnderSymbiosis, asNativeBoolean, asNativeException, asNativeFarReference, asNativeFraction, asNativeNumber, asNativeNumeric, asNativeTable, asNativeText, base__opeql__opeql_, base_asActorMirror, base_asAsyncMessage, base_asBegin, base_asBoolean, base_asClosure, base_asDefinition, base_asExpression, base_asFarReference, base_asHandler, base_asMessage, base_asMessageCreation, base_asMethod, base_asMirror, base_asNumber, base_asSplice, base_asStatement, base_asStripe, base_asSymbol, base_asTable, base_asUnquoteSplice, base_asVariableAssignment, base_init, base_isBoolean, base_isCallFrame, base_isClosure, base_isFarReference, base_isMessageCreation, base_isMethod, base_isMirror, base_isSplice, base_isStripe, base_isSymbol, base_isTable, base_isUnquoteSplice, base_isVariableAssignment, base_new, createChild, equals, isAmbientTalkObject, isJavaObjectUnderSymbiosis, isNativeBoolean, isNativeText, meta_addField, meta_addMethod, meta_assignField, meta_assignVariable, meta_clone, meta_defineField, meta_doesNotUnderstand, meta_eval, meta_extend, meta_getDynamicParent, meta_getLexicalParent, meta_grabField, meta_grabMethod, meta_invoke, meta_isCloneOf, meta_isRelatedTo, meta_isStripedWith, meta_listFields, meta_listMethods, meta_lookup, meta_quote, meta_receive, meta_respondsTo, meta_select, meta_send, meta_share, readResolve, toString, writeReplace
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface edu.vub.at.objects.ATObject
base__opeql__opeql_, base_init, base_new, meta_addField, meta_addMethod, meta_assignField, meta_assignVariable, meta_clone, meta_defineField, meta_doesNotUnderstand, meta_eval, meta_extend, meta_getDynamicParent, meta_getLexicalParent, meta_grabField, meta_grabMethod, meta_invoke, meta_isCloneOf, meta_isRelatedTo, meta_isStripedWith, meta_listFields, meta_listMethods, meta_lookup, meta_pass, meta_quote, meta_receive, meta_resolve, meta_respondsTo, meta_select, meta_send, meta_share
 
Methods inherited from interface edu.vub.at.objects.coercion.ATConversions
asAmbientTalkObject, asJavaClassUnderSymbiosis, asJavaObjectUnderSymbiosis, asNativeBoolean, asNativeException, asNativeFarReference, asNativeFraction, asNativeNumber, asNativeNumeric, asNativeTable, asNativeText, base_asActorMirror, base_asAsyncMessage, base_asBegin, base_asBoolean, base_asClosure, base_asDefinition, base_asExpression, base_asFarReference, base_asHandler, base_asMessage, base_asMessageCreation, base_asMethod, base_asMirror, base_asNumber, base_asSplice, base_asStatement, base_asStripe, base_asSymbol, base_asTable, base_asUnquoteSplice, base_asVariableAssignment, base_isBoolean, base_isCallFrame, base_isClosure, base_isFarReference, base_isMessageCreation, base_isMethod, base_isMirror, base_isSplice, base_isStripe, base_isSymbol, base_isTable, base_isUnquoteSplice, base_isVariableAssignment, isAmbientTalkObject, isJavaObjectUnderSymbiosis, isNativeBoolean, isNativeText
 

Field Detail

name_

private final ATSymbol name_
The AmbientTalk name of the field


host_

private ATObject host_
The AmbientTalk native object to which this field belongs


accessor_

private final java.lang.reflect.Method accessor_
The native Java accessor method to be called when accessing the field


mutator_

private final java.lang.reflect.Method mutator_
The native Java mutator method to be called when assigning to the field. This field may be null which indicates a read-only field

Constructor Detail

NativeField

public NativeField(ATObject host,
                   ATSymbol name,
                   java.lang.reflect.Method accessor,
                   java.lang.reflect.Method mutator)
Method Detail

base_getName

public ATSymbol base_getName()
Specified by:
base_getName in interface ATField
Returns:
a string by which the slot can be identified.

base_readField

public ATObject base_readField()
                        throws InterpreterException
Specified by:
base_readField in interface ATField
Returns:
the current value of the field.
Throws:
InterpreterException

base_writeField

public ATNil base_writeField(ATObject newValue)
                      throws InterpreterException
Description copied from interface: ATField
Sets the value of the field if possible

Specified by:
base_writeField in interface ATField
Parameters:
newValue - - the value the field should hold.
Returns:
- the return value is ignored.
Throws:
InterpreterException - - if the field cannot be modified.

meta_newInstance

public ATObject meta_newInstance(ATTable initargs)
                          throws InterpreterException
Fields can be re-initialized when installed in an object that is being cloned. They expect the new owner of the field as the sole instance to their 'new' method

Specified by:
meta_newInstance in interface ATObject
Overrides:
meta_newInstance in class NATNil
Throws:
InterpreterException

meta_print

public NATText meta_print()
                   throws InterpreterException
Description copied from interface: ATObject
Prints out the object in a human-readable way.

Specified by:
meta_print in interface ATObject
Overrides:
meta_print in class NATNil
Throws:
InterpreterException

meta_getStripes

public ATTable meta_getStripes()
                        throws InterpreterException
Description copied from interface: ATObject
Returns the stripes of this object. Note that only the stripes that were attached directly to this object are returned, not all of the parent's stripes as well.

Specified by:
meta_getStripes in interface ATObject
Overrides:
meta_getStripes in class NATNil
Throws:
InterpreterException

isNativeField

public boolean isNativeField()
Specified by:
isNativeField in interface ATConversions
Overrides:
isNativeField in class NATNil

base_asField

public ATField base_asField()
Specified by:
base_asField in interface ATConversions
Overrides:
base_asField in class NATNil