How do I get all the Enum values ββin XMLBeans?
Apache XMLBeans can be used to create Java classes and interfaces from XML Schema Definition (XSD) files. It also generates Enums based on StringEnumAbstractBase and StringEnumAbstractBase.Table to represent domain values. They are convenient for entering only valid values. However, I want to get all these values ββto create a JCombobox, JTable or html.
Is there an XMLBeans API request to get all the Enum values ββfrom the generated class? Is some kind of Java reflection available the only choice available?
thank
+1
source to share
2 answers
Here's another way to get it:
public static List<String> getEnumValueList(XmlString xmlString){
List<String> values = new ArrayList<String>();
SchemaStringEnumEntry valArr[] = xmlString.schemaType().getStringEnumEntries();
for(SchemaStringEnumEntry val : valArr){
values.add(val.getString());
}
return values;
}
So, to get a list of ModelType enum values, I do the following:
getEnumValueList(ModelType.Factory.newInstance());
+2
Preethi
source
to share