incubator-kato-spec mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stuart Monteith <>
Subject Inner classes, Enums
Date Tue, 13 Oct 2009 20:41:44 GMT
    I've noticed that we don't really have support for inner classes or 
enums in the API or any query languages that have been suggested.

For enums we'd want to do comparisons where a field is compared against 
an enum type. An enum just now will appear as a class subclassing 
java.lang.Enum with a modifier including "0x4000" - this, incidentally, 
doesn't appear in "java.lang.reflect.Modifier", which the API depends on.

For example,
    "SELECT x FROM instances WHERE AND 
x.colour = RED"

    public {
       Colour colour;

    public enum Colour {

In the Java application API, it might be worth having:

    public interface JavaEnum extends JavaClass {
        EnumConstant[] getConstants();       
       EnumConstant getConstant(String name);

    public interface EnumConstant extends JavaObject {
       public String getName();
       public int getOrdinal();
       public JavaEnum getType();

These would correspond with Enums and their types, extending JavaClass 
and JavaObject, and would still allow more sophisticated, non-standard 
enums to be queried like other classes and objects.
So you could do:

    EnumType terry=xxxx;
    if ( ((JavaObject)character).equals(terry.getConstant("June")) )
       // Do something interesting.

Now, inner classes..

The relationship between classes and their inner classes isn't exposed 
by the API. I'm not sure how to judge how important that is, but it 
might be important for field value retrieval and querying.

java.lang.Class provides the following methods:
    Class getDeclaringClass()
    Class getEnclosingClass()
    Class getEnclosingMethod()
    boolean isAnonymousClass()
    boolean isLocalClass()
    boolean isMemberClass()

Which could be conceivably be duplicated within JavaClass.

For querying, say:

public class A {
    int aNumber = 2;

    public class B {
       int anotherNumber = 5;

       public class C {
          String inDepth = 18;

Given an instance of A$B$C, should we allow querying to allow:
    WHERE x.anotherNumber = 5
when x is A$B$C ?




Stuart Monteith

View raw message