public Module parse(Element element) {
if (element.getChild("treatAs", NS) == null) {
return null;
}
SimpleListExtension sle = new SimpleListExtensionImpl();
sle.setTreatAs(element.getChildText("treatAs", NS));
Element listInfo = element.getChild("listinfo", NS);
List groups = listInfo.getChildren("group", NS);
ArrayList values = new ArrayList();
for (int i = 0; (groups != null) && (i < groups.size()); i++) {
Element ge = (Element) groups.get(i);
Namespace ns = (ge.getAttribute("ns") == null) ? element.getNamespace() : Namespace.getNamespace(ge.getAttributeValue("ns"));
String elementName = ge.getAttributeValue("element");
String label = ge.getAttributeValue("label");
values.add(new Group(ns, elementName, label));
}
sle.setGroupFields((Group[]) values.toArray(new Group[values.size()]));
values = (values.size() == 0) ? values : new ArrayList();
List sorts = listInfo.getChildren("sort", NS);
for (int i = 0; (sorts != null) && (i < sorts.size()); i++) {
Element se = (Element) sorts.get(i);
System.out.println("Parse cf:sort "+se.getAttributeValue("element")+se.getAttributeValue("data-type"));
Namespace ns = (se.getAttributeValue("ns") == null) ? element.getNamespace() : Namespace.getNamespace(se.getAttributeValue("ns"));
String elementName = se.getAttributeValue("element");
String label = se.getAttributeValue("label");
String dataType = se.getAttributeValue("data-type");
boolean defaultOrder = (se.getAttributeValue("default") == null) ? false : new Boolean(se.getAttributeValue("default")).booleanValue();
values.add(new Sort(ns, elementName, dataType, label, defaultOrder));
}
sle.setSortFields((Sort[]) values.toArray(new Sort[values.size()]));
insertValues(sle, element.getChildren());
return sle;
}