1
15
16 package gate.creole;
17
18 import java.io.Serializable;
19 import java.net.URL;
20 import java.util.ArrayList;
21 import java.util.List;
22
23 import gate.*;
24 import gate.util.*;
25
26
39 public class ResourceData extends AbstractFeatureBearer implements Serializable
40 {
41
42
43 protected static final boolean DEBUG = false;
44
45
46 public ResourceData() { }
48
49 public String toString() {
50 int noInst = (instantiationStack == null) ? 0: instantiationStack.size();
51
55 StringBuffer s = new StringBuffer(
56 "ResourceDataImpl, name=" + name + "; className=" + className +
57 "; jarFileName=" + jarFileName + "; jarFileUrl=" + jarFileUrl +
58 "; xmlFileName=" + xmlFileName + "; xmlFileUrl=" + xmlFileUrl +
59 "; isAutoLoading=" + autoLoading + "; numberInstances=" + noInst +
60 "; isPrivate=" + priv +"; isTool="+ tool +
61 "; validityMessage=" + validityMessage +
62 "; interfaceName=" + interfaceName +
63 "; guiType=" + guiType +
64 "; mainViewer=" + isMainView +
65 "; resourceDisplayed=" + resourceDisplayed +
66 "; annotationTypeDisplayed=" + annotationTypeDisplayed +
67 "; parameterList=" + parameterList +
68 "; features=" + features
69 );
70 return s.toString();
71 }
73
76 public boolean equals(Object other) {
77 if(name.equals(((ResourceData) other).getName()))
78 return true;
79 return false;
80 }
82
83 public int hashCode() {
84 return name.hashCode();
85 }
87
88 protected String name;
89
90
91 public void setName(String name) { this.name = name; }
92
93
94 public String getName() { return name; }
95
96
97 protected String icon;
98
99
100 public void setIcon(String icon) { this.icon = icon; }
101
102
103 public String getIcon() { return icon; }
104
105
106 protected WeakBumpyStack instantiationStack = new WeakBumpyStack();
107
108
112 protected List persistantInstantiationList = new ArrayList();
113
114
115 public WeakBumpyStack getInstantiations() {
116 return instantiationStack;
117 }
119
120 public void addInstantiation(Resource resource) {
121 instantiationStack.push(resource);
122 }
124
128 public void makeInstantiationPersistant(Resource resource) {
129 persistantInstantiationList.add(resource);
130 }
132
133 public void removeInstantiation(Resource resource) {
134 instantiationStack.remove(resource);
135 persistantInstantiationList.remove(resource);
136 }
138
139 public void bumpInstantiation(Resource resource) {
140 instantiationStack.bump(resource);
141 }
143
144 protected String className;
145
146
147 public void setClassName(String className) { this.className = className; }
148
149
150 public String getClassName() { return className; }
151
152
153 protected String interfaceName;
154
155
156 public void setInterfaceName(String interfaceName) {
157 this.interfaceName = interfaceName;
158 }
160
161 public String getInterfaceName() { return interfaceName; }
162
163
164 protected Class resourceClass;
165
166
167 public void setResourceClass(Class resourceClass) {
168 this.resourceClass = resourceClass;
169 }
171
174 public Class getResourceClass() throws ClassNotFoundException {
175 if(resourceClass == null) {
176 GateClassLoader classLoader = Gate.getClassLoader();
177 resourceClass = classLoader.loadClass(className);
178 }
179
180 return resourceClass;
181 }
183
184 protected String jarFileName;
185
186
187 public void setJarFileName(String jarFileName) {
188 this.jarFileName = jarFileName;
189 }
191
192 public String getJarFileName() { return jarFileName; }
193
194
195 protected URL jarFileUrl;
196
197
198 public void setJarFileUrl(URL jarFileUrl) { this.jarFileUrl = jarFileUrl; }
199
200
201 public URL getJarFileUrl() { return jarFileUrl; }
202
203
204 protected String xmlFileName;
205
206
207 protected URL xmlFileUrl;
208
209
210 public void setXmlFileUrl(URL xmlFileUrl) { this.xmlFileUrl = xmlFileUrl; }
211
212
213 public URL getXmlFileUrl() { return xmlFileUrl; }
214
215
216 protected String comment;
217
218
219 public String getComment() { return comment; }
220
221
222 public void setComment(String comment) { this.comment = comment; }
223
224
225 protected ParameterList parameterList = new ParameterList();
226
227
228 public void setParameterList(ParameterList parameterList) {
229 this.parameterList = parameterList;
230 }
232
233 public ParameterList getParameterList() { return parameterList; }
234
235
236 protected boolean autoLoading;
237
238
239 public void setAutoLoading(boolean autoLoading) {
240 this.autoLoading = autoLoading;
241 }
243
244 public boolean isAutoLoading() { return autoLoading; }
245
246
247 protected boolean priv = false;
248
249
250 public void setPrivate(boolean priv) {
251 this.priv = priv;
252 }
254
255 public boolean isPrivate() { return priv; }
256
257
258 protected boolean tool = false;
259
260
261 public void setTool(boolean tool) {
262 this.tool = tool;
263 }
265
266 public boolean isTool() { return tool; }
267
270 public boolean isValid() {
271 boolean valid = true;
272 return valid;
277 }
279
280 protected String validityMessage = "";
281
282
283 public String getValidityMessage() { return validityMessage; }
284
285
289 public static final int NULL_GUI = 0;
290
291 public static final int LARGE_GUI = 1;
292
293 public static final int SMALL_GUI = 2;
294
295 protected int guiType = NULL_GUI;
296
297 protected boolean isMainView = false;
298
299 protected String resourceDisplayed = null;
300
301 protected String annotationTypeDisplayed = null;
302
303 public void setGuiType(int aGuiType){guiType = aGuiType;}
304
305 public int getGuiType(){return guiType;}
306
307 public void setIsMainView(boolean mainView){isMainView = mainView;}
308
309 public boolean isMainView(){return isMainView;}
310
311 public void setResourceDisplayed(String aResourceDisplayed){
312 resourceDisplayed = aResourceDisplayed;
313 }
315 public String getResourceDisplayed(){return resourceDisplayed;}
316
317 public void setAnnotationTypeDisplayed(String anAnnotationTypeDisplayed){
318 annotationTypeDisplayed = anAnnotationTypeDisplayed;
319 }
321 public String getAnnotationTypeDisplayed(){return annotationTypeDisplayed;}
322 }