1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.qedeq.kernel.xml.handler.module;
17
18 import org.qedeq.kernel.se.base.module.Hypothesis;
19 import org.qedeq.kernel.se.dto.module.HypothesisVo;
20 import org.qedeq.kernel.xml.common.XmlSyntaxException;
21 import org.qedeq.kernel.xml.handler.common.AbstractSimpleHandler;
22 import org.qedeq.kernel.xml.handler.common.SimpleAttributes;
23
24
25
26
27
28
29
30 public class HypothesisHandler extends AbstractSimpleHandler {
31
32
33 private final FormulaHandler formulaHandler;
34
35
36 private HypothesisVo hypothesis;
37
38
39
40
41
42
43 public HypothesisHandler(final AbstractSimpleHandler handler) {
44 super(handler, "HYPOTHESIS");
45 formulaHandler = new FormulaHandler(this);
46 }
47
48 public final void init() {
49 hypothesis = null;
50 }
51
52
53
54
55
56
57 public final Hypothesis getHypothesis() {
58 return hypothesis;
59 }
60
61 public final void startElement(final String name, final SimpleAttributes attributes)
62 throws XmlSyntaxException {
63 if (getStartTag().equals(name)) {
64 hypothesis = new HypothesisVo();
65 hypothesis.setLabel(attributes.getString("label"));
66 } else if (formulaHandler.getStartTag().equals(name)) {
67 changeHandler(formulaHandler, name, attributes);
68 } else {
69 throw XmlSyntaxException.createUnexpectedTagException(name);
70 }
71 }
72
73 public final void endElement(final String name) throws XmlSyntaxException {
74 if (getStartTag().equals(name)) {
75
76 } else if (formulaHandler.getStartTag().equals(name)) {
77 hypothesis.setFormula(formulaHandler.getFormula());
78 } else {
79 throw XmlSyntaxException.createUnexpectedTagException(name);
80 }
81 }
82
83 }