Revision 484 org.gvsig.gpe/library/trunk/org.gvsig.gpe/org.gvsig.gpe.lib/org.gvsig.gpe.lib.impl/src/test/java/org/gvsig/gpe/lib/impl/parser/GPEContentHandlerTest.java

View differences:

GPEContentHandlerTest.java
138 138
	}
139 139

  
140 140
	public void endFeature(Object feature) {
141
		System.out.print(tab + "End Feature\n");		
142
	}	
141
		System.out.print(tab + "End Feature\n");
142
	}
143 143

  
144 144
	public void initialize(){
145 145
		layers = new ArrayList();
......
175 175
		tab = tab + "\t";
176 176
		System.out.print(tab + "Add Element " + elem.getName() + "=" +
177 177
				elem.getValue() + " to Feature\n");
178
		printChildElements(elem);		
178
		printChildElements(elem);
179 179
		tab = tab.substring(0, tab.length()-1);
180
		((Feature)feature).addElement(element);		
180
		((Feature)feature).addElement(element);
181 181
	}
182 182

  
183 183
	/**
184
	 * Print the element children 
184
	 * Print the element children
185 185
	 * @param element to print
186 186
	 */
187 187
	private void printChildElements(Element element){
......
217 217

  
218 218
	public void addNameToLayer(String name, Object layer) {
219 219
		System.out.print(tab + "Layer name changed: " + name + "\n");
220
		((Layer)layer).setName(name);		
220
		((Layer)layer).setName(name);
221 221
	}
222 222

  
223 223
	public void addParentElementToElement(Object parent, Object element) {
......
265 265
		Element element = new Element();
266 266
		element.setParentElement(parentElement);
267 267
		element.setName(name);
268
		element.setValue(value);		
268
		element.setValue(value);
269 269
		return element;
270 270
	}
271 271

  
......
289 289
		tab = tab + "\t";
290 290
		System.out.print(tab + "Start InnerPolygon, SRS:" + srs + "\n");
291 291
		tab = tab + "\t";
292
		Polygon inner = new Polygon();		
292
		Polygon inner = new Polygon();
293 293
		try {
294 294
			while(coords.hasNext()){
295 295
				double[] buffer = new double[coords.getDimension()];
......
300 300
					System.out.print(buffer[i]);
301 301
					if (i<buffer.length-1){
302 302
						System.out.print(",");
303
					}				
303
					}
304 304
				}
305 305
				System.out.print("\n");
306 306
			}
307 307
		} catch (IOException e) {
308 308
			e.printStackTrace();
309
		}		
309
		}
310 310
		inner.setId(id);
311 311
		inner.setSrs(srs);
312 312
		tab = tab.substring(0, tab.length()-2);
......
339 339
		}
340 340
		layers.add(layer);
341 341
		return layer;
342
	}	
342
	}
343 343

  
344 344
	public void endLayer(Object layer) {
345 345
		tab = tab.substring(0, tab.length()-1);
346
		System.out.print(tab + "End Layer\n");		
346
		System.out.print(tab + "End Layer\n");
347 347
	}
348 348

  
349 349
	public Object startLineString(String id, ICoordinateIterator coords, String srs) {
350 350
		tab = tab + "\t";
351 351
		System.out.print(tab + "Start LineString, SRS:" + srs + "\n");
352
		tab = tab + "\t";		
353
		LineString lineString = new LineString();		
352
		tab = tab + "\t";
353
		LineString lineString = new LineString();
354 354
		try {
355 355
			while(coords.hasNext()){
356 356
				double[] buffer = new double[coords.getDimension()];
......
361 361
					System.out.print(buffer[i]);
362 362
					if (i<buffer.length-1){
363 363
						System.out.print(",");
364
					}				
364
					}
365 365
				}
366 366
				System.out.print("\n");
367 367
			}
368 368
		} catch (IOException e) {
369 369
			e.printStackTrace();
370
		}		
370
		}
371 371
		lineString.setId(id);
372 372
		lineString.setSrs(srs);
373 373
		tab = tab.substring(0, tab.length()-2);
