Ken,
On Fri, Aug 19, 2011 at 2:56 PM, <[email protected]> wrote:
> Hi Patrick,
>
> Well, Enums have only existed for about 3 or 4 years, so 60-70% of that
> silence is understandable. =)
One neat thing about Java is that the reflection stuff is very
consistent. Even "newer" stuff like Enum that didn't exist when I
first wrote Inline::Java can automagically work using the existing
framework. In this case they are implemented using an inner class.
> I want to get my hands on a specific Enum value. valueOf() is just a way
> to look up an Enum by its string name, I was hoping that might already be
> exposed in the API by existing methods.
>
> Experimenting again, it looks like the following actually works:
>
> ------------------------
> use Inline (Java => "STUDY",
> CLASSPATH => "foo.jar",
> AUTOSTUDY => 1,
> STUDY=> ["com.my.company.TokenFSM\$TokenType"],
> JNI=>1);
> print com::my::company::TokenFSM::TokenType->valueOf("APOS");
> ------------------------
>
>
> That prints:
>
> main::com::my::company::TokenFSM::TokenType=HASH(0x1030567c0)
>
> And I can call methods of that object (like ordinal(), name(), etc.), so
> I'm happy. =)
You can also reference them directly like this:
print $com::my::company::TokenFSM::TokenType::ALPHAID->ordinal(), "\n" ;
print $com::my::company::TokenFSM::TokenType::APOS->ordinal(), "\n" ;
Patrick
--
=====================
Patrick LeBoutillier
Rosemère, Québec, Canada