Hello,
Let's say I want to define this in java :
package internet;
public class Downloader {
public enum DownloadStatus { INITIALIZING, IN_PROGRESS, COMPLETE };
}
How do I access the enum from matlab.
It seems that it works if the enum is defined outside of any class
(says Andrew here : http://stackoverflow.com/questions/1223795/using-java-enums-or-public-static-fields-in-matlab
) . But In this case, nothing seems to work in matlab
import internet.Downloader.DownloadStatus; does not work, it is not
recognized
internet.Downloader.DownloadStatus; does not work
internet.Downloader.DownloadStatus.INITIALIZING does not work
creating an empty object Downloader then trying to access
Downloadstatus does not work
I tried even the most stupid things, can't make it work
Why I want to do this ? Because there is a method in a java library
that asks for an enum type defined inside a class, so I need by any
means to create this enum type in matlab and pass it to the method as
a parameter.
Thanks for your help :)
|
|
0
|
|
|
|
Reply
|
sylvain.boltz (1)
|
12/2/2009 10:38:30 PM |
|
Sylvain <sylvain.boltz@gmail.com> wrote in message <1eea19c7-391b-4b3d-b4e6-1d9240b40410@m25g2000yqc.googlegroups.com>...
> Hello,
>
> Let's say I want to define this in java :
>
> package internet;
> public class Downloader {
> public enum DownloadStatus { INITIALIZING, IN_PROGRESS, COMPLETE };
> }
>
> How do I access the enum from matlab.
>
> It seems that it works if the enum is defined outside of any class
> (says Andrew here : http://stackoverflow.com/questions/1223795/using-java-enums-or-public-static-fields-in-matlab
> ) . But In this case, nothing seems to work in matlab
>
> import internet.Downloader.DownloadStatus; does not work, it is not
> recognized
> internet.Downloader.DownloadStatus; does not work
> internet.Downloader.DownloadStatus.INITIALIZING does not work
> creating an empty object Downloader then trying to access
> Downloadstatus does not work
> I tried even the most stupid things, can't make it work
>
> Why I want to do this ? Because there is a method in a java library
> that asks for an enum type defined inside a class, so I need by any
> means to create this enum type in matlab and pass it to the method as
> a parameter.
>
> Thanks for your help :)
You can try 'internet.Downloader$DownloadStatus' within the awtinvoke or javaMethod functions (this should work but I'm not 100% certain).
Alternately, use the method I used for system-tray messages, which has the same issue: http://undocumentedmatlab.com/blog/setting-system-tray-popup-messages/
Yair Altman
http://UndocumentedMatlab.com
|
|
0
|
|
|
|
Reply
|
Yair
|
12/3/2009 7:32:06 AM
|
|
"Yair Altman" wrote in message <hf7phm$cn9$1@fred.mathworks.com>...
> Sylvain <sylvain.boltz@gmail.com> wrote in message <1eea19c7-391b-4b3d-b4e6-1d9240b40410@m25g2000yqc.googlegroups.com>...
> > Hello,
> >
> > Let's say I want to define this in java :
> >
> > package internet;
> > public class Downloader {
> > public enum DownloadStatus { INITIALIZING, IN_PROGRESS, COMPLETE };
> > }
> >
> > How do I access the enum from matlab.
> >
> > It seems that it works if the enum is defined outside of any class
> > (says Andrew here : http://stackoverflow.com/questions/1223795/using-java-enums-or-public-static-fields-in-matlab
> > ) . But In this case, nothing seems to work in matlab
> >
> > import internet.Downloader.DownloadStatus; does not work, it is not
> > recognized
> > internet.Downloader.DownloadStatus; does not work
> > internet.Downloader.DownloadStatus.INITIALIZING does not work
> > creating an empty object Downloader then trying to access
> > Downloadstatus does not work
> > I tried even the most stupid things, can't make it work
> >
> > Why I want to do this ? Because there is a method in a java library
> > that asks for an enum type defined inside a class, so I need by any
> > means to create this enum type in matlab and pass it to the method as
> > a parameter.
> >
> > Thanks for your help :)
>
>
> You can try 'internet.Downloader$DownloadStatus' within the awtinvoke or javaMethod functions (this should work but I'm not 100% certain).
>
> Alternately, use the method I used for system-tray messages, which has the same issue: http://undocumentedmatlab.com/blog/setting-system-tray-popup-messages/
>
> Yair Altman
> http://UndocumentedMatlab.com
>
Based on Yair's suggestion, I found that using the valueOf() method with javaMethod works. For example, javaMethod('valueOf', 'internet.Downloader$DownloadStatus', 'INITIALIZING'). This solves a similar issue I was having, so thanks for the suggestion.
Ben :-)
|
|
0
|
|
|
|
Reply
|
none10 (3395)
|
11/7/2011 2:23:10 AM
|
|
|
2 Replies
467 Views
(page loaded in 0.394 seconds)
Similiar Articles: Enum type inside a class (matlab <-> java interface) - comp.soft ...Hello, Let's say I want to define this in java : package internet; public class Downloader { public enum DownloadStatus { INITIALIZING, IN_P... call java class from Matlab - comp.soft-sys.matlabCalling dll from Matlab - comp.soft-sys.matlab call java class from Matlab - comp.soft-sys.matlab Enum type inside a class (matlab <-> java interface) - comp ... Importing a java class in to Simulink - comp.soft-sys.matlab ...Enum type inside a class (matlab -> java interface) - comp.soft ... Hello, Let's say I want to define this in java : package internet; public class ... read string data ... programming robot using matlab - comp.soft-sys.matlabEnum type inside a class (matlab -> java interface) - comp.soft ... programming robot using matlab - comp.soft-sys.matlab Enum type inside a class (matlab <-> java ... How can I instantiate a class inside another class - comp.lang.c++ ...Enum type inside a class (matlab -> java interface) - comp.soft ... Member functions inside struct or class can slow and degrade ... link in a new type that implements the ... Calling dll from Matlab - comp.soft-sys.matlabcall java class from Matlab - comp.soft-sys.matlab Enum type inside a class (matlab <-> java interface) - comp ... Calling DLL subroutine from C++ - comp.lang.fortran I am ... Initializing IMPLAY from Matlab Code - comp.soft-sys.matlab ...Enum type inside a class (matlab -> java interface) - comp.soft ..... public enum DownloadStatus { INITIALIZING, IN_PROGRESS, COMPLETE }; } How do I access the enum from ... Error while evaluating TimerFCN for timer 'timer-1' - comp.soft ...Enum type inside a class (matlab -> java interface) - comp.soft ... Error while evaluating TimerFCN for timer 'timer-1' - comp ..... or similar (if that really is Java code). ... How to create a TIFF image from a binary raw data - comp.lang.java ...D:\projects\junk\numbered\484Image\Image.java:8: class, interface, or enum ... an image out of 3D data - comp.soft-sys.matlab ... See the DATA_TYPE keywork for read_binary ... Programming using JSP and Tomcat: cannot be resolved to a type ...... Connection" is an interface ... be resolved to a type ... Reading properties file from WEB-INF/classes - comp.lang.java ... ... Mysterious java error - comp.soft-sys.matlab Problem ... Enum type inside a class (matlab <-> java interface) - comp.soft ...Hello, Let's say I want to define this in java : package internet; public class Downloader { public enum DownloadStatus { INITIALIZING, IN_P... Thread Subject: Enum type inside a class (matlab <-> java interface)Hello, Let's say I want to define this in java : package internet; public class Downloader { public enum DownloadStatus { INITIALIZING, IN_PROGRESS, COMPLETE }; 7/22/2012 4:03:44 PM
|