| 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.inferencexml.model; |
| 27 |
|
| 28 |
import dr.inference.model.ReciprocalStatistic; |
| 29 |
import dr.inference.model.Statistic; |
| 30 |
import dr.xml.*; |
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
public class ReciprocalStatisticParser extends AbstractXMLObjectParser { |
| 35 |
|
| 36 |
public static String RECIPROCAL_STATISTIC = "reciprocalStatistic"; |
| 37 |
public static String RECIPROCAL = "reciprocal"; |
| 38 |
|
| 39 |
public String[] getParserNames() { |
| 40 |
return new String[]{getParserName(), RECIPROCAL}; |
| 41 |
} |
| 42 |
|
| 43 |
public String getParserName() { |
| 44 |
return RECIPROCAL_STATISTIC; |
| 45 |
} |
| 46 |
|
| 47 |
public Object parseXMLObject(XMLObject xo) throws XMLParseException { |
| 48 |
|
| 49 |
ReciprocalStatistic recipStatistic = null; |
| 50 |
|
| 51 |
Object child = xo.getChild(0); |
| 52 |
if (child instanceof Statistic) { |
| 53 |
recipStatistic = new ReciprocalStatistic((xo.hasId() ? xo.getId() : "RECIPROCAL"), (Statistic) child); |
| 54 |
} else { |
| 55 |
throw new XMLParseException("Unknown element found in " + getParserName() + " element:" + child); |
| 56 |
} |
| 57 |
|
| 58 |
return recipStatistic; |
| 59 |
} |
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
public String getParserDescription() { |
| 66 |
return "This element returns a statistic that is the element-wise reciprocal of the child statistic."; |
| 67 |
} |
| 68 |
|
| 69 |
public Class getReturnType() { |
| 70 |
return ReciprocalStatistic.class; |
| 71 |
} |
| 72 |
|
| 73 |
public XMLSyntaxRule[] getSyntaxRules() { |
| 74 |
return rules; |
| 75 |
} |
| 76 |
|
| 77 |
private XMLSyntaxRule[] rules = new XMLSyntaxRule[]{ |
| 78 |
new ElementRule(Statistic.class, 1, 1) |
| 79 |
}; |
| 80 |
} |