Model model = (Model) list.getParentSBMLObject();
if (elementName.equals("unitDefinition")
&& list.getSBaseListType().equals(
ListOf.Type.listOfUnitDefinitions)) {
UnitDefinition unitDefinition = (UnitDefinition) newContextObject;
model.addUnitDefinition(unitDefinition);
return unitDefinition;
} else if (elementName.equals("compartment")
&& list.getSBaseListType().equals(
ListOf.Type.listOfCompartments)) {
Compartment compartment = (Compartment) newContextObject;
model.addCompartment(compartment);
return compartment;
} else if (elementName.equals("specie")
&& list.getSBaseListType().equals(
ListOf.Type.listOfSpecies)) {
Species species = (Species) newContextObject;
model.addSpecies(species);
return species;
} else if (elementName.equals("parameter")
&& list.getSBaseListType().equals(
ListOf.Type.listOfParameters)) {
Parameter parameter = (Parameter) newContextObject;
model.addParameter(parameter);
return parameter;
} else if (elementName.equals("algebraicRule")
&& list.getSBaseListType().equals(
ListOf.Type.listOfRules)) {
AlgebraicRule rule = (AlgebraicRule) newContextObject;
model.addRule(rule);
return rule;
} else if (elementName.equals("assignmentRule") // TODO : wrong, there are no assignmentRule element, only more specialize rule
&& list.getSBaseListType().equals(
ListOf.Type.listOfRules)) {
AssignmentRule rule = (AssignmentRule) newContextObject;
model.addRule(rule);
return rule;
} else if (elementName.equals("reaction")
&& list.getSBaseListType().equals(
ListOf.Type.listOfReactions)) {
Reaction reaction = (Reaction) newContextObject;
model.addReaction(reaction);
return reaction;
} else {
// TODO : SBML syntax error, throw an exception?
}
} else if (list.getParentSBMLObject() instanceof UnitDefinition) {
UnitDefinition unitDefinition = (UnitDefinition) list
.getParentSBMLObject();
if (elementName.equals("unit")
&& list.getSBaseListType().equals(
ListOf.Type.listOfUnits)) {
Unit unit = (Unit) newContextObject;
unitDefinition.addUnit(unit);
return unit;
} else {
// TODO : SBML syntax error, throw an exception?
}
} else if (list.getParentSBMLObject() instanceof Reaction) {
Reaction reaction = (Reaction) list
.getParentSBMLObject();
if (elementName.equals("specieReference")) {
SpeciesReference speciesReference = (SpeciesReference) newContextObject;
if (list.getSBaseListType().equals(
ListOf.Type.listOfReactants)) {
reaction.addReactant(speciesReference);
return speciesReference;
} else if (list.getSBaseListType().equals(
ListOf.Type.listOfProducts)) {
reaction.addProduct(speciesReference);
return speciesReference;
} else {
// TODO : SBML syntax error, throw an exception?
}
} else {
// TODO : SBML syntax error, throw an exception?
}
} else if (list.getParentSBMLObject() instanceof KineticLaw) {
KineticLaw kineticLaw = (KineticLaw) list
.getParentSBMLObject();
if (elementName.equals("parameter")
&& list.getSBaseListType().equals(
ListOf.Type.listOfParameters)) {
LocalParameter localParameter = (LocalParameter) newContextObject;
kineticLaw.addParameter(localParameter);
return localParameter;
} else {
// TODO : SBML syntax error, throw an exception?
}
} else {
// TODO : SBML syntax error, throw an exception?
}
} else if (contextObject instanceof UnitDefinition) {
UnitDefinition unitDefinition = (UnitDefinition) contextObject;
if (elementName.equals("listOfUnits")) {
ListOf<Unit> listOfUnits = (ListOf<Unit>) newContextObject;
unitDefinition.setListOfUnits(listOfUnits);
return listOfUnits;
}
} else if (contextObject instanceof Reaction) {
Reaction reaction = (Reaction) contextObject;