Statistics
| Revision:

svn-gvsig-desktop / trunk / libraries / libGPE / src / org / gvsig / gpe / parser / GPEContentHandler.java @ 19579

History | View | Annotate | Download (16.3 KB)

1
package org.gvsig.gpe.parser;
2

    
3
import org.gvsig.gpe.warnings.FeatureNotSupportedWarning;
4
import org.gvsig.xmlschema.som.IXSSchemaDocument;
5
import org.gvsig.xmlschema.som.impl.XSSchemaDocumentImpl;
6

    
7
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
8
 *
9
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
10
 *
11
 * This program is free software; you can redistribute it and/or
12
 * modify it under the terms of the GNU General Public License
13
 * as published by the Free Software Foundation; either version 2
14
 * of the License, or (at your option) any later version.
15
 *
16
 * This program is distributed in the hope that it will be useful,
17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
 * GNU General Public License for more details.
20
 *
21
 * You should have received a copy of the GNU General Public License
22
 * along with this program; if not, write to the Free Software
23
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
24
 *
25
 * For more information, contact:
26
 *
27
 *  Generalitat Valenciana
28
 *   Conselleria d'Infraestructures i Transport
29
 *   Av. Blasco Ib??ez, 50
30
 *   46010 VALENCIA
31
 *   SPAIN
32
 *
33
 *      +34 963862235
34
 *   gvsig@gva.es
35
 *      www.gvsig.gva.es
36
 *
37
 *    or
38
 *
39
 *   IVER T.I. S.A
40
 *   Salamanca 50
41
 *   46005 Valencia
42
 *   Spain
43
 *
44
 *   +34 963163400
45
 *   dac@iver.es
46
 */
47
/* CVS MESSAGES:
48
 *
49
 * $Id: GPEContentHandler.java 202 2007-11-27 12:00:11Z jpiera $
50
 * $Log$
51
 * Revision 1.17  2007/06/20 09:35:37  jorpiell
52
 * Add the javadoc comments
53
 *
54
 * Revision 1.16  2007/06/19 10:34:51  jorpiell
55
 * Add some comments and creates a warning when an operation is not supported
56
 *
57
 * Revision 1.15  2007/06/14 13:50:06  jorpiell
58
 * The schema jar name has been changed
59
 *
60
 * Revision 1.14  2007/06/07 14:52:28  jorpiell
61
 * Add the schema support
62
 *
63
 * Revision 1.13  2007/05/15 12:09:18  jorpiell
64
 * The bbox is linked to the feature
65
 *
66
 * Revision 1.12  2007/05/09 10:25:45  jorpiell
67
 * Add the multiGeometries
68
 *
69
 * Revision 1.11  2007/05/07 12:57:55  jorpiell
70
 * Add some methods to manage the multigeometries
71
 *
72
 * Revision 1.10  2007/04/19 07:23:20  jorpiell
73
 * Add the add methods to teh contenhandler and change the register mode
74
 *
75
 * Revision 1.9  2007/04/18 12:48:16  jorpiell
76
 * The ID attribute is always on the first position
77
 *
78
 * Revision 1.8  2007/04/18 10:46:23  jorpiell
79
 * bbox para from tyhe starLayer method deleted
80
 *
81
 * Revision 1.7  2007/04/18 10:43:24  jorpiell
82
 * Eliminados los Object de la interfaz
83
 *
84
 * Revision 1.6  2007/04/17 07:53:55  jorpiell
85
 * Before to start a new parsing process, the initialize method of the content handlers is throwed
86
 *
87
 * Revision 1.5  2007/04/14 16:06:13  jorpiell
88
 * The writer handler has been updated
89
 *
90
 * Revision 1.4  2007/04/13 13:14:55  jorpiell
91
 * Created the base tests and add some methods to the content handler
92
 *
93
 * Revision 1.3  2007/04/12 17:06:42  jorpiell
94
 * First GML writing tests
95
 *
96
 * Revision 1.2  2007/04/11 13:04:51  jorpiell
97
 * Add the srs param to the addLayer method
98
 *
99
 * Revision 1.1  2007/04/11 08:46:21  csanchez
100
 * Actualizacion protoripo libGPE
101
 *
102
 *
103
 */
