incubator-kato-spec mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Steve Poole <spoole...@googlemail.com>
Subject Re: Inner classes, Enums
Date Wed, 14 Oct 2009 08:10:12 GMT
On Tue, Oct 13, 2009 at 9:41 PM, Stuart Monteith <stukato@stoo.me.uk> wrote:

> Hi,
>   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.
>
> True


> 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.
>
> The modifier is irrelevant for us yes?   As long as its a subclass of
java.lang.Enum   we know what it is.

For example,
>   "SELECT x FROM instances WHERE x.class=com.example.diy.Paint AND x.colour
> = RED"
>
> Think you mean

   "SELECT x FROM instances WHERE x.class=com.example.diy.Paint AND x.colour
= Colour.RED"


Where
>   public com.example.diy.Paint {
>      Colour colour;
>   }
>
>
>   public enum Colour {
>      RED, GREEN, FUSCHIA, MAGNOLIA, WHITE
>   }
>
>
> 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 ?
>
> anotherNumber is not  a field of  C so its not reasonable to allow
x.anotherNumber.    What is required is that somehow you can  make the jump
from the inner instance to the outer instance.    That would allow   x {goto
parent instance operator} anotherNumber to work



> Regards,
>   Stuart
>
>
>
> Regards,
>   Stuart
>
> --
> Stuart Monteith
> http://blog.stoo.me.uk/
>
>


-- 
Steve

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message