View Javadoc

1   /* 
2    WSMO Studio - a Semantic Web Service Editor
3    Copyright (c) 2004-2006, OntoText Lab. / SIRMA Group
4    
5    This library is free software; you can redistribute it and/or modify it under
6    the terms of the GNU Lesser General Public License as published by the Free
7    Software Foundation; either version 2.1 of the License, or (at your option)
8    any later version.
9    This library is distributed in the hope that it will be useful, but WITHOUT
10   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   details.
13   You should have received a copy of the GNU Lesser General Public License along
14   with this library; if not, write to the Free Software Foundation, Inc.,
15   59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
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  * $Log$
142  * Revision 1.5  2007/07/19 12:56:25  alex_simov
143  * no message
144  *
145  * Revision 1.4  2006/01/09 12:51:12  alex_simov
146  * Copyright message in header updated
147  *
148  * Revision 1.3  2005/07/21 14:44:40  alex_simov
149  * added javadoc: class description, footer
150  *
151  */