return parentNode;
}
public static Consider newInstance(INode parentNode, LinkedList<XMLElement> xmlElementList) throws ElementParseException {
Consider consider = new Consider(parentNode);
XMLElement xmlElement = xmlElementList.poll();
if (!xmlElement.getName().equals(NAME)){
throw new ElementParseException(ElementParseException.NOT_VALID_ELEMENT, "XMLElement is a " + xmlElement.getName() + " not a " + NAME, xmlElementList);
}
for (XMLAttribute xmlAttribute : xmlElement.getXMLAttributeList()){
if (xmlAttribute.getName().equals("nr")){
if (consider.nr == null){
try {consider.nr = Integer.parseInt(xmlAttribute.getValue());}
catch (Exception e) {throw new ElementParseException(ElementParseException.NOT_VALID_TYPE_OF_ATTRIBUTE_ELEMENT, "XMLElement has an attribute " + xmlAttribute.getName() + " with an invalid type", xmlElementList);};
} else {
throw new ElementParseException(ElementParseException.DUPLICATE_ATTRIBUTE_ELEMENT, "XMLElement has a duplicate attribute " + xmlAttribute.getName(), xmlElementList);
}
} else
throw new ElementParseException(ElementParseException.NOT_VALID_ATTRIBUTE_ELEMENT, "XMLElement has not a valid attribute " + xmlAttribute.getName(), xmlElementList);
}
if (!xmlElement.isEmpty()){
while (true){
xmlElement = xmlElementList.peek();
if (xmlElement == null){
throw new ElementParseException(ElementParseException.UNEXPECTED_END_OF_FILE, "Unexpected end of XMLElement list");
}
if (xmlElement.getName().equals(NAME) && xmlElement.isEndElement()){
xmlElement = xmlElementList.poll();
break;
}
if (xmlElement.getName().equals("Proposition") && consider.proposition == null){
consider.proposition = Proposition.newInstance(consider, xmlElementList);
} else if (Justification.isJustification(xmlElement.getName())){
if (consider.justification == null) {
consider.justification = Justification.newInstance(consider, xmlElementList);
} else {
throw new ElementParseException(ElementParseException.DUPLICATE_ELEMENT, "XMLElement list contains a duplicated <Justification> in element " + NAME, xmlElementList);
}
} else if (xmlElement.getName().equals("Typ")){
consider.typList.add(Typ.newInstance(consider, xmlElementList));
} else if (xmlElement.getName().equals("Proposition")){
consider.propositionList.add(Proposition.newInstance(consider, xmlElementList));
} else
throw new ElementParseException(ElementParseException.NOT_VALID_ELEMENT, "The XMLElement " + xmlElement.getName() + " is not valid in " + NAME, xmlElementList);
}
}
return consider;
}