| 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.evomodelxml.treelikelihood; |
| 27 |
|
| 28 |
import dr.evomodel.treelikelihood.utilities.HistoryFilter; |
| 29 |
import dr.util.Identifiable; |
| 30 |
import dr.xml.*; |
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
public class HistoryFilterParser extends AbstractXMLObjectParser { |
| 36 |
|
| 37 |
public static final String NAME = "historyFilter"; |
| 38 |
public static final String MAX_TIME = "maxTime"; |
| 39 |
public static final String MIN_TIME = "minTime"; |
| 40 |
public static final String SOURCES = "sources"; |
| 41 |
public static final String DESTINATIONS = "destinations"; |
| 42 |
public static final String INCLUDE_ALL = "includeAll"; |
| 43 |
|
| 44 |
public Object parseXMLObject(XMLObject xo) throws XMLParseException { |
| 45 |
|
| 46 |
double maxTime = xo.getAttribute(MAX_TIME, Double.POSITIVE_INFINITY); |
| 47 |
double minTime = xo.getAttribute(MIN_TIME, 0.0); |
| 48 |
|
| 49 |
return new HistoryFilter.SetFilter(null, null, maxTime, minTime); |
| 50 |
} |
| 51 |
|
| 52 |
public String getParserName() { |
| 53 |
return NAME; |
| 54 |
} |
| 55 |
|
| 56 |
public String getParserDescription() { |
| 57 |
return "A logger to filter transitions in the complete history."; |
| 58 |
} |
| 59 |
|
| 60 |
public Class getReturnType() { |
| 61 |
return HistoryFilter.class; |
| 62 |
} |
| 63 |
|
| 64 |
public XMLSyntaxRule[] getSyntaxRules() { |
| 65 |
return rules; |
| 66 |
} |
| 67 |
|
| 68 |
private final XMLSyntaxRule[] rules = { |
| 69 |
AttributeRule.newDoubleRule(MAX_TIME, true), |
| 70 |
AttributeRule.newDoubleRule(MIN_TIME, true), |
| 71 |
new ElementRule(SOURCES, |
| 72 |
new XMLSyntaxRule[]{ |
| 73 |
new XORRule( |
| 74 |
AttributeRule.newBooleanRule(INCLUDE_ALL, true), |
| 75 |
new ElementRule(Identifiable.class, 1, Integer.MAX_VALUE) |
| 76 |
), |
| 77 |
} |
| 78 |
, true), |
| 79 |
new ElementRule(DESTINATIONS, |
| 80 |
new XMLSyntaxRule[]{ |
| 81 |
new XORRule( |
| 82 |
AttributeRule.newBooleanRule(INCLUDE_ALL, true), |
| 83 |
new ElementRule(Identifiable.class, 1, Integer.MAX_VALUE) |
| 84 |
), |
| 85 |
} |
| 86 |
, true), |
| 87 |
}; |
| 88 |
} |