Search in sources :

Example 1 with Location

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;
}
Also used : Attribute(dr.util.Attribute) Taxon(dr.evolution.util.Taxon) Date(dr.evolution.util.Date) Location(dr.evolution.util.Location)

Aggregations

Date (dr.evolution.util.Date)1 Location (dr.evolution.util.Location)1 Taxon (dr.evolution.util.Taxon)1 Attribute (dr.util.Attribute)1