01 /* This file is part of the project "Hilbert II" - http://www.qedeq.org
02 *
03 * Copyright 2000-2011, Michael Meyling <mime@qedeq.org>.
04 *
05 * "Hilbert II" is free software; you can redistribute
06 * it and/or modify it under the terms of the GNU General Public
07 * License as published by the Free Software Foundation; either
08 * version 2 of the License, or (at your option) any later version.
09 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
16 package org.qedeq.kernel.xml.handler.module;
17
18 import org.qedeq.kernel.se.dto.module.FormalProofVo;
19 import org.qedeq.kernel.xml.common.XmlSyntaxException;
20 import org.qedeq.kernel.xml.handler.common.AbstractSimpleHandler;
21 import org.qedeq.kernel.xml.handler.common.SimpleAttributes;
22
23
24 /**
25 * Parse a proposition.
26 *
27 * @author Michael Meyling
28 */
29 public class FormalProofHandler extends AbstractSimpleHandler {
30
31 /** Handle formal proofs. */
32 private final FormalProofLineListHandler formalProofLineListHandler;
33
34 /** Value object. */
35 private FormalProofVo proof;
36
37 /**
38 * Deals with propositions.
39 *
40 * @param handler Parent handler.
41 */
42 public FormalProofHandler(final AbstractSimpleHandler handler) {
43 super(handler, "FORMAL_PROOF");
44 formalProofLineListHandler = new FormalProofLineListHandler(this);
45 }
46
47 public final void init() {
48 proof = null;
49 }
50
51 /**
52 * Get proof.
53 *
54 * @return Proof.
55 */
56 public final FormalProofVo getProof() {
57 return proof;
58 }
59
60 public final void startElement(final String name, final SimpleAttributes attributes)
61 throws XmlSyntaxException {
62 if (getStartTag().equals(name)) {
63 proof = new FormalProofVo();
64 } else if (formalProofLineListHandler.getStartTag().equals(name)) {
65 changeHandler(formalProofLineListHandler, name, attributes);
66 } else {
67 throw XmlSyntaxException.createUnexpectedTagException(name);
68 }
69 }
70
71 public final void endElement(final String name) throws XmlSyntaxException {
72 if (getStartTag().equals(name)) {
73 // nothing to do
74 } else if (formalProofLineListHandler.getStartTag().equals(name)) {
75 proof.setFormalProofLineList(formalProofLineListHandler.getFormalProofLineList());
76 } else {
77 throw XmlSyntaxException.createUnexpectedTagException(name);
78 }
79 }
80
81 }
|