return parentNode;
}
public static Constructor newInstance(INode parentNode, LinkedList<XMLElement> xmlElementList) throws ElementParseException {
Constructor constructor = new Constructor(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("kind")){
if (constructor.kind == null){
if (Kind.valueOf(xmlAttribute.getValue()) != null) {
constructor.kind = Kind.valueOf(xmlAttribute.getValue());
} else
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
if (xmlAttribute.getName().equals("nr")){
if (constructor.nr == null){
try {constructor.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
if (xmlAttribute.getName().equals("aid")){
if (constructor.aid == null){
constructor.aid = xmlAttribute.getValue();
} else {
throw new ElementParseException(ElementParseException.DUPLICATE_ATTRIBUTE_ELEMENT, "XMLElement has a duplicate attribute " + xmlAttribute.getName(), xmlElementList);
}
} else
if (xmlAttribute.getName().equals("relnr")){
if (constructor.relnr == null){
try {constructor.relnr = 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
if (xmlAttribute.getName().equals("redefnr")){
if (constructor.redefnr == null){
try {constructor.redefnr = 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
if (xmlAttribute.getName().equals("superfluous")){
if (constructor.superfluous == null){
try {constructor.superfluous = 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
if (xmlAttribute.getName().equals("absredefnr")){
if (constructor.absredefnr == null){
try {constructor.absredefnr = 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
if (xmlAttribute.getName().equals("redefaid")){
if (constructor.redefaid == null){
constructor.redefaid = xmlAttribute.getValue();
} else {
throw new ElementParseException(ElementParseException.DUPLICATE_ATTRIBUTE_ELEMENT, "XMLElement has a duplicate attribute " + xmlAttribute.getName(), xmlElementList);
}
} else
if (xmlAttribute.getName().equals("structmodeaggrnr")){
if (constructor.structmodeaggrnr == null){
try {constructor.structmodeaggrnr = 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
if (xmlAttribute.getName().equals("aggregbase")){
if (constructor.aggregbase == null){
try {constructor.aggregbase = 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("Properties")){
if (constructor.properties == null) {
constructor.properties = Properties.newInstance(constructor, xmlElementList);
} else {
throw new ElementParseException(ElementParseException.DUPLICATE_ELEMENT, "XMLElement list contains a duplicated <Properties> in element " + NAME, xmlElementList);
}
} else if (xmlElement.getName().equals("ArgTypes")){
if (constructor.argTypes == null) {
constructor.argTypes = ArgTypes.newInstance(constructor, xmlElementList);
} else {
throw new ElementParseException(ElementParseException.DUPLICATE_ELEMENT, "XMLElement list contains a duplicated <ArgTypes> in element " + NAME, xmlElementList);
}
} else if (xmlElement.getName().equals("StructLoci")){
if (constructor.structLoci == null) {
constructor.structLoci = StructLoci.newInstance(constructor, xmlElementList);
} else {
throw new ElementParseException(ElementParseException.DUPLICATE_ELEMENT, "XMLElement list contains a duplicated <StructLoci> in element " + NAME, xmlElementList);
}
} else if (xmlElement.getName().equals("Typ")){
constructor.typList.add(Typ.newInstance(constructor, xmlElementList));
} else if (xmlElement.getName().equals("Fields")){
if (constructor.fields == null) {
constructor.fields = Fields.newInstance(constructor, xmlElementList);
} else {
throw new ElementParseException(ElementParseException.DUPLICATE_ELEMENT, "XMLElement list contains a duplicated <Fields> in element " + NAME, xmlElementList);
}
} else
throw new ElementParseException(ElementParseException.NOT_VALID_ELEMENT, "The XMLElement " + xmlElement.getName() + " is not valid in " + NAME, xmlElementList);
}
}
return constructor;
}