1 |
| |
2 |
| |
3 |
| |
4 |
| |
5 |
| |
6 |
| |
7 |
| |
8 |
| |
9 |
| |
10 |
| |
11 |
| |
12 |
| |
13 |
| |
14 |
| |
15 |
| |
16 |
| |
17 |
| |
18 |
| |
19 |
| package com.ontotext.wsmo4j.common; |
20 |
| |
21 |
| |
22 |
| import java.util.Collections; |
23 |
| import java.util.LinkedHashMap; |
24 |
| import java.util.LinkedHashSet; |
25 |
| import java.util.Set; |
26 |
| |
27 |
| import org.omwg.ontology.Ontology; |
28 |
| import org.wsmo.common.IRI; |
29 |
| import org.wsmo.common.Identifier; |
30 |
| import org.wsmo.common.Namespace; |
31 |
| import org.wsmo.common.TopEntity; |
32 |
| |
33 |
| |
34 |
| |
35 |
| |
36 |
| |
37 |
| |
38 |
| |
39 |
| |
40 |
| |
41 |
| |
42 |
| public class TopEntityImpl extends EntityImpl implements TopEntity { |
43 |
| |
44 |
| private String wsmlVariant; |
45 |
| |
46 |
| private Namespace defaultNS; |
47 |
| |
48 |
| private LinkedHashSet <IRI> mediators; |
49 |
| |
50 |
| private LinkedHashMap <String, Namespace> namespaces; |
51 |
| |
52 |
| private LinkedHashMap <Identifier, Ontology> ontologies; |
53 |
| |
54 |
0
| public TopEntityImpl(Identifier id) {
|
55 |
0
| super(id);
|
56 |
0
| mediators = new LinkedHashSet <IRI>();
|
57 |
0
| namespaces = new LinkedHashMap <String, Namespace> ();
|
58 |
0
| ontologies = new LinkedHashMap <Identifier, Ontology> ();
|
59 |
| } |
60 |
| |
61 |
| |
62 |
0
| public String getWsmlVariant() {
|
63 |
| |
64 |
| |
65 |
| |
66 |
| |
67 |
| |
68 |
| |
69 |
| |
70 |
| |
71 |
| |
72 |
0
| return this.wsmlVariant;
|
73 |
| |
74 |
| } |
75 |
| |
76 |
0
| public void setWsmlVariant(String variant) {
|
77 |
0
| if (variant != null
|
78 |
| && variant.trim().length() == 0) { |
79 |
0
| variant = null;
|
80 |
| } |
81 |
0
| this.wsmlVariant = variant;
|
82 |
| } |
83 |
| |
84 |
0
| public Set <Namespace> listNamespaces() {
|
85 |
0
| return new LinkedHashSet <Namespace>(namespaces.values());
|
86 |
| } |
87 |
| |
88 |
0
| public void addNamespace(Namespace ns) {
|
89 |
0
| if (ns == null) {
|
90 |
0
| throw new IllegalArgumentException();
|
91 |
| } |
92 |
0
| namespaces.put(ns.getPrefix(), ns);
|
93 |
| } |
94 |
| |
95 |
0
| public void removeNamespace(String prefix) {
|
96 |
0
| if (prefix == null) {
|
97 |
0
| throw new IllegalArgumentException();
|
98 |
| } |
99 |
0
| namespaces.remove(prefix);
|
100 |
| } |
101 |
| |
102 |
0
| public void removeNamespace(Namespace ns) {
|
103 |
0
| if (ns == null) {
|
104 |
0
| throw new IllegalArgumentException();
|
105 |
| } |
106 |
0
| removeNamespace(ns.getPrefix());
|
107 |
| } |
108 |
| |
109 |
0
| public Namespace findNamespace(String prefix) {
|
110 |
0
| if (prefix == null) {
|
111 |
0
| throw new IllegalArgumentException();
|
112 |
| } |
113 |
0
| return namespaces.get(prefix);
|
114 |
| } |
115 |
| |
116 |
0
| public Namespace getDefaultNamespace() {
|
117 |
0
| return this.defaultNS;
|
118 |
| } |
119 |
| |
120 |
0
| public void setDefaultNamespace(Namespace ns) {
|
121 |
0
| this.defaultNS = ns;
|
122 |
| } |
123 |
| |
124 |
| |
125 |
| |
126 |
| |
127 |
| |
128 |
| |
129 |
0
| public void setDefaultNamespace(IRI iri) {
|
130 |
0
| if (iri == null) {
|
131 |
0
| this.defaultNS = null;
|
132 |
| } |
133 |
| else { |
134 |
0
| this.defaultNS = new NamespaceImpl("", iri);
|
135 |
| } |
136 |
| } |
137 |
| |
138 |
0
| public void addMediator(IRI mediator) {
|
139 |
0
| if (mediator == null) {
|
140 |
0
| throw new IllegalArgumentException();
|
141 |
| } |
142 |
0
| mediators.add(mediator);
|
143 |
| } |
144 |
| |
145 |
0
| public void removeMediator(IRI mediator) {
|
146 |
0
| if (mediator == null) {
|
147 |
0
| throw new IllegalArgumentException();
|
148 |
| } |
149 |
0
| mediators.remove(mediator);
|
150 |
| } |
151 |
| |
152 |
| |
153 |
0
| public Set <IRI> listMediators() {
|
154 |
0
| return Collections.unmodifiableSet(mediators);
|
155 |
| } |
156 |
| |
157 |
0
| public void addOntology(Ontology ontology) {
|
158 |
0
| if (ontology == null) {
|
159 |
0
| throw new IllegalArgumentException();
|
160 |
| } |
161 |
0
| ontologies.put(ontology.getIdentifier(), ontology);
|
162 |
| } |
163 |
| |
164 |
0
| public void removeOntology(IRI iri) {
|
165 |
0
| if (iri == null) {
|
166 |
0
| throw new IllegalArgumentException();
|
167 |
| } |
168 |
0
| ontologies.remove(iri);
|
169 |
| } |
170 |
| |
171 |
0
| public void removeOntology(Ontology ontology) {
|
172 |
0
| if (ontology == null) {
|
173 |
0
| throw new IllegalArgumentException();
|
174 |
| } |
175 |
0
| ontologies.remove(ontology.getIdentifier());
|
176 |
| } |
177 |
| |
178 |
0
| public Set <Ontology> listOntologies() {
|
179 |
0
| return new LinkedHashSet <Ontology> (ontologies.values());
|
180 |
| } |
181 |
| |
182 |
0
| public boolean equals(Object object) {
|
183 |
0
| if (object == this) {
|
184 |
0
| return true;
|
185 |
| } |
186 |
0
| if (object == null
|
187 |
| || false == object instanceof TopEntity) { |
188 |
0
| return false;
|
189 |
| } |
190 |
0
| return super.equals(object);
|
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 |
| |