104
/**
105
 * This class is a common implementation for all
106
 * the application content handlers. It has an attribute
107
 * with the geographical file schema. It has a default
108
 * implementation for all the methods defined by the 
109
 * IGPEContentHandler.
110
 * @author Jorge Piera Llodr? (jorge.piera@iver.es)
111
 * @author Carlos S?nchez Peri??n (sanchez_carper@gva.es)
112
 */
113
public abstract class GPEContentHandler implements IGPEContentHandler {
114
        private IXSSchemaDocument schemaDocument = null;
115
        private IGPEErrorHandler errorHandler = null;
116
        
117
        /**
118
         * @return the schemaDocument
119
         */
120
        public IXSSchemaDocument getSchemaDocument() {
121
                if (schemaDocument == null){
122
                        schemaDocument = new XSSchemaDocumentImpl();
123
                }
124
                return schemaDocument;
125
        }
126

    
127
        /**
128
         * @param schemaDocument the schemaDocument to set
129
         */
130
        public void setSchemaDocument(IXSSchemaDocument schemaDocument) {
131
                this.schemaDocument = schemaDocument;
132
        }        
133

    
134
        /**
135
         * @return the errorHandler
136
         */
137
        public IGPEErrorHandler getErrorHandler() {
138
                return errorHandler;
139
        }
140

    
141
        /**
142
         * @param errorHandler the errorHandler to set
143
         */
144
        public void setErrorHandler(IGPEErrorHandler errorHandler) {
145
                this.errorHandler = errorHandler;
146
        }
147

    
148
        /*
149
         * (non-Javadoc)
150
         * @see org.gvsig.gpe.IGPEContentHandler#addBboxToFeature(java.lang.Object, java.lang.Object)
151
         */
152
        public void addBboxToFeature(Object bbox, Object feature) {
153
                addNotSupportedWarning(FeatureNotSupportedWarning.FEATUEWITHBBOX);                
154
        }
155

    
156
        /*
157
         * (non-Javadoc)
158
         * @see org.gvsig.gpe.IGPEContentHandler#addBboxToLayer(java.lang.Object, java.lang.Object)
159
         */
160
        public void addBboxToLayer(Object bbox, Object layer) {
161
                addNotSupportedWarning(FeatureNotSupportedWarning.LAYERWITHBBOX);                                
162
        }
163

    
164
        /*
165
         * (non-Javadoc)
166
         * @see org.gvsig.gpe.IGPEContentHandler#addDescriptionToLayer(java.lang.String, java.lang.Object)
167
         */
168
        public void addDescriptionToLayer(String description, Object layer) {
169
                addNotSupportedWarning(FeatureNotSupportedWarning.LAYERWITHDESCRIPTION);                                
170
        }
171

    
172
        /*
173
         * (non-Javadoc)
174
         * @see org.gvsig.gpe.IGPEContentHandler#addElementToFeature(java.lang.Object, java.lang.Object)
175
         */
176
        public void addElementToFeature(Object element, Object feature) {
177
                addNotSupportedWarning(FeatureNotSupportedWarning.FEATUREWITHELEMENTS);                                
178
        }
179

    
180
        /*
181
         * (non-Javadoc)
182
         * @see org.gvsig.gpe.IGPEContentHandler#addFeatureToLayer(java.lang.Object, java.lang.Object)
183
         */
184
        public void addFeatureToLayer(Object feature, Object layer) {
185
                addNotSupportedWarning(FeatureNotSupportedWarning.LAYERWITHFEATURES);
186
        }
187

    
188
        /*
189
         * (non-Javadoc)
190
         * @see org.gvsig.gpe.IGPEContentHandler#addGeometryToFeature(java.lang.Object, java.lang.Object)
191
         */
192
        public void addGeometryToFeature(Object geometry, Object feature) {
193
                addNotSupportedWarning(FeatureNotSupportedWarning.FEATUREWITHGEOMETRY);
194
        }
195

    
196
        /*
197
         * (non-Javadoc)
198
         * @see org.gvsig.gpe.IGPEContentHandler#addInnerPolygonToPolygon(java.lang.Object, java.lang.Object)
199
         */
200
        public void addInnerPolygonToPolygon(Object innerPolygon, Object Polygon) {
201
                addNotSupportedWarning(FeatureNotSupportedWarning.POLYGONWITHINNERPOLYGON);
202
        }
203

    
204
        /*
205
         * (non-Javadoc)
206
         * @see org.gvsig.gpe.IGPEContentHandler#addNameToFeature(java.lang.String, java.lang.Object)
207
         */
208
        public void addNameToFeature(String name, Object feature) {
209
                addNotSupportedWarning(FeatureNotSupportedWarning.FEATUREWITHNAME);
210
        }
211

    
212
        /*
213
         * (non-Javadoc)
214
         * @see org.gvsig.gpe.IGPEContentHandler#addNameToLayer(java.lang.String, java.lang.Object)
215
         */
216
        public void addNameToLayer(String name, Object layer) {
217
                addNotSupportedWarning(FeatureNotSupportedWarning.LAYERWITHNAME);
218
        }
219

    
220
        /*
221
         * (non-Javadoc)
222
         * @see org.gvsig.gpe.IGPEContentHandler#addParentElementToElement(java.lang.Object, java.lang.Object)
223
         */
224
        public void addParentElementToElement(Object parent, Object element) {
225
                addNotSupportedWarning(FeatureNotSupportedWarning.ELEMENTWITHCHILDREN);
226
        }
227
        
228
        
229
        /*
230
         * (non-Javadoc)
231
         * @see org.gvsig.gpe.IGPEContentHandler#addParentLayerToLayer(java.lang.Object, java.lang.Object)
232
         */
233
        public void addParentLayerToLayer(Object parent, Object layer) {
234
                addNotSupportedWarning(FeatureNotSupportedWarning.LAYERWITHCHILDREN);
235
        }
236

    
237
        /*
238
         * (non-Javadoc)
239
         * @see org.gvsig.gpe.IGPEContentHandler#addSrsToLayer(java.lang.String, java.lang.Object)
240
         */
241
        public void addSrsToLayer(String srs, Object Layer) {
242
                addNotSupportedWarning(FeatureNotSupportedWarning.LAYERWITHSRS);
243
        }
244

    
245
        /*
246
         * (non-Javadoc)
247
         * @see org.gvsig.gpe.IGPEContentHandler#endBbox(java.lang.Object)
248
         */
249
        public void endBbox(Object bbox) {
250
                                
251
        }
252

    
253
        /*
254
         * (non-Javadoc)
255
         * @see org.gvsig.gpe.IGPEContentHandler#endElement(java.lang.Object)
256
         */
257
        public void endElement(Object element) {
258
                
259
        }
260
        /*
261
         * (non-Javadoc)
262
         * @see org.gvsig.gpe.IGPEContentHandler#endElement(java.lang.Object)
263
         */
264
        public void endElement(Object element, boolean isGeometryTag) {
265
                
266
        }
267

    
268
        /*
269
         * (non-Javadoc)
270
         * @see org.gvsig.gpe.IGPEContentHandler#endFeature(java.lang.Object)
271
         */
272
        public void endFeature(Object feature) {
273
                
274
        }
275

    
276
        /*
277
         * (non-Javadoc)
278
         * @see org.gvsig.gpe.IGPEContentHandler#endInnerPolygon(java.lang.Object)
279
         */
280
        public void endInnerPolygon(Object innerPolygon) {
281
                
282
        }
283
        
284
        /*
285
         * (non-Javadoc)
286
         * @see org.gvsig.gpe.IGPEContentHandler#endLayer(java.lang.Object)
287
         */
288
        public void endLayer(Object layer) {
289
                
290
        }
291

    
292
        /*
293
         * (non-Javadoc)
294
         * @see org.gvsig.gpe.IGPEContentHandler#endLineString(java.lang.Object)
295
         */
296
        public void endLineString(Object lineString) {
297
                
298
        }
299

    
300
        /*
301
         * (non-Javadoc)
302
         * @see org.gvsig.gpe.IGPEContentHandler#endLinearRing(java.lang.Object)
303
         */
304
        public void endLinearRing(Object linearRing) {
305
                
306
        }
307

    
308
        /*
309
         * (non-Javadoc)
310
         * @see org.gvsig.gpe.IGPEContentHandler#endPoint(java.lang.Object)
311
         */
312
        public void endPoint(Object point) {
313
                
314
        }
315

    
316
        /*
317
         * (non-Javadoc)
318
         * @see org.gvsig.gpe.IGPEContentHandler#endPolygon(java.lang.Object)
319
         */
320
        public void endPolygon(Object Polygon) {
321
                
322
        }
323

    
324
        /*
325
         * (non-Javadoc)
326
         * @see org.gvsig.gpe.IGPEContentHandler#startBbox(java.lang.String, double[], double[], double[], java.lang.String)
327
         */
328
        public Object startBbox(String id, double[] x, double[] y, double[] z, String srs) {
329
                addNotSupportedWarning(FeatureNotSupportedWarning.BBOXCREATION);
330
                return null;
331
        }
332

    
333
        /*
334
         * (non-Javadoc)
335
         * @see org.gvsig.gpe.IGPEContentHandler#startElement(java.lang.String, java.lang.Object, java.lang.String, java.lang.Object)
336
         */
337
        public Object startElement(String name, Object value, String xsElementName, Object parentElement) {
338
                addNotSupportedWarning(FeatureNotSupportedWarning.ELEMENTCREATION);
339
                return null;
340
        }
341

    
342
        /*
343
         * (non-Javadoc)
344
         * @see org.gvsig.gpe.IGPEContentHandler#startFeature(java.lang.String, java.lang.String, java.lang.String, java.lang.Object)
345
         */
346
        public Object startFeature(String id, String name, String xsElementName, Object layer) {
347
                addNotSupportedWarning(FeatureNotSupportedWarning.FEATURECREATION);
348
                return null;
349
        }
350

    
351
        /*
352
         * (non-Javadoc)
353
         * @see org.gvsig.gpe.IGPEContentHandler#startInnerPolygon(java.lang.String, double[], double[], double[], java.lang.String)
354
         */
355
        public Object startInnerPolygon(String id, double[] x, double[] y, double[] z, String srs) {
356
                addNotSupportedWarning(FeatureNotSupportedWarning.INNERBOUNDARYCREATION);
357
                return null;
358
        }
359

    
360
        /*
361
         * (non-Javadoc)
362
         * @see org.gvsig.gpe.IGPEContentHandler#startLayer(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.Object, java.lang.Object, java.lang.String)
363
         */
364
        public Object startLayer(String id, String name, String description, String srs, Object parentLayer, Object bBox, String xsElementName) {
365
                addNotSupportedWarning(FeatureNotSupportedWarning.LAYERCREATION);
366
                return null;
367
        }
368

    
369
        /*
370
         * (non-Javadoc)
371
         * @see org.gvsig.gpe.IGPEContentHandler#startLineString(java.lang.String, double[], double[], double[], java.lang.String)
372
         */
373
        public Object startLineString(String id, double[] x, double[] y, double[] z, String srs) {
374
                addNotSupportedWarning(FeatureNotSupportedWarning.LINESTRINGCREATION);
375
                return null;
376
        }
377

    
378
        /*
379
         * (non-Javadoc)
380
         * @see org.gvsig.gpe.IGPEContentHandler#startLinearRing(java.lang.String, double[], double[], double[], java.lang.String)
381
         */
382
        public Object startLinearRing(String id, double[] x, double[] y, double[] z, String srs) {
383
                addNotSupportedWarning(FeatureNotSupportedWarning.LINEARRINGCREATION);
384
                return null;
385
        }
386

    
387
        /*
388
         * (non-Javadoc)
389
         * @see org.gvsig.gpe.IGPEContentHandler#startPoint(java.lang.String, double, double, double, java.lang.String)
390
         */
391
        public Object startPoint(String id, double x, double y, double z, String srs) {
392
                addNotSupportedWarning(FeatureNotSupportedWarning.POINTCREATION);
393
                return null;
394
        }
395

    
396

    
397
        /*
398
         * (non-Javadoc)
399
         * @see org.gvsig.gpe.IGPEContentHandler#startPolygon(java.lang.String, double[], double[], double[], java.lang.String)
400
         */
401
        public Object startPolygon(String id, double[] x, double[] y, double[] z, String srs) {
402
                addNotSupportedWarning(FeatureNotSupportedWarning.POLYGONCREATION);
403
                return null;
404
        }
405

    
406
        /*
407
         * (non-Javadoc)
408
         * @see org.gvsig.gpe.IGPEContentHandler#addGeometryToMultiGeometry(java.lang.Object, java.lang.Object)
409
         */
410
        public void addGeometryToMultiGeometry(Object geometry, Object multiGeometry) {
411
                
412
        }
413
        
414
        /*
415
         * (non-Javadoc)
416
         * @see org.gvsig.gpe.IGPEContentHandlerSFP0#addCurveToMultiCurve(java.lang.Object, java.lang.Object)
417
         */
418
        public void addCurveToMultiCurve(Object curve, Object multiCurve) {
419
                
420
        }
421
        
422
        /*
423
         * (non-Javadoc)
424
         * @see org.gvsig.gpe.IGPEContentHandlerSFP0#startMultiCurve(java.lang.String, java.lang.String)
425
         */
426
        public Object startMultiCurve(String id, String srs) {
427
                addNotSupportedWarning(FeatureNotSupportedWarning.MULTICURVECREATION);
428
                return null;
429
        }
430
        
431
        /*
432
         * (non-Javadoc)
433
         * @see org.gvsig.gpe.IGPEContentHandlerSFP0#endMultiCurve(java.lang.Object)
434
         */
435
        public void endMultiCurve(Object multiCurve) {
436
                
437
        }
438
        
439
        /*
440
         * (non-Javadoc)
441
         * @see org.gvsig.gpe.IGPEContentHandlerSFP0#startCurve(java.lang.String, double[], double[], double[], java.lang.String)
442
         */
443
        public Object startCurve(String id,  double[] x, double[] y, double[] z, String srs){
444
                addNotSupportedWarning(FeatureNotSupportedWarning.CURVECREATION);
445
                return null;
446
        }
447
        
448
        /*
449
         * (non-Javadoc)
450
         * @see org.gvsig.gpe.IGPEContentHandlerSFP0#endCurve(java.lang.Object)
451
         */
452
        public void endCurve(Object Curve) {
453
                
454
        }
455
                
456
        /*
457
         * (non-Javadoc)
458
         * @see org.gvsig.gpe.IGPEContentHandler#addLineStringToMultiLineString(java.lang.Object, java.lang.Object)
459
         */
460
        public void addLineStringToMultiLineString(Object lineString, Object multiLineString) {
461
                
462
        }
463

    
464
        /*
465
         * (non-Javadoc)
466
         * @see org.gvsig.gpe.IGPEContentHandler#addPointToMultiPoint(java.lang.Object, java.lang.Object)
467
         */
468
        public void addPointToMultiPoint(Object point, Object multiPoint) {
469
                
470
        }
471

    
472
        /*
473
         * (non-Javadoc)
474
         * @see org.gvsig.gpe.IGPEContentHandler#addPolygonToMultiPolygon(java.lang.Object, java.lang.Object)
475
         */
476
        public void addPolygonToMultiPolygon(Object polygon, Object multiPolygon) {
477
                
478
        }
479

    
480
        /*
481
         * (non-Javadoc)
482
         * @see org.gvsig.gpe.IGPEContentHandler#endMultiGeometry(java.lang.Object)
483
         */
484
        public void endMultiGeometry(Object multiGeometry) {
485
                
486
        }
487

    
488
        /*
489
         * (non-Javadoc)
490
         * @see org.gvsig.gpe.IGPEContentHandler#endMultiLineString(java.lang.Object)
491
         */
492
        public void endMultiLineString(Object multiLineString) {
493
                
494
        }
495

    
496
        /*
497
         * (non-Javadoc)
498
         * @see org.gvsig.gpe.IGPEContentHandler#endMultiPoint(java.lang.Object)
499
         */
500
        public void endMultiPoint(Object multiPoint) {
501
                
502
        }
503

    
504
        /*
505
         * (non-Javadoc)
506
         * @see org.gvsig.gpe.IGPEContentHandler#endMultiPolygon(java.lang.Object)
507
         */
508
        public void endMultiPolygon(Object multiPolygon) {
509
                
510
        }
511

    
512
        /*
513
         * (non-Javadoc)
514
         * @see org.gvsig.gpe.IGPEContentHandler#startMultiGeometry(java.lang.String, java.lang.String)
515
         */
516
        public Object startMultiGeometry(String id, String srs) {
517
                addNotSupportedWarning(FeatureNotSupportedWarning.MULTIGEOMETRYCREATION);
518
                return null;
519
        }
520

    
521
        /*
522
         * (non-Javadoc)
523
         * @see org.gvsig.gpe.IGPEContentHandler#startMultiLineString(java.lang.String, java.lang.String)
524
         */
525
        public Object startMultiLineString(String id, String srs) {
526
                addNotSupportedWarning(FeatureNotSupportedWarning.MULTILINESTRINGCREATION);
527
                return null;
528
        }
529

    
530
        /*
531
         * (non-Javadoc)
532
         * @see org.gvsig.gpe.IGPEContentHandler#startMultiPoint(java.lang.String, java.lang.String)
533
         */
534
        public Object startMultiPoint(String id, String srs) {
535
                addNotSupportedWarning(FeatureNotSupportedWarning.MULTIPOINTCREATION);
536
                return null;
537
        }
538

    
539
        /*
540
         * (non-Javadoc)
541
         * @see org.gvsig.gpe.IGPEContentHandler#startMultiPolygon(java.lang.String, java.lang.String)
542
         */
543
        public Object startMultiPolygon(String id, String srs) {
544
                addNotSupportedWarning(FeatureNotSupportedWarning.MULTIPOLYGONCREATION);
545
                return null;
546
        }
547
        
548
        
549
        /**
550
         * This method adds a warning message into the ErrorHandler
551
         * to indicate that the application doesn't supports 
552
         * the especified objects
553
         * @param objectName
554
         * Object name that is not supported
555
         */
556
        private void addNotSupportedWarning(String objectName){
557
                if (errorHandler != null){
558
                        errorHandler.addWarning(new FeatureNotSupportedWarning(objectName));
559
                }
560
        }
561

    
562
        /* (non-Javadoc)
563
         * @see org.gvsig.gpe.IGPEContentHandlerSFP0#addSegmentToCurve(java.lang.Object, java.lang.Object)
564
         */
565
        public void addSegmentToCurve(Object segment, Object curve) {
566
                                
567
        }
568

    
569
        /* (non-Javadoc)
570
         * @see org.gvsig.gpe.IGPEContentHandlerSFP0#startCurve(java.lang.String, java.lang.String)
571
         */
572
        public Object startCurve(String id, String srs) {
573
                addNotSupportedWarning(FeatureNotSupportedWarning.CURVECREATION);
574
                return null;
575
        }        
576
}