......
376 376

  
377 377
	public void endLineString(Object line) {
378 378
		System.out.print(tab + "\t"+ "End LineString:\n");
379
	}	
379
	}
380 380

  
381 381
	public Object startPoint(String id, ICoordinateIterator coords, String srs) {
382 382
		tab = tab + "\t";
383 383
		System.out.print(tab + "Start Point, SRS:" + srs + "\n");
384
		tab = tab + "\t";		
384
		tab = tab + "\t";
385 385
		Point point = new Point();
386 386
		double[] buffer = new double[coords.getDimension()];
387 387
		try {
388 388
			if (coords.hasNext()){
389 389
				coords.next(buffer);
390
				point.setCoordinates(buffer);				
390
				point.setCoordinates(buffer);
391 391
				System.out.print(tab);
392 392
				for (int i=0 ; i<buffer.length ; i++){
393 393
					System.out.print(buffer[i]);
394 394
					if (i<buffer.length-1){
395 395
						System.out.print(",");
396
					}				
396
					}
397 397
				}
398 398
				System.out.print("\n");
399 399
			}
400 400
		} catch (IOException e) {
401 401
			e.printStackTrace();
402
		}		
403
		
402
		}
403

  
404 404
		point.setId(id);
405 405
		point.setSrs(srs);
406 406
		tab = tab.substring(0, tab.length()-2);
407 407
		return point;
408
	}	
408
	}
409 409

  
410 410
	public void endPoint(Object point) {
411 411
		System.out.print(tab + "\t" + "End Point\n");
......
415 415
		tab = tab + "\t";
416 416
		System.out.print(tab + "Start Polygon, SRS:" + srs + "\n");
417 417
		tab = tab + "\t";
418
		Polygon polygon = new Polygon();		
418
		Polygon polygon = new Polygon();
419 419
		try {
420 420
			while(coords.hasNext()){
421 421
				double[] buffer = new double[coords.getDimension()];
......
426 426
					System.out.print(buffer[i]);
427 427
					if (i<buffer.length-1){
428 428
						System.out.print(",");
429
					}				
429
					}
430 430
				}
431 431
				System.out.print("\n");
432 432
			}
433 433
		} catch (IOException e) {
434 434
			e.printStackTrace();
435
		}		
435
		}
436 436
		polygon.setId(id);
437 437
		polygon.setSrs(srs);
438 438
		tab = tab.substring(0, tab.length()-2);
......
448 448
	public Object startLinearRing(String id, ICoordinateIterator coords, String srs) {
449 449
		System.out.print(tab + "Start LinearRing, SRS:" + srs + "\n");
450 450
		tab = tab + "\t";
451
		LinearRing linearRing = new LinearRing();		
451
		LinearRing linearRing = new LinearRing();
452 452
		try {
453 453
			while(coords.hasNext()){
454 454
				double[] buffer = new double[coords.getDimension()];
......
459 459
					System.out.print(buffer[i]);
460 460
					if (i<buffer.length-1){
461 461
						System.out.print(",");
462
					}				
462
					}
463 463
				}
464 464
				System.out.print("\n");
465 465
			}
466 466
		} catch (IOException e) {
467 467
			e.printStackTrace();
468
		}		
468
		}
469 469
		linearRing.setId(id);
470 470
		linearRing.setSrs(srs);
471 471
		tab = tab.substring(0, tab.length()-1);
......
485 485
		multiPoint.setId(id);
486 486
		multiPoint.setSrs(srs);
487 487
		return multiPoint;
488
	}	
488
	}
489 489

  
490 490
	public void endMultiPoint(Object multiPoint) {
491
		tab = tab.substring(0, tab.length()-1);		
492
		System.out.print(tab + "End MultiPoint\n");		
491
		tab = tab.substring(0, tab.length()-1);
492
		System.out.print(tab + "End MultiPoint\n");
493 493
	}
494 494

  
495 495
	public void addPointToMultiPoint(Object point, Object multiPoint) {
496
		System.out.print(tab + "Add Point to MultiPoint");	
496
		System.out.print(tab + "Add Point to MultiPoint");
497 497
		((MultiPoint)multiPoint).addPoint((Point)point);
498 498
	}
