I am currently trying to use a Java package in Matlab, which works fine so far. But now I need to do a Switch case in Matlab depending on a Java enum. Here a small example code:
Java:
package abc;
class Parser {
enum FileType {
UNHANDLED,
XML,
BINARY
}
public getFileType(){
this.fileType;
}
private FileType fileType;
}
In Matlab, I want to do the following:
parser = abc.Parser();
Switch (parser.getFileType()) {
case abc.FileType.BINARY:
%TODO
break;
}
According to using Java enums or public static fields in MATLAB, I can access the enum elements with
javaMethod('valueOf', 'abc.Parser$FileType', 'BINARY');
but if I use this line in the Switch case:
parser = abc.Parser();
Switch(Parser.getFileType()){
case javaMethod('valueOf', 'abc.Parser$FileType', 'BINARY');
%TODO
break;
}
I get the error
??? SWITCH expression must be a scalar or string constant.
Has anyone a work around to achieve my desired behaviour?