1 |
| |
2 |
| |
3 |
| |
4 |
| |
5 |
| |
6 |
| |
7 |
| |
8 |
| |
9 |
| |
10 |
| |
11 |
| |
12 |
| |
13 |
| |
14 |
| |
15 |
| |
16 |
| |
17 |
| |
18 |
| |
19 |
| package com.ontotext.wsmo4j.ontology; |
20 |
| |
21 |
| |
22 |
| |
23 |
| |
24 |
| |
25 |
| |
26 |
| |
27 |
| |
28 |
| |
29 |
| |
30 |
| import java.util.Collections; |
31 |
| import java.util.LinkedHashSet; |
32 |
| import java.util.Set; |
33 |
| |
34 |
| import org.omwg.ontology.Attribute; |
35 |
| import org.omwg.ontology.Concept; |
36 |
| import org.omwg.ontology.Type; |
37 |
| import org.wsmo.common.Identifier; |
38 |
| import org.wsmo.common.exception.InvalidModelException; |
39 |
| import org.wsmo.common.exception.SynchronisationException; |
40 |
| |
41 |
| import com.ontotext.wsmo4j.common.EntityImpl; |
42 |
| |
43 |
| |
44 |
| public class AttributeImpl extends EntityImpl |
45 |
| implements Attribute { |
46 |
| |
47 |
| private Concept domain; |
48 |
| |
49 |
| private LinkedHashSet <Type> ranges; |
50 |
| |
51 |
| private int minCardinality = 0; |
52 |
| |
53 |
| private int maxCardinality = Integer.MAX_VALUE; |
54 |
| |
55 |
| private boolean constraining = false, |
56 |
| reflexive = false, |
57 |
| symmetric = false, |
58 |
| transitive = false; |
59 |
| |
60 |
| private Identifier inverseAttribute = null; |
61 |
| |
62 |
0
| public AttributeImpl(Identifier thisID, Concept domain) {
|
63 |
0
| super(thisID);
|
64 |
0
| this.domain = domain;
|
65 |
| |
66 |
0
| ranges = new LinkedHashSet <Type> ();
|
67 |
| } |
68 |
| |
69 |
0
| public Concept getConcept() throws SynchronisationException {
|
70 |
0
| return this.domain;
|
71 |
| } |
72 |
| |
73 |
0
| public void removeFromConcept() throws InvalidModelException {
|
74 |
0
| if (domain == null)
|
75 |
0
| return;
|
76 |
0
| Concept old = domain;
|
77 |
0
| domain = null;
|
78 |
0
| old.removeAttribute(this);
|
79 |
| } |
80 |
| |
81 |
0
| public boolean isConstraining() {
|
82 |
0
| return constraining;
|
83 |
| } |
84 |
| |
85 |
0
| public void setConstraining(boolean constraining) {
|
86 |
0
| this.constraining = constraining;
|
87 |
| } |
88 |
| |
89 |
0
| public int getMinCardinality() {
|
90 |
0
| return this.minCardinality;
|
91 |
| } |
92 |
| |
93 |
0
| public void setMinCardinality(int min) {
|
94 |
0
| this.minCardinality = min;
|
95 |
| } |
96 |
| |
97 |
0
| public int getMaxCardinality() {
|
98 |
0
| return this.maxCardinality;
|
99 |
| } |
100 |
| |
101 |
0
| public void setMaxCardinality(int max) {
|
102 |
0
| this.maxCardinality = max;
|
103 |
| } |
104 |
| |
105 |
0
| public Set <Type> listTypes() {
|
106 |
0
| return Collections.unmodifiableSet(ranges);
|
107 |
| } |
108 |
| |
109 |
0
| public void addType(Type type) throws InvalidModelException {
|
110 |
0
| if (type == null) {
|
111 |
0
| throw new IllegalArgumentException();
|
112 |
| } |
113 |
0
| ranges.add(type);
|
114 |
| } |
115 |
| |
116 |
0
| public void removeType(Type type) throws InvalidModelException {
|
117 |
0
| if (type == null) {
|
118 |
0
| throw new IllegalArgumentException();
|
119 |
| } |
120 |
0
| ranges.remove(type);
|
121 |
| } |
122 |
| |
123 |
0
| public boolean isReflexive() {
|
124 |
0
| return this.reflexive;
|
125 |
| } |
126 |
| |
127 |
0
| public void setReflexive(boolean reflexive) {
|
128 |
0
| this.reflexive = reflexive;
|
129 |
| } |
130 |
| |
131 |
0
| public boolean isSymmetric() {
|
132 |
0
| return symmetric;
|
133 |
| } |
134 |
| |
135 |
0
| public void setSymmetric(boolean symmetric) {
|
136 |
0
| this.symmetric = symmetric;
|
137 |
| } |
138 |
| |
139 |
0
| public boolean isTransitive() {
|
140 |
0
| return this.transitive;
|
141 |
| } |
142 |
| |
143 |
0
| public void setTransitive(boolean trans) {
|
144 |
0
| this.transitive = trans;
|
145 |
| } |
146 |
| |
147 |
0
| public Identifier getInverseOf() {
|
148 |
0
| return this.inverseAttribute;
|
149 |
| } |
150 |
| |
151 |
0
| public void setInverseOf(Identifier id) {
|
152 |
0
| this.inverseAttribute = id;
|
153 |
| } |
154 |
| |
155 |
0
| public boolean equals(Object object) {
|
156 |
0
| if (object == this) {
|
157 |
0
| return true;
|
158 |
| } |
159 |
0
| if (object == null
|
160 |
| || false == object instanceof Attribute) { |
161 |
0
| return false;
|
162 |
| } |
163 |
0
| Attribute anotherAttr = (Attribute)object;
|
164 |
0
| if (getConcept() == null) {
|
165 |
0
| if (anotherAttr.getConcept() != null) {
|
166 |
0
| return false;
|
167 |
| } |
168 |
| } |
169 |
| else { |
170 |
0
| if (!getConcept().equals(anotherAttr.getConcept())) {
|
171 |
0
| return false;
|
172 |
| } |
173 |
| } |
174 |
0
| return super.equals(object);
|
175 |
| } |
176 |
| |
177 |
| } |
178 |
| |
179 |
| |
180 |
| |
181 |
| |
182 |
| |
183 |
| |
184 |
| |
185 |
| |
186 |
| |
187 |
| |
188 |
| |
189 |
| |
190 |
| |
191 |
| |
192 |
| |
193 |
| |
194 |
| |
195 |
| |
196 |
| |
197 |
| |
198 |
| |
199 |
| |
200 |
| |
201 |
| |
202 |
| |
203 |
| |
204 |
| |
205 |
| |
206 |
| |
207 |
| |
208 |
| |
209 |
| |
210 |
| |
211 |
| |
212 |
| |
213 |
| |
214 |
| |
215 |
| |
216 |
| |
217 |
| |
218 |
| |
219 |
| |
220 |
| |
221 |
| |
222 |
| |
223 |
| |
224 |
| |
225 |
| |
226 |
| |
227 |
| |
228 |
| |
229 |
| |
230 |
| |
231 |
| |
232 |
| |
233 |
| |
234 |
| |
235 |
| |
236 |
| |
237 |
| |
238 |
| |