499 499

  
......
503 503
		MultiLineString multiLineString = new MultiLineString();
504 504
		multiLineString.setId(id);
505 505
		multiLineString.setSrs(srs);
506
		return multiLineString;		
506
		return multiLineString;
507 507
	}
508 508

  
509 509
	public void endMultiLineString(Object multiLineString) {
510
		tab = tab.substring(0, tab.length()-1);		
511
		System.out.print(tab + "End MultiLineString\n");		
512
	}	
510
		tab = tab.substring(0, tab.length()-1);
511
		System.out.print(tab + "End MultiLineString\n");
512
	}
513 513

  
514 514
	public void addLineStringToMultiLineString(Object lineString, Object multiLineString) {
515
		System.out.print(tab + "Add LineString to MultiLineString");	
515
		System.out.print(tab + "Add LineString to MultiLineString");
516 516
		((MultiLineString)multiLineString).addLineString((LineString)lineString);
517 517
	}
518 518

  
......
522 522
		MultiPolygon multiPolygon = new MultiPolygon();
523 523
		multiPolygon.setId(id);
524 524
		multiPolygon.setSrs(srs);
525
		return multiPolygon;	
525
		return multiPolygon;
526 526
	}
527 527

  
528 528
	public void endMultiPolygon(Object multiPolygon) {
529
		tab = tab.substring(0, tab.length()-1);		
530
		System.out.print(tab + "End MultiPolygon\n");		
529
		tab = tab.substring(0, tab.length()-1);
530
		System.out.print(tab + "End MultiPolygon\n");
531 531
	}
532 532

  
533 533
	public void addPolygonToMultiPolygon(Object polygon, Object multiPolygon) {
534
		System.out.print(tab + "Add Polygon to MultiPolygon");	
534
		System.out.print(tab + "Add Polygon to MultiPolygon");
535 535
		((MultiPolygon)multiPolygon).addPolygon((Polygon)polygon);
536 536
	}
537 537

  
......
541 541
		MultiGeometry multiGeometry = new MultiGeometry();
542 542
		multiGeometry.setId(id);
543 543
		multiGeometry.setSrs(srs);
544
		return multiGeometry;	
544
		return multiGeometry;
545 545
	}
546 546

  
547 547
	public void endMultiGeometry(Object multiGeometry) {
548
		tab = tab.substring(0, tab.length()-1);		
549
		System.out.print(tab + "End MultiGeometry\n");		
548
		tab = tab.substring(0, tab.length()-1);
549
		System.out.print(tab + "End MultiGeometry\n");
550 550
	}
551 551

  
552 552
	public void addGeometryToMultiGeometry(Object geometry, Object multiGeometry) {
......
560 560
			System.out.print(tab + "Add LineString to Curve");
561 561
		}else {
562 562
			System.out.print(tab + "Add Geometry to MultiGeometry");
563
		}		
563
		}
564 564
		((MultiGeometry)multiGeometry).addGeometry((Geometry)geometry);
565 565
	}
566 566

  
......
569 569
		tab = tab + "\t";
570 570
		System.out.print(tab + "Start Curve, ID: " + id + ", SRS:" + srs + "\n");
571 571
		tab = tab + "\t";
572
		Curve curve = new Curve();		
572
		Curve curve = new Curve();
573 573
		try {
574 574
			while(coords.hasNext()){
575 575
				double[] buffer = new double[coords.getDimension()];
......
580 580
					System.out.print(buffer[i]);
581 581
					if (i<buffer.length-1){
582 582
						System.out.print(",");
583
					}				
583
					}
584 584
				}
585 585
				System.out.print("\n");
586 586
			}
587 587
		} catch (IOException e) {
588 588
			e.printStackTrace();
589
		}		
589
		}
590 590
		curve.setId(id);
591 591
		curve.setSrs(srs);
592 592
		tab = tab.substring(0, tab.length()-2);
593 593
		return curve;
594
	}	
594
	}
