my dog learned polymorphism
The moose likes Java in General and the fly likes Bitwise operations with Enumerated types Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Bitwise operations with Enumerated types" Watch "Bitwise operations with Enumerated types" New topic

Bitwise operations with Enumerated types

Muthuraj Muthiah

Joined: Mar 14, 2006
Posts: 1
I am using COM4J to integrate my Java application with SDF (Autodesk) compoent toolkit in COM. COM4J generated wrapper interfaces or proxies for this COM object and one of the method signature is

void open(
java.lang.String sdfPath, openFlags,
boolean useKif);

Where the openFlags argument is of type enum.
public enum SdfOpenFlags implements ComEnum {

private final int value;
SdfOpenFlags(int value) { this.value=value; }
public int comEnumValue() { return value; }

The corresponding VB example to call this COM function is

Rem - Create a new SDF opened for write.
openFlags = sdfOpenUpdate Or sdfCreateAlways
toolkit.Open "c:\temp\TEST.SDF", openFlags, True

I would like to use Java the same way but got compilation errors."c:\\Temp\\test.sdf", SdfOpenFlags.sdfCreateAlways | SdfOpenFlags.sdfOpenUpdate, true);

This leads to compilation errors as "The operator | is undefined for argument type(s),

I am not sure how I should use the OR operator in this case in Java.
KR Campbell
Ranch Hand

Joined: Mar 26, 2004
Posts: 124"c:\\Temp\\test.sdf", SdfOpenFlags.sdfCreateAlways | SdfOpenFlags.sdfOpenUpdate, true);

might have a better chance.
Hao Wu

Joined: Sep 13, 2006
Posts: 1

I am also using com4j to generate wrapper (*.java) from DLL, I successfully generated a set of *.java files, but I can not complie them.
$ javac 'class' or 'interface' expected
public enum Planet {
1 error
"enum" type can not be identified. I use jdk1.5.0_08, com4j.dll and com4j.jar are also in lib path.

How do you compile the *.java file?

I agree. Here's the link:
subject: Bitwise operations with Enumerated types
It's not a secret anymore!