1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 /***
19 * <p>Title: WSMO Studio</p>
20 * <p>Description: Semantic Web Service Editor</p>
21 * <p>Copyright: Copyright (c) 2004-2006</p>
22 * <p>Company: OntoText Lab. / SIRMA </p>
23 */
24 package org.wsmostudio.runtime.cache;
25
26 import org.omwg.ontology.Ontology;
27 import org.wsmo.common.TopEntity;
28 import org.wsmo.mediator.*;
29 import org.wsmo.service.*;
30
31 /***
32 * A translation class between string types and numbered types.
33 *
34 * @author not attributable
35 * @version $Revision: 1225 $ $Date: 2007-07-19 15:56:25 +0300 $
36 */
37
38 public class WSMOTopEntity {
39 public static final byte ONTOLOGY = 0;
40 public static final byte GOAL = 1;
41 public static final byte WEB_SERVICE = 2;
42 public static final byte OO_MEDIATOR = 3;
43 public static final byte GG_MEDIATOR = 4;
44 public static final byte WG_MEDIATOR = 5;
45 public static final byte WW_MEDIATOR = 6;
46 public static final byte INTERFACE = 7;
47 public static final byte CAPABILITY = 8;
48 public static final int TYPE_COUNT = 9;
49
50 public static byte parse(String wsmoType) {
51 if (wsmoType.equalsIgnoreCase("ontology")) {
52 return ONTOLOGY;
53 }
54 else if (wsmoType.equalsIgnoreCase("goal")) {
55 return GOAL;
56 }
57 else if (wsmoType.equalsIgnoreCase("webservice")) {
58 return WEB_SERVICE;
59 }
60 else if (wsmoType.equalsIgnoreCase("oomediator")) {
61 return OO_MEDIATOR;
62 }
63 else if (wsmoType.equalsIgnoreCase("ggmediator")) {
64 return GG_MEDIATOR;
65 }
66 else if (wsmoType.equalsIgnoreCase("wgmediator")) {
67 return WG_MEDIATOR;
68 }
69 else if (wsmoType.equalsIgnoreCase("wwmediator")) {
70 return WW_MEDIATOR;
71 }
72 else if (wsmoType.equalsIgnoreCase("interface")) {
73 return INTERFACE;
74 }
75 else if (wsmoType.equalsIgnoreCase("capability")) {
76 return CAPABILITY;
77 }
78 else {
79 throw new IllegalArgumentException("Unknown type: " + wsmoType);
80 }
81 }
82 public static byte getEntityType(TopEntity entity) {
83
84 if (entity instanceof Ontology) {
85 return ONTOLOGY;
86 }
87 else if (entity instanceof Goal) {
88 return GOAL;
89 }
90 else if (entity instanceof WebService) {
91 return WEB_SERVICE;
92 }
93 else if (entity instanceof OOMediator) {
94 return OO_MEDIATOR;
95 }
96 else if (entity instanceof GGMediator) {
97 return GG_MEDIATOR;
98 }
99 else if (entity instanceof WGMediator) {
100 return WG_MEDIATOR;
101 }
102 else if (entity instanceof WWMediator) {
103 return WW_MEDIATOR;
104 }
105 else if (entity instanceof Interface) {
106 return INTERFACE;
107 }
108 else if (entity instanceof Capability) {
109 return CAPABILITY;
110 }
111 else {
112 throw new IllegalArgumentException("Unknown type: " + entity.getClass().getName());
113 }
114 }
115 public static String getTypeAsString(byte type) {
116 switch (type) {
117 case ONTOLOGY:
118 return "Ontology";
119 case GOAL:
120 return "Goal";
121 case WEB_SERVICE:
122 return "Web Service";
123 case OO_MEDIATOR:
124 return "OO Mediator";
125 case GG_MEDIATOR:
126 return "GG Mediator";
127 case WG_MEDIATOR:
128 return "WG Mediator";
129 case WW_MEDIATOR:
130 return "WW Mediator";
131 case INTERFACE:
132 return "Interface";
133 case CAPABILITY:
134 return "Capability";
135 }
136 return null;
137 }
138 }
139
140
141
142
143
144
145
146
147
148
149
150
151