public class GMLReader extends org.xml.sax.helpers.DefaultHandler implements JUMPReader
JUMPReader specialized to read GML files.
DataProperties for the JCSReader load(DataProperties) interface:
| Parameter | Meaning |
|---|---|
| File or DefaultValue | File name for the input .xml file |
| InputTemplateFile | Filename for the GMLInputTemplate .xml file |
| CompressedFile | File name (a .zip or .gz) with a .jml/.xml/.gml inside (specified by File) |
| CompressedFileTemplate | File name (.zip or .gz) with the input template in (specified by InputTemplateFile) |
gmlReader = new GMLReader(); gmlReader.load(DriverProperties); // has InputFile and InputTemplateor:
gmlReader.setInputTemplate( GMLInputTemplate);
gmlReader.load( , );
0 -----> 1
|
| Collection start Tag
|
-->2----------------> FINISH
\ | End Collection tag
End Feature tag \ |
\|
4<-------->3
Geometry start/end
example of double GCs: START geometry ->move to state 4 START TAG: multi* -> move to state 1000, geometry = recursivegeometry[0]Most of the work is done in the endTag method!-> added to geometry -> added to geometry START TAG: multi* -> move to state 1001, geometry = recursivegeometry[1] -> added to geometry -> added to geometry END TAG: multi -> move to state 1000, build geometry in recursivegeometry[1], add to recursivegeometry[0], geometry = recursivegeometry[0] -> added to geometry END TAG: multi -> move to state 4, build geometry in recursivegeometry[0] (thats the result) and put it in finalGeometry END geometry -> add to feature collection example of simple geometry: START geometry ->move to state 4 BEGIN polygon ->clear out inner ring accumulator BEGIN outerboundary BEGIN linearring END linearring -> put points in linearRing END outerboundary -> put linearRing in outerBoundary BEGIN innerboundary BEGIN linearring END linearring -> put points in linearRing END innerboundary -> add linearRing to innerBoundary list END polygon -> build polygon (put in geometry, which is recursivegeometry[0] END geometry => add to feature collection
| Modifier and Type | Field and Description |
|---|---|
boolean |
multiItemsAsLists
true => for 'OBJECT' types, if you find more than 1 item, make a list and
store all the results
|
boolean |
parseSRID |
| Constructor and Description |
|---|
GMLReader()
Constructor - make a SAXParser and have this GMLReader be its
ContentHandler and ErrorHandler.
|
| Modifier and Type | Method and Description |
|---|---|
void |
acceptSRID(boolean parseTheSRID)
parse SRID information in geometry tags
|
void |
characters(char[] ch,
int start,
int length)
SAX handler - store and accumulate tag bodies
|
void |
endDocument()
SAX HANDLER - move to state 0
|
void |
endElement(java.lang.String uri,
java.lang.String name,
java.lang.String qName)
SAX handler - handle state information and transitions based on ending
elements Most of the work of the parser is done here.
|
void |
error(org.xml.sax.SAXParseException exception) |
void |
fatalError(org.xml.sax.SAXParseException exception) |
java.util.Collection<java.lang.Exception> |
getExceptions() |
void |
processMultiItems(boolean accept)
Added slightly better support for type=OBJECT.
|
FeatureCollection |
read(DriverProperties dp)
Main Entry - load in a GML file
|
FeatureCollection |
read(java.lang.Object o,
java.lang.String readerName)
Main function to read a GML file.
|
FeatureCollection |
read(java.io.Reader r)
Helper function - calls read(java.io.Reader r,String readerName) with the
readerName "Unknown Stream".
|
void |
setInputTemplate(GMLInputTemplate template)
Attach a GMLInputTemplate information class.
|
void |
startDocument()
SAX handler - move to state 1
|
void |
startElement(java.lang.String uri,
java.lang.String name,
java.lang.String qName,
org.xml.sax.Attributes atts)
SAX handler.
|
void |
warning(org.xml.sax.SAXParseException exception) |
public boolean parseSRID
public boolean multiItemsAsLists
public GMLReader()
public void acceptSRID(boolean parseTheSRID)
parseTheSRID - true = parsepublic void processMultiItems(boolean accept)
public void setInputTemplate(GMLInputTemplate template)
template - The new inputTemplate valuepublic void characters(char[] ch,
int start,
int length)
throws org.xml.sax.SAXException
characters in interface org.xml.sax.ContentHandlercharacters in class org.xml.sax.helpers.DefaultHandlerch - Description of the Parameterstart - Description of the Parameterlength - Description of the Parameterorg.xml.sax.SAXException - Description of the Exceptionpublic void endDocument()
endDocument in interface org.xml.sax.ContentHandlerendDocument in class org.xml.sax.helpers.DefaultHandlerpublic void endElement(java.lang.String uri,
java.lang.String name,
java.lang.String qName)
throws org.xml.sax.SAXException
endElement in interface org.xml.sax.ContentHandlerendElement in class org.xml.sax.helpers.DefaultHandleruri - Description of the Parametername - Description of the ParameterqName - Description of the Parameterorg.xml.sax.SAXException - Description of the Exceptionpublic void error(org.xml.sax.SAXParseException exception)
throws org.xml.sax.SAXException
error in interface org.xml.sax.ErrorHandlererror in class org.xml.sax.helpers.DefaultHandlerorg.xml.sax.SAXExceptionpublic void fatalError(org.xml.sax.SAXParseException exception)
throws org.xml.sax.SAXException
fatalError in interface org.xml.sax.ErrorHandlerfatalError in class org.xml.sax.helpers.DefaultHandlerorg.xml.sax.SAXExceptionpublic FeatureCollection read(DriverProperties dp) throws IllegalParametersException, java.lang.Exception
read in interface JUMPReaderdp - Description of the ParameterIllegalParametersException - Description of the Exceptionjava.lang.Exception - Description of the Exceptionpublic FeatureCollection read(java.io.Reader r) throws java.lang.Exception
r - reader to read the GML File fromjava.lang.Exception - Description of the Exceptionpublic FeatureCollection read(java.lang.Object o, java.lang.String readerName) throws java.lang.Exception
o - reader/inputstream object to read the GML fromreaderName - what to call the reader for error reportingjava.lang.Exception - Description of the Exceptionpublic void startDocument()
startDocument in interface org.xml.sax.ContentHandlerstartDocument in class org.xml.sax.helpers.DefaultHandlerpublic void startElement(java.lang.String uri,
java.lang.String name,
java.lang.String qName,
org.xml.sax.Attributes atts)
throws org.xml.sax.SAXException
startElement in interface org.xml.sax.ContentHandlerstartElement in class org.xml.sax.helpers.DefaultHandleruri - Description of the Parametername - Description of the ParameterqName - Description of the Parameteratts - Description of the Parameterorg.xml.sax.SAXException - Description of the Exceptionpublic void warning(org.xml.sax.SAXParseException exception)
throws org.xml.sax.SAXException
warning in interface org.xml.sax.ErrorHandlerwarning in class org.xml.sax.helpers.DefaultHandlerorg.xml.sax.SAXExceptionpublic java.util.Collection<java.lang.Exception> getExceptions()
getExceptions in interface JUMPReader