Debian Codegraph @

src/dr/evomodelxml/treelikelihood/HistoryFilterParser.java

raw symbols SCIP
1 /*
2 * HistoryFilterParser.java
3 *
4 * Copyright (c) 2002-2016 Alexei Drummond, Andrew Rambaut and Marc Suchard
5 *
6 * This file is part of BEAST.
7 * See the NOTICE file distributed with this work for additional
8 * information regarding copyright ownership and licensing.
9 *
10 * BEAST is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU Lesser General Public License as
12 * published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
14 *
15 * BEAST is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with BEAST; if not, write to the
22 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
23 * Boston, MA 02110-1301 USA
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 * @author Marc A. Suchard
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) // TODO Fix type
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) // TODO Fix type
84 ),
85 }
86 , true),
87 };
88 }