if (elementName.equals("speciesReference")
&& (reaction.getLevel() > 1 || (reaction
.getLevel() == 1 && reaction
.getVersion() == 2))) {
SpeciesReference speciesReference = (SpeciesReference) newContextObject;
speciesReference.initDefaults();
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 {
log4jLogger.warn("The element " + elementName + " is not recognized");
}
} else if (elementName.equals("specieReference")
&& reaction.getLevel() == 1) {
SpeciesReference speciesReference = (SpeciesReference) newContextObject;
speciesReference.initDefaults();
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 {
log4jLogger.warn("The element " + elementName + " is not recognized");
}
} else if (elementName
.equals("modifierSpeciesReference")
&& list.getSBaseListType().equals(
ListOf.Type.listOfModifiers)
&& reaction.getLevel() > 1) {
ModifierSpeciesReference modifierSpeciesReference = (ModifierSpeciesReference) newContextObject;
reaction.addModifier(modifierSpeciesReference);
return modifierSpeciesReference;
} else {
log4jLogger.warn("The element " + elementName + " is not recognized");
}
} else if (list.getParentSBMLObject() instanceof KineticLaw) {
KineticLaw kineticLaw = (KineticLaw) list
.getParentSBMLObject();
// Level 3: parameter and listOfParameters =>
// localParameter and listOfLocalParameter
if (elementName.equals("localParameter")
&& list.getSBaseListType().equals(
ListOf.Type.listOfLocalParameters)
&& kineticLaw.getLevel() >= 3) {
LocalParameter localParameter = (LocalParameter) newContextObject;
kineticLaw.addLocalParameter(localParameter);
return localParameter;
} else if (elementName.equals("parameter")
&& list.getSBaseListType().equals(
ListOf.Type.listOfLocalParameters)
&& kineticLaw.isSetLevel()
&& kineticLaw.getLevel() < 3) {
LocalParameter localParameter = new LocalParameter(
(Parameter) newContextObject);
kineticLaw.addLocalParameter(localParameter);
return localParameter;
} else {
log4jLogger.warn("The element " + elementName + " is not recognized");
}
} else if (list.getParentSBMLObject() instanceof Event) {
Event event = (Event) list.getParentSBMLObject();
if (elementName.equals("eventAssignment")
&& list.getSBaseListType().equals(
ListOf.Type.listOfEventAssignments)
&& event.getLevel() > 1) {
EventAssignment eventAssignment = (EventAssignment) newContextObject;
event.addEventAssignment(eventAssignment);
return eventAssignment;
} else {
log4jLogger.warn("The element " + elementName + " is not recognized");
}
} else {
log4jLogger.warn("The element " + elementName + " is not recognized");
}
} 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 Event) {
Event event = (Event) contextObject;
if (elementName.equals("listOfEventAssignments")) {
ListOf<EventAssignment> listOfEventAssignments = (ListOf<EventAssignment>) newContextObject;
event.setListOfEventAssignments(listOfEventAssignments);
return listOfEventAssignments;
} else if (elementName.equals("trigger")) {
Trigger trigger = (Trigger) newContextObject;
event.setTrigger(trigger);
return trigger;
} else if (elementName.equals("delay")) {
Delay delay = (Delay) newContextObject;
event.setDelay(delay);
return delay;
} else if (elementName.equals("priority")) {
Priority priority = (Priority) newContextObject;
event.setPriority(priority);
return priority;
} else {
log4jLogger.warn("The element " + elementName + " is not recognized");
}
} else if (contextObject instanceof Reaction) {
Reaction reaction = (Reaction) contextObject;
if (elementName.equals("listOfReactants")) {
ListOf<SpeciesReference> listOfReactants = (ListOf<SpeciesReference>) newContextObject;
reaction.setListOfReactants(listOfReactants);
return listOfReactants;
} else if (elementName.equals("listOfProducts")) {
ListOf<SpeciesReference> listOfProducts = (ListOf<SpeciesReference>) newContextObject;
reaction.setListOfProducts(listOfProducts);
return listOfProducts;
} else if (elementName.equals("listOfModifiers")
&& reaction.getLevel() > 1) {
ListOf<ModifierSpeciesReference> listOfModifiers = (ListOf<ModifierSpeciesReference>) newContextObject;
reaction.setListOfModifiers(listOfModifiers);
return listOfModifiers;
} else if (elementName.equals("kineticLaw")) {
KineticLaw kineticLaw = (KineticLaw) newContextObject;
reaction.setKineticLaw(kineticLaw);
return kineticLaw;
} else {
log4jLogger.warn("The element " + elementName + " is not recognized");
}
} else if (contextObject instanceof SpeciesReference) {
SpeciesReference speciesReference = (SpeciesReference) contextObject;
if (elementName.equals("stoichiometryMath")) {
StoichiometryMath stoichiometryMath = (StoichiometryMath) newContextObject;
speciesReference.setStoichiometryMath(stoichiometryMath);
return stoichiometryMath;
} else {
log4jLogger.warn("The element " + elementName + " is not recognized");
}