root / trunk / libraries / libDataSource / src / org / gvsig / data / vectorial / visitor / PrintlnFeaturesVisitor.java @ 20500
History | View | Annotate | Download (4.06 KB)
1 | 19487 | jpiera | package org.gvsig.data.vectorial.visitor; |
---|---|---|---|
2 | |||
3 | 20412 | vcaballero | import java.util.Iterator; |
4 | |||
5 | 20500 | vcaballero | import org.gvsig.data.vectorial.DefaultAttributeDescriptor; |
6 | 19487 | jpiera | import org.gvsig.data.vectorial.IFeature; |
7 | import org.gvsig.data.vectorial.IFeatureAttributeDescriptor; |
||
8 | import org.gvsig.data.vectorial.IFeatureType; |
||
9 | import org.gvsig.exceptions.BaseException; |
||
10 | |||
11 | /* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
||
12 | *
|
||
13 | * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
||
14 | *
|
||
15 | * This program is free software; you can redistribute it and/or
|
||
16 | * modify it under the terms of the GNU General Public License
|
||
17 | * as published by the Free Software Foundation; either version 2
|
||
18 | * of the License, or (at your option) any later version.
|
||
19 | *
|
||
20 | * This program is distributed in the hope that it will be useful,
|
||
21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
23 | * GNU General Public License for more details.
|
||
24 | *
|
||
25 | * You should have received a copy of the GNU General Public License
|
||
26 | * along with this program; if not, write to the Free Software
|
||
27 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
||
28 | *
|
||
29 | * For more information, contact:
|
||
30 | *
|
||
31 | * Generalitat Valenciana
|
||
32 | * Conselleria d'Infraestructures i Transport
|
||
33 | * Av. Blasco Ib??ez, 50
|
||
34 | * 46010 VALENCIA
|
||
35 | * SPAIN
|
||
36 | *
|
||
37 | * +34 963862235
|
||
38 | * gvsig@gva.es
|
||
39 | * www.gvsig.gva.es
|
||
40 | *
|
||
41 | * or
|
||
42 | *
|
||
43 | * IVER T.I. S.A
|
||
44 | * Salamanca 50
|
||
45 | * 46005 Valencia
|
||
46 | * Spain
|
||
47 | *
|
||
48 | * +34 963163400
|
||
49 | * dac@iver.es
|
||
50 | */
|
||
51 | /* CVS MESSAGES:
|
||
52 | *
|
||
53 | * $Id$
|
||
54 | * $Log$
|
||
55 | *
|
||
56 | */
|
||
57 | /**
|
||
58 | * This visitor is used only to print a feature by console.
|
||
59 | * @author Jorge Piera Llodr? (jorge.piera@iver.es)
|
||
60 | */
|
||
61 | public class PrintlnFeaturesVisitor extends DefaultFeaturesVisitor{ |
||
62 | private IFeatureType featureType;
|
||
63 | 19627 | jmvivo | |
64 | 19487 | jpiera | public PrintlnFeaturesVisitor(IFeatureType featureType) {
|
65 | super();
|
||
66 | this.featureType = featureType;
|
||
67 | } |
||
68 | |||
69 | /* (non-Javadoc)
|
||
70 | * @see org.gvsig.data.vectorial.visitor.DefaultFeaturesVisitor#visit(org.gvsig.data.vectorial.IFeature)
|
||
71 | */
|
||
72 | public void visit(IFeature feature) throws BaseException { |
||
73 | System.out.println("***************** New Feature ******************"); |
||
74 | System.out.println("CLASS = " + feature.getClass().toString()); |
||
75 | System.out.println("ATTRIBUTES = "); |
||
76 | 20412 | vcaballero | Iterator iterator=featureType.iterator();
|
77 | while (iterator.hasNext()) {
|
||
78 | IFeatureAttributeDescriptor descriptor = (IFeatureAttributeDescriptor) iterator.next(); |
||
79 | 20500 | vcaballero | int i=((DefaultAttributeDescriptor)descriptor).originalPosition();
|
80 | 19487 | jpiera | String type = descriptor.getDataType();
|
81 | if (type.equals(IFeatureAttributeDescriptor.TYPE_BOOLEAN)){
|
||
82 | System.out.print(" ----" + feature.getBoolean(i) +"\t" + "Boolean"); |
||
83 | }else if (type.equals(IFeatureAttributeDescriptor.TYPE_BYTE)){ |
||
84 | System.out.print(" ---- " + feature.getByte(i)+ " ---- Byte"); |
||
85 | }else if (type.equals(IFeatureAttributeDescriptor.TYPE_DATE)){ |
||
86 | System.out.print(" ---- " + feature.getDate(i)+ " ---- Date"); |
||
87 | }else if (type.equals(IFeatureAttributeDescriptor.TYPE_DOUBLE)){ |
||
88 | System.out.print(" ---- " + feature.getDouble(i)+ " ---- Double"); |
||
89 | }else if (type.equals(IFeatureAttributeDescriptor.TYPE_FLOAT)){ |
||
90 | System.out.print(" ---- " + feature.getFloat(i)+ " ---- Float"); |
||
91 | }else if (type.equals(IFeatureAttributeDescriptor.TYPE_INT)){ |
||
92 | System.out.print(" ---- " + feature.getInt(i)+ " ---- Integer"); |
||
93 | }else if (type.equals(IFeatureAttributeDescriptor.TYPE_LONG)){ |
||
94 | System.out.print(" ---- " + feature.getLong(i)+ " ---- Long"); |
||
95 | }else if (type.equals(IFeatureAttributeDescriptor.TYPE_STRING)){ |
||
96 | 19653 | vcaballero | System.out.print(" ---- " + feature.getString(i)+ " ---- String"); |
97 | 19627 | jmvivo | }else if (type.equals(IFeatureAttributeDescriptor.TYPE_GEOMETRY)){ |
98 | 19665 | jmvivo | if (feature.getGeometry(i) == null){ |
99 | System.out.print(" ---- " + feature.getGeometry(i)+ " ---- Geometry"); |
||
100 | }else {
|
||
101 | System.out.print(" ---- " + feature.getGeometry(i).getClass()+ " ---- Geometry"); |
||
102 | } |
||
103 | 19487 | jpiera | }else {
|
104 | System.out.print(" ---- " + "TYPE UNKNOWN"); |
||
105 | } |
||
106 | System.out.print("\n"); |
||
107 | 19627 | jmvivo | } |
108 | 19487 | jpiera | } |
109 | } |