Closed MatFi closed 2 years ago
We may have some low level support in https://github.com/JuliaInterop/JavaCall.jl/blob/master/src/JNI.jl . Essentially the question comes down to how you would work with Enum types via JNI. If you can link that documentation, we can build up from there.
No, we do not have any specific support for it as far as I know. I imagine you can get the id and name fields of the Enum and work with that?
Sadly this seems not sufficient to me as I can not get set the fields this way (not an Java expert).
Also, separately, I guess you have seen Taro.jl?
Thanks, in fact Taro.jl is what I want to extend with some formatting features, this is why I came across this
This look informative: https://stackoverflow.com/questions/11225261/how-to-return-enum-from-jni
This look informative: https://stackoverflow.com/questions/11225261/how-to-return-enum-from-jni
Worked for me! Thanks a lot!!
class = Symbol("org.apache.poi.ss.usermodel.ConditionalFormattingThreshold\$RangeType")
jclass = JavaCall.javaclassname(class)
jclassptr = JavaCall.JNI.FindClass(jclass)
jfieldID = JavaCall.JNI.GetStaticFieldID(jclassptr,"PERCENT",JavaCall.signature(JavaObject{class}))
jenum = JavaCall.JNI.GetStaticObjectField(jclassptr,jfieldID)
ret = JavaCall.convert_result(JavaObject{class},jenum)
After some investigation I noticed that it is also possible to simply use the jfield
function. so this JavaCall.jl actually supports enums to some extend
enum = @jimport "org.apache.poi.ss.usermodel.ConditionalFormattingThreshold\$RangeType"
ret = jfield(enum,"MAX",enum)
Could you do
enum = @jimport raw"org.apache.poi.ss.usermodel.ConditionalFormattingThreshold$RangeType"
ret = jfield(enum,"MAX",enum)
Perhaps another approach would be to use listfields(enum, "MAX")
I am correct with the assumption that there is currently no way to handle Java
Enum
types. If I am wrong here, can someone provide me an example please?In my case the specific problems appear when working with this Java object.