return parentNode;
}
public static CCluster newInstance(INode parentNode, LinkedList<XMLElement> xmlElementList) throws ElementParseException {
CCluster cCluster = new CCluster(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("aid")){
if (cCluster.aid == null){
cCluster.aid = xmlAttribute.getValue();
} else {
throw new ElementParseException(ElementParseException.DUPLICATE_ATTRIBUTE_ELEMENT, "XMLElement has a duplicate attribute " + xmlAttribute.getName(), xmlElementList);
}
} else
if (xmlAttribute.getName().equals("nr")){
if (cCluster.nr == null){
try {cCluster.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("ErrorCluster")){
if (cCluster.errorCluster == null) {
cCluster.errorCluster = ErrorCluster.newInstance(cCluster, xmlElementList);
} else {
throw new ElementParseException(ElementParseException.DUPLICATE_ELEMENT, "XMLElement list contains a duplicated <ErrorCluster> in element " + NAME, xmlElementList);
}
} else if (xmlElement.getName().equals("ArgTypes")){
if (cCluster.argTypes == null) {
cCluster.argTypes = ArgTypes.newInstance(cCluster, xmlElementList);
} else {
throw new ElementParseException(ElementParseException.DUPLICATE_ELEMENT, "XMLElement list contains a duplicated <ArgTypes> in element " + NAME, xmlElementList);
}
} else if (xmlElement.getName().equals("Cluster") && cCluster.cluster1 == null) {
cCluster.cluster1 = Cluster.newInstance(cCluster, xmlElementList);
} else if (xmlElement.getName().equals("Typ")){
if (cCluster.typ == null) {
cCluster.typ = Typ.newInstance(cCluster, xmlElementList);
} else {
throw new ElementParseException(ElementParseException.DUPLICATE_ELEMENT, "XMLElement list contains a duplicated <Typ> in element " + NAME, xmlElementList);
}
} else if (xmlElement.getName().equals("Cluster") && cCluster.cluster2 == null){
if (cCluster.cluster2 == null) {
cCluster.cluster2 = Cluster.newInstance(cCluster, xmlElementList);
} else {
throw new ElementParseException(ElementParseException.DUPLICATE_ELEMENT, "XMLElement list contains a duplicated <Cluster> in element " + NAME, xmlElementList);
}
} else if (xmlElement.getName().equals("Cluster")){
if (cCluster.cluster3 == null) {
cCluster.cluster3 = Cluster.newInstance(cCluster, xmlElementList);
} else {
throw new ElementParseException(ElementParseException.DUPLICATE_ELEMENT, "XMLElement list contains a duplicated <Cluster> in element " + NAME, xmlElementList);
}
} else
throw new ElementParseException(ElementParseException.NOT_VALID_ELEMENT, "The XMLElement " + xmlElement.getName() + " is not valid in " + NAME, xmlElementList);
}
}
return cCluster;
}