Debian Codegraph @

src/dr/inferencexml/model/ImmutableParameterParser.java

raw symbols SCIP
1 package dr.inferencexml.model;
2
3 import dr.inference.model.Bounds;
4 import dr.inference.model.Parameter;
5 import dr.inference.model.Statistic;
6 import dr.xml.*;
7
8 /**
9 * Created by Guy Baele on 18/12/15.
10 */
11 public class ImmutableParameterParser extends AbstractXMLObjectParser {
12
13 public static final String IMMUTABLE_PARAMETER = "immutableParameter";
14
15 public Object parseXMLObject(XMLObject xo) throws XMLParseException {
16 final Statistic statistic = (Statistic) xo.getChild(Statistic.class);
17
18 Parameter.Abstract immutableParameter = new Parameter.Abstract() {
19 public void setParameterValueNotifyChangedAll(int dim, double value) {
20 throw new RuntimeException("Forbidden call to ImmutableParameter.");
21 }
22 public void setParameterValueQuietly(int dim, double value) {
23 throw new RuntimeException("Forbidden call to ImmutableParameter.");
24 }
25 public void storeValues() {
26 //do nothing
27 }
28 public void restoreValues() {
29 //do nothing
30 }
31 public void acceptValues() {
32 //do nothing
33 }
34
35 public int getDimension() {
36 return statistic.getDimension();
37 }
38
39 public void setParameterValue(int dim, double value) {
40 throw new RuntimeException("Forbidden call to ImmutableParameter.");
41 }
42 public double getParameterValue(int dim) {
43 return statistic.getStatisticValue(dim);
44 }
45 public String getParameterName() {
46 if (getId() == null)
47 return "immutable." + statistic.getStatisticName();
48 return getId();
49 }
50 public void adoptValues(Parameter source) {
51 throw new RuntimeException("Forbidden call to ImmutableParameter.");
52 }
53 public void addDimension(int index, double value) {
54 throw new RuntimeException("Forbidden call to ImmutableParameter.");
55 }
56 public double removeDimension(int index) {
57 throw new RuntimeException("Forbidden call to ImmutableParameter.");
58 }
59 public void addBounds(Bounds<Double> bounds) {
60 throw new RuntimeException("Forbidden call to ImmutableParameter.");
61 }
62 public Bounds<Double> getBounds() {
63 throw new RuntimeException("Forbidden call to ImmutableParameter.");
64 }
65 };
66
67 return immutableParameter;
68 }
69
70 public XMLSyntaxRule[] getSyntaxRules() {
71 return rules;
72 }
73
74 private final XMLSyntaxRule[] rules = {
75 new ElementRule(Statistic.class),
76 };
77
78 public String getParserDescription() {
79 return "An immutable parameter generated from a statistic.";
80 }
81
82 public Class getReturnType() {
83 return Parameter.class;
84 }
85
86 public String getParserName() {
87 return IMMUTABLE_PARAMETER;
88 }
89
90 }