for (int i = 0; i < children.size(); i++) {
Element child = (Element)children.get(i);
String name = child.getName().toLowerCase();
if (name.equals("info")) {
ModuleInfo info = modInfoSerializer.readModuleInfo(child);
if (info != null)
module.setModuleInfo(info);
}
else if (name.equals("parameters")) {
List parameters = paramSerializer.readList(child);
for (int j = 0; j < parameters.size(); j++) {
Parameter param = (Parameter)parameters.get(j);
module.addParameter(param);
}
}
else if (name.equals("outputs")) {
List outputs = new ListSerializer(outputSerializer, "output").readList(child);
for (int j=0; j<outputs.size(); j++)
module.addOutput((Output)outputs.get(j));
}
else if (name.equals("functions")) {
ListSerializer serializer = new ListSerializer(
new FunctionSerializer(
module.getParameterMap(), module.getOutputMap()),
"function");
List functions = serializer.readList(child);
for (int functionIndex=0; functionIndex<functions.size(); functionIndex++) {
Function function = (Function)functions.get(functionIndex);
module.addFunction(function);
}
}
/*
else if (name.equals("function")) {
Function f = new FunctionSerializer(module.getParameterMap()).readFunction(elem);
if (f != null)
module.addFunction(f);
}*/
}
//validate:
if (module.getModuleInfo() == null)
module.setModuleInfo(new ModuleInfo("unknown program"));
//name functions:
List functions = module.getFunctionList();
Function func;
for (int i=0; i<functions.size(); i++) {