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 InputTemplate
or:
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(String uri,
String name,
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(SAXParseException exception) |
void |
fatalError(SAXParseException exception) |
void |
processMultiItems(boolean accept)
Added slightly better support for type=OBJECT.
|
FeatureCollection |
read(DriverProperties dp)
Main Entry - load in a GML file
|
FeatureCollection |
read(Reader r)
Helper function - calls read(java.io.Reader r,String readerName) with the
readerName "Unknown Stream".
|
FeatureCollection |
read(Reader r,
String readerName)
Main function to read a GML file.
|
void |
setInputTemplate(GMLInputTemplate template)
Attach a GMLInputTemplate information class.
|
void |
startDocument()
SAX handler - move to state 1
|
void |
startElement(String uri,
String name,
String qName,
Attributes atts)
SAX handler.
|
void |
warning(SAXParseException exception) |
endPrefixMapping, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startPrefixMapping, unparsedEntityDeclpublic 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 SAXException
characters in interface ContentHandlercharacters in class org.xml.sax.helpers.DefaultHandlerch - Description of the Parameterstart - Description of the Parameterlength - Description of the ParameterSAXException - Description of the Exceptionpublic void endDocument()
endDocument in interface ContentHandlerendDocument in class org.xml.sax.helpers.DefaultHandlerpublic void endElement(String uri, String name, String qName) throws SAXException
endElement in interface ContentHandlerendElement in class org.xml.sax.helpers.DefaultHandleruri - Description of the Parametername - Description of the ParameterqName - Description of the ParameterSAXException - Description of the Exceptionpublic void error(SAXParseException exception) throws SAXException
error in interface ErrorHandlererror in class org.xml.sax.helpers.DefaultHandlerSAXExceptionpublic void fatalError(SAXParseException exception) throws SAXException
fatalError in interface ErrorHandlerfatalError in class org.xml.sax.helpers.DefaultHandlerSAXExceptionpublic FeatureCollection read(DriverProperties dp) throws IllegalParametersException, Exception
read in interface JUMPReaderdp - Description of the ParameterIllegalParametersException - Description of the ExceptionException - Description of the Exceptionpublic FeatureCollection read(Reader r) throws Exception
r - reader to read the GML File fromException - Description of the Exceptionpublic FeatureCollection read(Reader r, String readerName) throws Exception
r - reader to read the GML File fromreaderName - what to call the reader for error reportingException - Description of the Exceptionpublic void startDocument()
startDocument in interface ContentHandlerstartDocument in class org.xml.sax.helpers.DefaultHandlerpublic void startElement(String uri, String name, String qName, Attributes atts) throws SAXException
startElement in interface ContentHandlerstartElement in class org.xml.sax.helpers.DefaultHandleruri - Description of the Parametername - Description of the ParameterqName - Description of the Parameteratts - Description of the ParameterSAXException - Description of the Exceptionpublic void warning(SAXParseException exception) throws SAXException
warning in interface ErrorHandlerwarning in class org.xml.sax.helpers.DefaultHandlerSAXExceptionCopyright © 2015. All rights reserved.