Revision 9729 trunk/libraries/libRemoteServices/src/org/gvsig/remoteClient/gml/GMLReader.java
GMLReader.java | ||
---|---|---|
3 | 3 |
import java.awt.geom.Rectangle2D; |
4 | 4 |
import java.io.File; |
5 | 5 |
import java.io.FileNotFoundException; |
6 |
import java.util.ArrayList;
|
|
6 |
import java.io.IOException;
|
|
7 | 7 |
|
8 |
import org.gvsig.exceptions.BaseException; |
|
9 |
import org.gvsig.exceptions.ListBaseException; |
|
10 |
import org.gvsig.remoteClient.gml.exceptions.GMLException; |
|
11 |
import org.gvsig.remoteClient.gml.exceptions.GMLParserException; |
|
8 | 12 |
import org.gvsig.remoteClient.gml.factories.FeaturesParserFactory; |
9 | 13 |
import org.gvsig.remoteClient.gml.factories.IGeometriesFactory; |
10 | 14 |
import org.gvsig.remoteClient.gml.factories.XMLParserFactory; |
11 | 15 |
import org.gvsig.remoteClient.gml.schemas.XMLSchemaManager; |
12 | 16 |
import org.gvsig.remoteClient.gml.schemas.XMLSchemaParser; |
17 |
import org.gvsig.remoteClient.gml.warnings.GMLWarningInfo; |
|
18 |
import org.xmlpull.v1.XmlPullParserException; |
|
13 | 19 |
|
14 | 20 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
15 | 21 |
* |
... | ... | |
55 | 61 |
* |
56 | 62 |
* $Id$ |
57 | 63 |
* $Log$ |
58 |
* Revision 1.3 2006-12-22 11:25:44 csanchez |
|
64 |
* Revision 1.4 2007-01-15 13:11:00 csanchez |
|
65 |
* Sistema de Warnings y Excepciones adaptado a BasicException |
|
66 |
* |
|
67 |
* Revision 1.3 2006/12/22 11:25:44 csanchez |
|
59 | 68 |
* Nuevo parser GML 2.x para gml's sin esquema |
60 | 69 |
* |
61 | 70 |
* Revision 1.2 2006/11/06 12:15:11 jorpiell |
... | ... | |
83 | 92 |
public class GMLReader { |
84 | 93 |
private XMLSchemaManager schemaManager = null; |
85 | 94 |
private GMLFeaturesParser featuresParser = null; |
86 |
private GMLFileParseInfo warnings = null; |
|
95 |
private FeaturesParserFactory featuresFactory = null; |
|
96 |
private GMLWarningInfo warnings = null; |
|
87 | 97 |
private File m_File = null; |
88 | 98 |
|
89 | 99 |
|
... | ... | |
98 | 108 |
* @throws FileNotFoundException |
99 | 109 |
* When the file is not found |
100 | 110 |
*/ |
101 |
public GMLReader(File file,IGeometriesFactory factory) throws Exception{ |
|
111 |
public GMLReader(File file,IGeometriesFactory factory) throws GMLException{
|
|
102 | 112 |
|
103 | 113 |
//file to parse... |
104 | 114 |
this.m_File = file; |
... | ... | |
113 | 123 |
* GML geometries |
114 | 124 |
* @throws Exception |
115 | 125 |
*/ |
116 |
private void initialize(IGeometriesFactory factory) throws Exception{ |
|
126 |
private void initialize(IGeometriesFactory factory) throws GMLException{
|
|
117 | 127 |
|
118 |
warnings = new GMLFileParseInfo();
|
|
128 |
warnings = new GMLWarningInfo();
|
|
119 | 129 |
XMLSchemaParser parser = new XMLParserFactory().createSchemaParser(m_File); |
120 | 130 |
|
121 | 131 |
//Retrieve the header attributes and download and parse the schema |
122 | 132 |
schemaManager = new XMLSchemaManager(m_File); |
123 |
schemaManager.parse(parser); |
|
133 |
try { |
|
134 |
schemaManager.parse(parser); |
|
135 |
} catch (XmlPullParserException e) { |
|
136 |
// TODO Auto-generated catch block |
|
137 |
throw new GMLException(m_File.getName(),e); |
|
138 |
} catch (IOException e) { |
|
139 |
// TODO Auto-generated catch block |
|
140 |
throw new GMLException(m_File.getName(),e); |
|
141 |
} |
|
124 | 142 |
|
125 | 143 |
//Parse the GML global fields |
126 |
featuresParser = new FeaturesParserFactory().createParser(getVersion(),factory,parser); |
|
144 |
featuresFactory = new FeaturesParserFactory(); |
|
145 |
try { |
|
146 |
featuresParser = featuresFactory.createParser(getVersion(),factory,parser); |
|
147 |
} catch (GMLParserException e) { |
|
148 |
throw new GMLException(m_File.getName(),e); |
|
149 |
} |
|
150 |
|
|
127 | 151 |
} |
128 | 152 |
|
129 | 153 |
/** |
... | ... | |
133 | 157 |
* Factory to create the geometries |
134 | 158 |
* @return |
135 | 159 |
*/ |
136 |
public IGMLFeaturesIterator getFeaturesIterator() throws Exception{ |
|
137 |
return featuresParser.getFeaturesReader(); |
|
160 |
public IGMLFeaturesIterator getFeaturesIterator() throws GMLException{ |
|
161 |
try { |
|
162 |
return featuresParser.getFeaturesReader(); |
|
163 |
} catch (BaseException e) { |
|
164 |
throw new GMLException(e); |
|
165 |
} |
|
138 | 166 |
} |
139 | 167 |
|
140 | 168 |
/** |
... | ... | |
146 | 174 |
|
147 | 175 |
/** |
148 | 176 |
* @return Returns a list of codes with information to the user about GML parse. |
177 |
* @throws ListBaseException |
|
149 | 178 |
*/ |
150 |
public ArrayList getWarnings(){
|
|
179 |
public ListBaseException getWarnings(){
|
|
151 | 180 |
if (schemaManager.warnings.areWarnings()) |
152 | 181 |
{ |
153 | 182 |
warnings.setGMLWarningList(schemaManager.warnings.getGMLWarningList()); |
154 | 183 |
} |
155 |
return this.warnings.getGMLWarningList(); |
|
184 |
if (featuresFactory.warnings.areWarnings()) |
|
185 |
{ |
|
186 |
warnings.setGMLWarningList(featuresFactory.warnings.getGMLWarningList()); |
|
187 |
} |
|
188 |
//*********************************************************** |
|
189 |
// CUIDADO CON LANZAR LOS WARNINGS, YA VEREMOS COMO LANZARLOS |
|
190 |
//*********************************************************** |
|
191 |
return warnings.getGMLWarningList(); |
|
192 |
|
|
156 | 193 |
} |
157 | 194 |
|
195 |
// /** |
|
196 |
// * @return Returns true if there are warnings parsing the gml file. |
|
197 |
// */ |
|
198 |
// public boolean areWarnings(){ |
|
199 |
// this.getWarnings(); |
|
200 |
// if (warnings.areWarnings()) |
|
201 |
// { |
|
202 |
// return true; |
|
203 |
// } |
|
204 |
// return false; |
|
205 |
// } |
|
206 |
|
|
158 | 207 |
/** |
159 | 208 |
* @return Returns the target namespace. |
160 | 209 |
*/ |
Also available in: Unified diff