use of dr.evolution.util.Location in project beast-mcmc by beast-dev.
the class TaxonParser method parseXMLObject.
public Object parseXMLObject(XMLObject xo) throws XMLParseException {
if (dr.xml.XMLParser.ID.contains("\'") && dr.xml.XMLParser.ID.contains("\"")) {
// as it won't be possible to wrap it in either.
throw new XMLParseException("Illegal taxon name, " + dr.xml.XMLParser.ID + ", - contains both single and double quotes");
}
Taxon taxon = new Taxon(xo.getStringAttribute(dr.xml.XMLParser.ID));
for (int i = 0; i < xo.getChildCount(); i++) {
Object child = xo.getChild(i);
if (child instanceof Date) {
taxon.setDate((Date) child);
} else if (child instanceof Location) {
taxon.setLocation((Location) child);
} else if (child instanceof Attribute) {
final Attribute attr = (Attribute) child;
taxon.setAttribute(attr.getAttributeName(), attr.getAttributeValue());
} else if (child instanceof Attribute[]) {
Attribute[] attrs = (Attribute[]) child;
for (Attribute attr : attrs) {
taxon.setAttribute(attr.getAttributeName(), attr.getAttributeValue());
}
} else {
throw new XMLParseException("Unrecognized element found in taxon element");
}
}
return taxon;
}