Importing and using Enum types

482 views
Skip to first unread message

Kasim

unread,
Feb 22, 2011, 11:38:44 PM2/22/11
to clo...@googlegroups.com
Hi Hackers,
I am trying to import and use following Enum class from Clojure:
http://build.xuggle.com/view/Stable/job/xuggler_jdk5_stable/javadoc/java/api/com/xuggle/xuggler/IContainer.Type.html

Basically, I need it so that I can feed it to a Java method that requires it. I'd appreciate any idea or help.

Thanks,

Ken Wesson

unread,
Feb 23, 2011, 12:58:31 AM2/23/11
to clo...@googlegroups.com

If the enum is a top level class: com.example.package.EnumClass and
com.example.package.EnumClass/EnumConstant. If the enum is nested in
Foo, com.example.package.Foo$EnumClass and
com.example.package.Foo$EnumClass/EnumConstant.

The enum class can be imported like any other class. If you want a
shorthand for the constants, like foo for EnumClass/FOO, you can do
something like this

(ns quux
(import [com.example.package EnumClass]))

(def foo EnumClass/FOO)

...

(do-something-with foo)

...

(.javaMethod some-object ^String "boo!" (int 42) ^EnumClass foo)

Kasim

unread,
Feb 23, 2011, 11:50:50 AM2/23/11
to clo...@googlegroups.com
Thanks Ken. I was able to use enums before as you have suggested but here is the specific issue:
The name of the Enum Class is (Unfortunately) IContainer.Type that lives in com.xuggle.xuggler package.
I believe it is the dot within the IContainer.Type class name that is giving me headache.

I'd appreciate any input or work around that I am not aware of.

-K

Baishampayan Ghose

unread,
Feb 23, 2011, 11:56:14 AM2/23/11
to clo...@googlegroups.com, Kasim
> The name of the Enum Class is (Unfortunately) IContainer.Type that lives in
> com.xuggle.xuggler package.
> I believe it is the dot within the IContainer.Type class name that is giving
> me headache.
>
> I'd appreciate any input or work around that I am not aware of.

Try IContainer$Type/READ and IContainer$Type/WRITE

Regards,
BG

--
Baishampayan Ghose
b.ghose at gmail.com

Kasim

unread,
Feb 24, 2011, 12:40:19 AM2/24/11
to clo...@googlegroups.com, Kasim
Thanks. That did the trick.
Reply all
Reply to author
Forward
0 new messages