edu.vub.at.objects.symbiosis
Class JavaPackage

java.lang.Object
  extended byedu.vub.at.objects.natives.NATNil
      extended byedu.vub.at.objects.natives.NATByRef
          extended byedu.vub.at.objects.natives.NATCallframe
              extended byedu.vub.at.objects.natives.NATObject
                  extended byedu.vub.at.objects.symbiosis.JavaPackage
All Implemented Interfaces:
ATAbstractGrammar, ATConversions, ATExpression, ATNil, ATObject, ATStatement, java.io.Serializable

public final class JavaPackage
extends NATObject

A JavaPackage represents (part of) a Java package name and serves the same purpose as AmbientTalk Namespace objects, but for loading Java classes rather than AT objects. The behaviour of a JavaPackage object relies on Java naming conventions for automatic loading of classes. If some Java code does not follow the naming conventions, then explicit loading of packages or classes must be done via a JavaPackage's provided base-level methods. Selecting a field f from a JavaPackage encapsulating the path p has the following semantics: - if f starts with an uppercase symbol, the field access is interpreted as a class reference: The JavaPackage tries to load the class p.f. If the class does not exist, an XSelectorNotFound exception is thrown. - if f starts with a lowercase symbol, the field access is interpreted as a subpackage reference: The JavaPackage creates a new field referring to a JavaPackage whose path equals 'p.f.' JavaPackage instances are isolates, hence, they are pass-by-copy.

Author:
tvcutsem
See Also:
Serialized Form

Field Summary
private static AGSymbol _CLS_NAME_
           
private static AGSymbol _PKG_NAME_
           
private static java.lang.String _PKG_SEP_
           
private static PrimitiveMethod _PRIM_CLS_
          def class(name) { nil }
private static PrimitiveMethod _PRIM_PKG_
          def package(name) { nil }
private  java.lang.String path_
           
 
Fields inherited from class edu.vub.at.objects.natives.NATObject
_EQL_NAME_, _INI_NAME_, _IS_A_, _NEW_NAME_, _NO_STRIPES_, _SHARES_A_, _SUPER_NAME_, stripes_
 
Fields inherited from class edu.vub.at.objects.natives.NATCallframe
customFields_, lexicalParent_, stateVector_, variableMap_
 
Fields inherited from class edu.vub.at.objects.natives.NATNil
_INSTANCE_
 
Constructor Summary
private JavaPackage(FieldMap map, java.util.Vector state, java.util.LinkedList customFields, MethodDictionary methodDict, ATObject dynamicParent, ATObject lexicalParent, byte flags, ATStripe[] stripes, java.lang.String path)
          Private constructor used only for cloning
  JavaPackage(java.lang.String path)
          A JavaPackage object encapsulates a package path.
 
Method Summary
 ATObject base_class(ATSymbol selector)
          Allows the AT programmer to explicitly load a class.
 ATObject base_package(ATSymbol selector)
          Allows the AT programmer to explicitly load a package.
protected  NATObject createClone(FieldMap map, java.util.Vector state, java.util.LinkedList customFields, MethodDictionary methodDict, ATObject dynamicParent, ATObject lexicalParent, byte flags, ATStripe[] stripes)
           
 ATObject meta_doesNotUnderstand(ATSymbol selector)
          For a JavaPackage object, doesNotUnderstand triggers the querying of the Java classpath to load classes corresponding to the missing selector.
 NATText meta_print()
          Prints out the object in a human-readable way.
 
Methods inherited from class edu.vub.at.objects.natives.NATObject
asAmbientTalkObject, base_asActorMirror, base_asAsyncMessage, base_asBegin, base_asBoolean, base_asClosure, base_asDefinition, base_asExpression, base_asField, 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_isBoolean, base_isCallFrame, base_isClosure, base_isMethod, base_isMirror, base_isSplice, base_isStripe, base_isSymbol, base_isTable, base_isUnquoteSplice, createChild, createIsolate, isAmbientTalkObject, isPrimitive, listTransitiveFields, listTransitiveMethods, meta_addMethod, meta_assignField, meta_clone, meta_defineField, meta_extend, meta_getStripes, meta_grabMethod, meta_invoke, meta_isCloneOf, meta_isRelatedTo, meta_isStripedWith, meta_listMethods, meta_lookup, meta_newInstance, meta_pass, meta_resolve, meta_respondsTo, meta_select, meta_share
 
