View Javadoc

1   /* This file is part of the project "Hilbert II" - http://www.qedeq.org" target="alexandria_uri">http://www.qedeq.org
2    *
3    * Copyright 2000-2014,  Michael Meyling <mime@qedeq.org>.
4    *
5    * "Hilbert II" is free software; you can redistribute
6    * it and/or modify it under the terms of the GNU General Public
7    * License as published by the Free Software Foundation; either
8    * version 2 of the License, or (at your option) any later version.
9    *
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.bo.logic;
17  
18  import org.qedeq.base.io.Version;
19  import org.qedeq.kernel.bo.logic.proof.checker.ProofChecker0Impl;
20  import org.qedeq.kernel.bo.logic.proof.checker.ProofChecker1Impl;
21  import org.qedeq.kernel.bo.logic.proof.checker.ProofChecker2Impl;
22  import org.qedeq.kernel.bo.logic.proof.common.ProofChecker;
23  import org.qedeq.kernel.bo.logic.proof.common.ProofCheckerFactory;
24  
25  
26  
27  /**
28   * Factory implementation for {@link ProofChecker}s.
29   *
30   * @author  Michael Meyling
31   */
32  public class ProofCheckerFactoryImpl implements ProofCheckerFactory {
33  
34      public boolean isRuleVersionSupported(final String ruleVersion) {
35          try {
36              new Version(ruleVersion);
37          } catch (RuntimeException e) {
38              return false;
39          }
40          if ("0.00.00".equals(ruleVersion)) {
41              return true;
42          } else if ("0.01.00".equals(ruleVersion)) {
43              return true;
44          } else if ("0.02.00".equals(ruleVersion)) {
45              return true;
46          }
47          return false;
48      }
49  
50      public ProofChecker createProofChecker(final Version ruleVersion) {
51          if (ruleVersion.equals("0.00.00")) {
52              return new ProofChecker0Impl();
53          } else if (ruleVersion.equals("0.01.00")) {
54              return new ProofChecker1Impl();
55          } else if (ruleVersion.equals("0.02.00")) {
56              return new ProofChecker2Impl();
57          }
58          // not found, so we take the best one we have
59          return new ProofChecker2Impl();
60      }
61  
62  
63  }