Statistics
| Revision:

gvsig-tools / org.gvsig.tools / library / trunk / org.gvsig.tools / org.gvsig.tools.lib / src / main / java / org / gvsig / tools / dynobject / DynObjectManager.java @ 130

History | View | Annotate | Download (7.99 KB)

1
package org.gvsig.tools.dynobject;
2

    
3
import java.io.IOException;
4
import java.io.InputStream;
5
import java.util.Iterator;
6
import java.util.List;
7
import java.util.Map;
8

    
9
import org.gvsig.tools.dynobject.exception.DuplicateDynClassException;
10
import org.gvsig.tools.dynobject.exception.DynMethodException;
11
import org.gvsig.tools.dynobject.exception.DynObjectValidateException;
12
import org.xmlpull.v1.XmlPullParser;
13
import org.xmlpull.v1.XmlPullParserException;
14

    
15

    
16
public interface DynObjectManager {
17

    
18
        /**
19
         * Null value for method id.
20
         * 
21
         * This value not is a value valid for a code of method.
22
         */
23
        public int NULLCODE = -1;
24

    
25
        
26
        /**
27
         * Create a instance of DynClass with the name and description
28
         * Indicated as parameters.
29
         * 
30
         * @param name, the name used for DynClass name.
31
         * @param description, the description associated to the
32
         *                         new DynClass.
33
         * 
34
         * @return the DynClass created.
35
         */
36
        public DynClass createDynClass(String name, String description);
37

    
38
        /**
39
         * Create a instance of DynClass with the name and description
40
         * Indicated as parameters.
41
         * 
42
         * @param namespace, the namespace used for the new DynClass.
43
         * 
44
         * @param name, the name used for the new DynClass.
45
         * 
46
         * @param description, the description associated to the
47
         *                         new DynClass.
48
         * 
49
         * @return the DynClass created.
50
         * 
51
         */
52
        public DynClass createDynClass(String namespace, String name, String description);
53

    
54
        /**
55
         * Load the classes defined in the resource and return a Map 
56
         * with its.
57
         * The classes do not be registered in the manager.
58
         * 
59
         * @param resource, XML with the definition of dynamic 
60
         *                         classes.
61
         * 
62
         * @param loader, loader used to load classes used in
63
         *                         "classOfValue" in the resource.
64
         * 
65
         * @param defaultNamespace, namespace used in classes that do not
66
         *                         specify a namespace in the resource.
67
         * 
68
         * @return The Map of loaded dynamic classes 
69
         * 
70
         * @throws XmlPullParserException
71
         * @throws IOException
72
         */
73
        public Map importDynClassDefinitions(InputStream resource, ClassLoader loader, String defaultNamespace)throws XmlPullParserException, IOException;
74
        
75
        /**
76
         * Load the classes defined in the resource.
77
         * When the class do not specify a namespace this is set
78
         * to null.
79
         * 
80
         * The classes do not be registered in the manager.
81
         * 
82
         * @param resource, XML with the definition of dynamic 
83
         *                         classes.
84
         * 
85
         * @param loader, loader used to load classes used in 
86
         *                         "classOfValue" in the resource.
87
         * 
88
         * @return The Map of loaded dynamic classes
89
         * 
90
         * @throws XmlPullParserException
91
         * @throws IOException
92
         */
93
        public Map importDynClassDefinitions(InputStream resource, ClassLoader loader)throws XmlPullParserException, IOException;
94

    
95
        /**
96
         * Load the classes defined in the resource.
97
         * When the class do not specify a namespace this is set
98
         * to null.
99
         * 
100
         * The classes do not be registered in the manager.
101
         * 
102
         * @param parser, XML parser used in the definition of dynamic 
103
         *                         classes.
104
         * 
105
         * @param loader, loader used to load classes used in 
106
         *                         "classOfValue" in the resource.
107
         * 
108
         * @param defaultNamespace, namespace used in classes that do not
109
         *                         specify a namespace in the resource.
110
         * 
111
         * @return The Map of loaded dynamic classes
112
         * 
113
         * @throws XmlPullParserException
114
         * @throws IOException
115
         */
116
        public Map importDynClassDefinitions(XmlPullParser parser, ClassLoader loader, String defaultNamespace)throws XmlPullParserException, IOException;
117
        
118
        /**
119
         * A?ade la dynClass a la lista de clases registradas.
120
         * Falla lanzando una excepcion si ya existe una clase registrada con ese
121
         * nombre en ese namespace.
122
         * 
123
         * @param dynClass
124
         * @throws DuplicateDynClassException
125
         */
126
        public void add(DynClass dynClass) throws DuplicateDynClassException;
127

    
128
        /**
129
         * Create and add to the manager a class with the name
130
         * passed as parameter in the default namespace.
131
         *  
132
         * @param name
133
         * @param description
134
         * @return the new class created.
135
         */
136
        public DynClass add(String name, String description);
137

    
138
        /**
139
         * Create and add to the manager a class with the name
140
         * passed as parameter in the default namespace.
141
         *  
142
         * @param name
143
         * @param description
144
         * @return the new class created.
145
         */
146
        public DynClass add(String name);
147

    
148
        public void remove(DynStruct dynClass);
149
        
150
        /**
151
         * Obtiene  la clase asociado al nombre indicado.
152
         * 
153
         * Si se indica un nombre con namespace la buscara en
154
         * ese namespace. if not se usara el namespace por
155
         * defecto.
156
         *
157
         * @param name
158
         *            , nombre de la clase que queremos obtener.
159
         * @return la clase requerida.
160
         */
161
        public DynClass get(String name);
162
        
163
        /**
164
         * Obtiene el la clase asociado al nombre indicado dentro del
165
         * namespace pedido.
166
         *
167
         * @param name
168
         *            , nombre de la clase que queremos obtener.
169
         * @return la clase requerida.
170
         */
171
        public DynClass get(String namespace, String name);
172

    
173
        /**
174
         * Comprueba si esta registrada una clase.
175
         *
176
         * @return true si la clase "name" esta registrada, false si no.
177
         */
178
        public boolean has(String name);
179

    
180
        /**
181
         * Comprueba si esta registrada una clase.
182
         *
183
         * @return true si la clase "name" esta registrada, false si no.
184
         */
185
        public boolean has(String namespace, String name);
186

    
187
        /**
188
         * Return the count of registered DynClass.
189
         *
190
         * @return count of DynClass
191
         */
192
        public int getCount();
193

    
194
        /**
195
         * Return an iterator over all registered DynClass.
196
         *
197
         * @return the iterator.
198
         */
199
        public Iterator interator();
200

    
201
        /**
202
         * Return the list of names of all registered DynClass.
203
         *
204
         * @return list of DynClass names.
205
         */
206
        public List getNames();
207

    
208

    
209
        /**
210
         * Create a new DynObject associated to the DynStruct or DynClass
211
         * passed as parameter.
212
         *
213
         * @param dynStruct or dynClass to use for create the dynObject
214
         * @return the new DynObject
215
         */
216
        public DynObject createDynObject(DynStruct dynStruct);
217

    
218
        /**
219
         * Crea un nuevo objeto asociandole como clase base la indicada que tiene el
220
         * nombre indicado.
221
         *
222
         * @param dynClassName
223
         * @return el nuevo DynObject
224
         */
225
        public DynObject createDynObject(String classname);
226

    
227
        /**
228
         * Crea un nuevo objeto asociandole como clase base la indicada que tiene el
229
         * nombre indicado.
230
         *
231
         * @param dynClassName
232
         * @return el nuevo DynObject
233
         */
234
        public DynObject createDynObject(String namespace, String classname);
235

    
236
        /**
237
         * Actualiza todas las DynClasses registradas para reflejar la
238
         * herencia de forma adecuada.
239
         */
240
        public void consolide();
241

    
242

    
243
        /**
244
         * Register the method in the dynClass.
245
         *
246
         * @param dynClass class over the method is registred
247
         * @param dynMethod method to registry
248
         * @return unique code of method
249
         */
250
        public int registerDynMethod(DynClass dynClass, DynMethod dynMethod);
251

    
252
        /**
253
         * Register the method in the class.
254
         *
255
         * @param theClass class over the method is registred
256
         * @param dynMethod method to registry
257
         * @return unique code of method
258
         */
259
        public int registerDynMethod(Class theClass, DynMethod dynMethod);
260

    
261

    
262
        /**
263
         * Obtain the method for the indicated code of the dynObject.
264
         *
265
         * @param dynObject
266
         * @param code code of the requeted method
267
         * @return the required DynMethod
268
         *
269
         * @throws DynMethodException
270
         */
271
        public DynMethod getDynMethod(DynObject dynObject, int code) throws DynMethodException ;
272

    
273
        public DynMethod getDynMethod(DynClass dynClass, int code) throws DynMethodException;
274

    
275
        public DynMethod getDynMethod(Object obj, int code) throws DynMethodException;
276

    
277
        public DynMethod getDynMethod(Class theClass, int code) throws DynMethodException;
278

    
279
        public DynMethod getDynMethod(int code) throws DynMethodException;
280

    
281
        /**
282
         * Invoke the method of the indicated code for the object self, with
283
         * parameters in context.
284
         *
285
         * @param self object over the method is invoked
286
         * @param code code for the method to invoke
287
         * @param context paramters of method
288
         * @return return value for the method
289
         * @throws DynMethodException
290
         */
291
        public Object invokeDynMethod(Object self, int code, DynObject context) throws DynMethodException;
292

    
293
        void validate(DynObject object) throws DynObjectValidateException;
294

    
295
        /**
296
         * @deprecated use DataTypesManager.getDefaultClass
297
         */
298
        Class getDefaultClassOfType(int type);
299
        
300
}