Methods inherited from class edu.vub.at.objects.natives.NATCallframe
getLocalCustomField, getLocalField, hasLocalCustomField, hasLocalField, hasLocalNativeField, meta_addField, meta_assignVariable, meta_getDynamicParent, meta_getLexicalParent, meta_grabField, meta_listFields, setLocalField
 
Methods inherited from class edu.vub.at.objects.natives.NATNil
asJavaClassUnderSymbiosis, asJavaObjectUnderSymbiosis, asNativeBoolean, asNativeException, asNativeFarReference, asNativeFraction, asNativeNumber, asNativeNumeric, asNativeTable, asNativeText, base__opeql__opeql_, base_asFarReference, base_asVariableAssignment, base_init, base_isFarReference, base_isMessageCreation, base_isVariableAssignment, base_new, equals, isJavaObjectUnderSymbiosis, isNativeBoolean, isNativeField, isNativeText, meta_eval, meta_quote, meta_receive, meta_send, 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_assignVariable, meta_eval, meta_getDynamicParent, meta_getLexicalParent, meta_grabField, meta_listFields, meta_quote, meta_receive, meta_send
 
Methods inherited from interface edu.vub.at.objects.coercion.ATConversions
asJavaClassUnderSymbiosis, asJavaObjectUnderSymbiosis, asNativeBoolean, asNativeException, asNativeFarReference, asNativeFraction, asNativeNumber, asNativeNumeric, asNativeTable, asNativeText, base_asFarReference, base_asVariableAssignment, base_isFarReference, base_isMessageCreation, base_isVariableAssignment, isJavaObjectUnderSymbiosis, isNativeBoolean, isNativeField, isNativeText
 

Field Detail

_PKG_SEP_

private static final java.lang.String _PKG_SEP_
See Also:
Constant Field Values

_CLS_NAME_

private static final AGSymbol _CLS_NAME_

_PKG_NAME_

private static final AGSymbol _PKG_NAME_

_PRIM_CLS_

private static final PrimitiveMethod _PRIM_CLS_
def class(name) { nil }


_PRIM_PKG_

private static final PrimitiveMethod _PRIM_PKG_
def package(name) { nil }


path_

private final java.lang.String path_
Constructor Detail

JavaPackage

public JavaPackage(java.lang.String path)
A JavaPackage object encapsulates a package path. A package path is a '.'-separated string, always ending with a '.' The jlobby root package has an empty package path A JavaPackage is initialized as an AT/2 isolate object.

Parameters:
path - the pathname of this JavaPackage, e.g. 'java.' or 'java.lang.'

JavaPackage

private JavaPackage(FieldMap map,
                    java.util.Vector state,
                    java.util.LinkedList customFields,
                    MethodDictionary methodDict,
                    ATObject dynamicParent,
                    ATObject lexicalParent,
                    byte flags,
                    ATStripe[] stripes,
                    java.lang.String path)
             throws InterpreterException
Private constructor used only for cloning

Method Detail

meta_doesNotUnderstand

public ATObject meta_doesNotUnderstand(ATSymbol selector)
                                throws InterpreterException
For a JavaPackage object, doesNotUnderstand triggers the querying of the Java classpath to load classes corresponding to the missing selector. Depending on the case of the selector's first letter, the access is interpreted as a class or a package reference.

Specified by:
meta_doesNotUnderstand in interface ATObject
Overrides:
meta_doesNotUnderstand in class NATCallframe
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 NATObject
Throws:
InterpreterException

createClone

protected NATObject createClone(FieldMap map,
                                java.util.Vector state,
                                java.util.LinkedList customFields,
                                MethodDictionary methodDict,
                                ATObject dynamicParent,
                                ATObject lexicalParent,
                                byte flags,
                                ATStripe[] stripes)
                         throws InterpreterException
Overrides:
createClone in class NATObject
Throws:
InterpreterException

base_class

public ATObject base_class(ATSymbol selector)
                    throws InterpreterException
Allows the AT programmer to explicitly load a class. This might be necessary if the class starts with a lowercase letter.

Throws:
InterpreterException

base_package

public ATObject base_package(ATSymbol selector)
                      throws InterpreterException
Allows the AT programmer to explicitly load a package. This might be necessary if the package starts with an uppercase letter.

Throws:
InterpreterException