|
1 |
| |
|
2 |
| |
|
3 |
| |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| |
|
8 |
| |
|
9 |
| |
|
10 |
| |
|
11 |
| |
|
12 |
| |
|
13 |
| |
|
14 |
| |
|
15 |
| |
|
16 |
| |
|
17 |
| |
|
18 |
| package org.qedeq.kernel.bo.control; |
|
19 |
| |
|
20 |
| import org.qedeq.kernel.bo.logic.DefaultExistenceChecker; |
|
21 |
| import org.qedeq.kernel.bo.module.ModuleDataException; |
|
22 |
| import org.qedeq.kernel.bo.module.ModuleProperties; |
|
23 |
| import org.qedeq.kernel.bo.module.ModuleReferenceList; |
|
24 |
| |
|
25 |
| |
|
26 |
| |
|
27 |
| |
|
28 |
| |
|
29 |
| |
|
30 |
| |
|
31 |
| |
|
32 |
| public class ModuleConstantsExistenceChecker extends DefaultExistenceChecker { |
|
33 |
| |
|
34 |
| |
|
35 |
| private final ModuleProperties prop; |
|
36 |
| |
|
37 |
| |
|
38 |
| |
|
39 |
| |
|
40 |
| |
|
41 |
| |
|
42 |
| |
|
43 |
| |
|
44 |
59
| public ModuleConstantsExistenceChecker(final ModuleProperties prop)
|
|
45 |
| throws ModuleDataException { |
|
46 |
59
| super();
|
|
47 |
59
| this.prop = prop;
|
|
48 |
59
| init();
|
|
49 |
| } |
|
50 |
| |
|
51 |
| |
|
52 |
| |
|
53 |
| |
|
54 |
| |
|
55 |
| |
|
56 |
| |
|
57 |
| |
|
58 |
| |
|
59 |
| |
|
60 |
59
| public void init() throws ModuleDataException {
|
|
61 |
59
| clear();
|
|
62 |
59
| boolean identityOperatorExists = false;
|
|
63 |
59
| boolean classOperatorExists = false;
|
|
64 |
59
| final ModuleReferenceList list = prop.getRequiredModules();
|
|
65 |
59
| String identityOperator = null;
|
|
66 |
59
| for (int i = 0; i < list.size(); i++) {
|
|
67 |
38
| if (list.getModuleProperties(i).getExistenceChecker().equalityOperatorExists()) {
|
|
68 |
22
| if (identityOperatorExists) {
|
|
69 |
| |
|
70 |
0
| throw new IdentityOperatorAlreadyExistsException(123476,
|
|
71 |
| "identity operator already defined", list.getModuleContext(i)); |
|
72 |
| } |
|
73 |
22
| identityOperatorExists = true;
|
|
74 |
22
| identityOperator = list.getLabel(i) + "."
|
|
75 |
| + list.getModuleProperties(i).getExistenceChecker().getIdentityOperator(); |
|
76 |
| } |
|
77 |
38
| if (list.getModuleProperties(i).getExistenceChecker().classOperatorExists()) {
|
|
78 |
0
| if (classOperatorExists) {
|
|
79 |
| |
|
80 |
0
| throw new ClassOperatorAlreadyExistsException(123478,
|
|
81 |
| "class operator already defined", list.getModuleContext(i)); |
|
82 |
| } |
|
83 |
0
| classOperatorExists = true;
|
|
84 |
| } |
|
85 |
| } |
|
86 |
59
| setIdentityOperatorDefined(identityOperatorExists, identityOperator);
|
|
87 |
59
| setClassOperatorExists(classOperatorExists);
|
|
88 |
| } |
|
89 |
| |
|
90 |
4223
| public boolean predicateExists(final String name, final int arguments) {
|
|
91 |
4223
| final int external = name.indexOf(".");
|
|
92 |
4223
| if (external < 0) {
|
|
93 |
3139
| return super.predicateExists(name, arguments);
|
|
94 |
| } |
|
95 |
1084
| final String label = name.substring(0, external);
|
|
96 |
1084
| final ModuleReferenceList ref = prop.getRequiredModules();
|
|
97 |
1084
| final ModuleProperties newProp = ref.getModuleProperties(label);
|
|
98 |
1084
| if (newProp == null) {
|
|
99 |
0
| return false;
|
|
100 |
| } |
|
101 |
1084
| final String shortName = name.substring(external + 1);
|
|
102 |
1084
| return newProp.getExistenceChecker().predicateExists(shortName, arguments);
|
|
103 |
| } |
|
104 |
| |
|
105 |
1440
| public boolean functionExists(final String name, final int arguments) {
|
|
106 |
1440
| final int external = name.indexOf(".");
|
|
107 |
1440
| if (external < 0) {
|
|
108 |
1440
| return super.functionExists(name, arguments);
|
|
109 |
| } |
|
110 |
0
| final String label = name.substring(0, external);
|
|
111 |
0
| final ModuleReferenceList ref = prop.getRequiredModules();
|
|
112 |
0
| final ModuleProperties newProp = ref.getModuleProperties(label);
|
|
113 |
0
| final String shortName = name.substring(external + 1);
|
|
114 |
0
| return newProp.getExistenceChecker().functionExists(shortName, arguments);
|
|
115 |
| } |
|
116 |
| |
|
117 |
| } |