595 595

  
596 596
	public void endCurve(Object curve) {
597
		System.out.print(tab + "\t"+ "End Curve:\n");				
597
		System.out.print(tab + "\t"+ "End Curve:\n");
598 598
	}
599 599

  
600 600
	public Object startMultiCurve(String id, String srs) {
......
607 607
	}
608 608

  
609 609
	public void endMultiCurve(Object multiCurve) {
610
		tab = tab.substring(0, tab.length()-1);		
611
		System.out.print(tab + "End MultiCurve\n");		
610
		tab = tab.substring(0, tab.length()-1);
611
		System.out.print(tab + "End MultiCurve\n");
612 612
	}
613 613

  
614 614
	public void addCurveToMultiCurve(Object curve, Object multiCurve) {
615
		System.out.print(tab + "Add Curve to MultiCurve");	
615
		System.out.print(tab + "Add Curve to MultiCurve");
616 616
		((MultiCurve)multiCurve).addCurve((Curve)curve);
617 617
	}
618 618

  
......
621 621
		MetaData meta=null;
622 622
		System.out.print(tab + "Start Metadata, META: " + type + ", DATA:" + data + "\n");
623 623
		try {
624
			
624

  
625 625
			for(int i = 0; i<attributes.getNumAttributes();i++)
626 626
			{
627 627
				//String[] buffer = new String[2];
......
638 638
		meta.setTagData(data);
639 639
		return meta;
640 640
	}
641
	
641

  
642 642
	public void endMetadata(Object metadata) {
643 643
		tab = tab.substring(0, tab.length()-1);
644 644
		System.out.print(tab + "\t"+ "End Metadata:\n");
645 645
	}
646
	
646

  
647 647
	public void addMetadataToFeature(Object metadata, Object feature){
648
		System.out.print(tab+tab + "Add Metadata to Feature \n");	
648
		System.out.print(tab+tab + "Add Metadata to Feature \n");
649 649
		((Feature)feature).addMetadata((MetaData)metadata);
650
	} 
651
	
650
	}
651

  
652 652
	public void addMetadataToMetadata(Object metadata, Object parent){
653
		System.out.print(tab + "Add Metadata to Complex Metadata\n");	
653
		System.out.print(tab + "Add Metadata to Complex Metadata\n");
654 654
		((MetaData)parent).addChildData((MetaData)metadata);
655 655
	}
656 656

  
657 657
	public void addTimeToFeature(Object time, Object feature) {
658
		System.out.print(tab + "Add Time to feature\n");	
658
		System.out.print(tab + "Add Time to feature\n");
659 659
		((Feature)feature).addTime(time);
660 660
	}
661 661

  
......
669 669
		System.out.print(tab + "Start Time, TYPE: " + type + ", DATA:" + time + "\n");
670 670
		Time t = new Time();
671 671
		t.setType(type);
672
		t.setValue(time);		
672
		t.setValue(time);
673 673
		return t;
674 674
	}
675 675

  
676 676
	public Object startTime(String name, String description, String type,
677
			String time, Time previous, Time next) 
677
			String time, Time previous, Time next)
678 678
	{
679 679
		tab = tab + "\t";
680 680
		System.out.print(tab + "Start Time, NAME: " + name + ", DATA:" + time + "\n");
681 681
		Time t = new Time();
682 682
		t.setType(type);
683
		t.setValue(time);	
683
		t.setValue(time);
684 684
		t.setDescription(description);
685 685
		t.setName(name);
686 686
		t.setPrevious(previous);
687 687
		t.setNext(next);
688 688
		return t;
689
	} 
689
	}
690

  
691
    public Object startMultiPoint(String id, String srs, int dimension) {
692
        //Do nothing
693
        return null;
694
    }
695

  
696
    public Object startMultiLineString(String id, String srs, int dimension) {
697
        //Do nothing
698
        return null;
699
    }
700

  
701
    public Object startMultiPolygon(String id, String srs, int dimension) {
702
        //Do nothing
703
        return null;
704
    }
705

  
706
    public Object startMultiCurve(String id, String srs, int dimension) {
707
        //Do nothing
708
        return null;
709
    }
690 710
}
691 711

  

Also available in: Unified diff