| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
package dr.evomodel.alloppnet.parsers; |
| 27 |
|
| 28 |
|
| 29 |
import dr.evomodel.alloppnet.speciation.AlloppSpeciesBindings; |
| 30 |
import dr.xml.AbstractXMLObjectParser; |
| 31 |
import dr.xml.AttributeRule; |
| 32 |
import dr.xml.ElementRule; |
| 33 |
import dr.xml.XMLObject; |
| 34 |
import dr.xml.XMLParseException; |
| 35 |
import dr.xml.XMLSyntaxRule; |
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
public class AlloppSpeciesBindingsApSpInfoParser extends |
| 59 |
AbstractXMLObjectParser { |
| 60 |
public static final String APSP = "apsp"; |
| 61 |
public static final String PLOIDYLEVEL = "ploidylevel"; |
| 62 |
|
| 63 |
public String getParserName() { |
| 64 |
return APSP; |
| 65 |
} |
| 66 |
|
| 67 |
@Override |
| 68 |
public Object parseXMLObject(XMLObject xo) throws XMLParseException { |
| 69 |
AlloppSpeciesBindings.Individual[] individuals = |
| 70 |
new AlloppSpeciesBindings.Individual[xo.getChildCount()]; |
| 71 |
for (int ni = 0; ni < individuals.length; ++ni) { |
| 72 |
individuals[ni] = (AlloppSpeciesBindings.Individual) xo.getChild(ni); |
| 73 |
} |
| 74 |
return new AlloppSpeciesBindings.ApSpInfo(xo.getId(), xo.getIntegerAttribute(PLOIDYLEVEL), individuals); |
| 75 |
} |
| 76 |
|
| 77 |
@Override |
| 78 |
public XMLSyntaxRule[] getSyntaxRules() { |
| 79 |
return new XMLSyntaxRule[] { |
| 80 |
AttributeRule.newDoubleRule(PLOIDYLEVEL), |
| 81 |
new ElementRule(AlloppSpeciesBindings.Individual.class, 1, Integer.MAX_VALUE) |
| 82 |
}; |
| 83 |
} |
| 84 |
|
| 85 |
@Override |
| 86 |
public String getParserDescription() { |
| 87 |
return "A diploid or allopolyploid species made of individuals"; |
| 88 |
} |
| 89 |
|
| 90 |
@Override |
| 91 |
public Class getReturnType() { |
| 92 |
return AlloppSpeciesBindings.ApSpInfo.class; |
| 93 |
} |
| 94 |
|
| 95 |
} |