JESS: [EXTERNAL] Access public enum inside of a class

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

JESS: [EXTERNAL] Access public enum inside of a class

Hunter Mcmillen
Hi everyone, 

I am trying to use an enum from one of my Java classes inside of Jess. I read a forum post that said I could use the (import <enum-name>) feature to import enums into Jess, but that only seems to work when the enum is itself in a separate file. 

I have a class called UnitType, inside of it there is a public enum called UnitTypes where all of the UnitTypes in my game are listed. In Java to access this I would use UnitType.UnitTypes.<Element_in_enum> to get to the enum. 

When I try this in Jess however, I get an error:
Rete engine = new Rete();
engine.executeCommand("(import eisbot.proxy.types.UnitType.UnitTypes)");

an error occurs, "java.lang.ClassNotFoundException: eisbot.proxy.types.UnitType.UnitTypes"

I am curious as to how I could go about accessing an enum that is inside of a Java class from Jess. 

any help would be appreciated.

Thanks
Hunter McMillen



Reply | Threaded
Open this post in threaded view
|

RE: JESS: [EXTERNAL] Access public enum inside of a class

Friedman-Hill, Ernest
Nested enums, like nested classes, actually secretly have a name like "UnitType$UnitTypes". I haven't tried this specifically for enums, but I suspect this would work:

engine.executeCommand("(import eisbot.proxy.types.UnitType$UnitTypes)");

________________________________
From: [hidden email] [mailto:[hidden email]] On Behalf Of Hunter McMillen
Sent: Wednesday, December 07, 2011 4:27 PM
To: jess-users
Subject: JESS: [EXTERNAL] Access public enum inside of a class

Hi everyone,

I am trying to use an enum from one of my Java classes inside of Jess. I read a forum post that said I could use the (import <enum-name>) feature to import enums into Jess, but that only seems to work when the enum is itself in a separate file.

I have a class called UnitType, inside of it there is a public enum called UnitTypes where all of the UnitTypes in my game are listed. In Java to access this I would use UnitType.UnitTypes.<Element_in_enum> to get to the enum
Reply | Threaded
Open this post in threaded view
|

Re: JESS: [EXTERNAL] Access public enum inside of a class

Hunter Mcmillen
Thanks very much that worked perfectly.

Hunter McMillen

On Wed, Dec 7, 2011 at 5:10 PM, Friedman-Hill, Ernest <[hidden email]> wrote:
Nested enums, like nested classes, actually secretly have a name like "UnitType$UnitTypes". I haven't tried this specifically for enums, but I suspect this would work:

engine.executeCommand("(import eisbot.proxy.types.UnitType$UnitTypes)");

________________________________
From: [hidden email] [mailto:[hidden email]] On Behalf Of Hunter McMillen
Sent: Wednesday, December 07, 2011 4:27 PM
To: jess-users
Subject: JESS: [EXTERNAL] Access public enum inside of a class

Hi everyone,

I am trying to use an enum from one of my Java classes inside of Jess. I read a forum post that said I could use the (import <enum-name>) feature to import enums into Jess, but that only seems to work when the enum is itself in a separate file.

I have a class called UnitType, inside of it there is a public enum called UnitTypes where all of the UnitTypes in my game are listed. In Java to access this I would use UnitType.UnitTypes.<Element_in_enum> to get to the enum