use of cbit.vcell.solver.MathOverrides in project vcell by virtualcell.
the class XmlReader method getMathOverrides.
/**
* This method returns a MathOverrides object from a XML Element.
* Creation date: (5/21/2001 3:05:17 PM)
* @return cbit.vcell.solver.MathOverrides
* @param param org.jdom.Element
*/
private MathOverrides getMathOverrides(Element param, Simulation simulation) throws XmlParseException {
MathOverrides mathOverrides = null;
try {
// Get the constants
Object[] elements = param.getChildren().toArray();
Vector<ConstantArraySpec> v1 = new Vector<ConstantArraySpec>();
Vector<Constant> v2 = new Vector<Constant>();
for (int i = 0; i < elements.length; i++) {
Element e = (Element) elements[i];
Attribute array = e.getAttribute(XMLTags.ConstantArraySpec);
if (array != null) {
// collect scan overrides
String name = e.getAttributeValue(XMLTags.NameAttrTag);
int type = array.getIntValue();
v1.add(ConstantArraySpec.createFromString(name, e.getText(), type));
} else {
// collect regular overrides
v2.add(getConstant(e));
}
}
Constant[] constants = (Constant[]) BeanUtils.getArray(v2, Constant.class);
ConstantArraySpec[] specs = (ConstantArraySpec[]) BeanUtils.getArray(v1, ConstantArraySpec.class);
// create new MathOverrides object
mathOverrides = new MathOverrides(simulation, constants, specs);
} catch (ExpressionException e) {
e.printStackTrace();
throw new XmlParseException("A ExpressionException was fired when adding a Constant to the MathOverrides", e);
} catch (DataConversionException e2) {
e2.printStackTrace();
throw new XmlParseException("A DataConversionException occured when reading a ConstantArraySpec type", e2);
}
return mathOverrides;
}
Aggregations