Package org.meteoinfo.jts.io.gml2
Class GMLHandler
- java.lang.Object
-
- org.xml.sax.helpers.DefaultHandler
-
- org.meteoinfo.jts.io.gml2.GMLHandler
-
public class GMLHandler extends org.xml.sax.helpers.DefaultHandlerA SAXDefaultHandlerwhich buildsGeometrys from GML2-formatted geometries. An XML parser can delegate SAX events to this handler to parse and building Geometrys.This handler currently ignores both namespaces and prefixes. Hints:
- If your parent handler is a DefaultHandler register the parent handler to receive the errors and locator calls.
- Use
GeometryStrategies.findStrategy(String, String)to help check for applicability
- See Also:
DefaultHandler
-
-
Constructor Summary
Constructors Constructor Description GMLHandler(GeometryFactory gf, org.xml.sax.ErrorHandler delegate)Creates a new handler.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcharacters(char[] ch, int start, int length)voidendElement(java.lang.String uri, java.lang.String localName, java.lang.String qName)voiderror(org.xml.sax.SAXParseException e)voidfatalError(org.xml.sax.SAXParseException e)protected org.xml.sax.LocatorgetDocumentLocator()GeometrygetGeometry()Gets the geometry parsed by this handler.voidignorableWhitespace(char[] ch, int start, int length)booleanisGeometryComplete()Tests whether this handler has completed parsing a geometry.voidsetDocumentLocator(org.xml.sax.Locator locator)voidstartElement(java.lang.String uri, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes attributes)voidwarning(org.xml.sax.SAXParseException e)
-
-
-
Constructor Detail
-
GMLHandler
public GMLHandler(GeometryFactory gf, org.xml.sax.ErrorHandler delegate)
Creates a new handler. Allows the user to specify a delegate object for error / warning messages. If the delegate also implements ContentHandler then the document Locator will be passed on.- Parameters:
gf- Geometry Factorydelegate- Nullable- See Also:
ErrorHandler,ContentHandler,ContentHandler.setDocumentLocator(org.xml.sax.Locator),Locator
-
-
Method Detail
-
isGeometryComplete
public boolean isGeometryComplete()
Tests whether this handler has completed parsing a geometry. If this is the case,getGeometry()can be called to get the value of the parsed geometry.- Returns:
- if the parsing of the geometry is complete
-
getGeometry
public Geometry getGeometry()
Gets the geometry parsed by this handler. This method should only be called AFTER the parser has completed execution- Returns:
- the parsed Geometry, or a GeometryCollection if more than one geometry was parsed
- Throws:
java.lang.IllegalStateException- if called before the parse is complete
-
characters
public void characters(char[] ch, int start, int length) throws org.xml.sax.SAXException- Overrides:
charactersin classorg.xml.sax.helpers.DefaultHandler- Throws:
org.xml.sax.SAXException- See Also:
DefaultHandler.characters(char[], int, int)
-
ignorableWhitespace
public void ignorableWhitespace(char[] ch, int start, int length) throws org.xml.sax.SAXException- Overrides:
ignorableWhitespacein classorg.xml.sax.helpers.DefaultHandler- Throws:
org.xml.sax.SAXException- See Also:
DefaultHandler.ignorableWhitespace(char[], int, int)
-
endElement
public void endElement(java.lang.String uri, java.lang.String localName, java.lang.String qName) throws org.xml.sax.SAXException- Overrides:
endElementin classorg.xml.sax.helpers.DefaultHandler- Throws:
org.xml.sax.SAXException- See Also:
DefaultHandler.endElement(java.lang.String, java.lang.String, java.lang.String)
-
startElement
public void startElement(java.lang.String uri, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes attributes) throws org.xml.sax.SAXException- Overrides:
startElementin classorg.xml.sax.helpers.DefaultHandler- Throws:
org.xml.sax.SAXException- See Also:
DefaultHandler.startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)
-
setDocumentLocator
public void setDocumentLocator(org.xml.sax.Locator locator)
- Overrides:
setDocumentLocatorin classorg.xml.sax.helpers.DefaultHandler- See Also:
DefaultHandler.setDocumentLocator(org.xml.sax.Locator)
-
getDocumentLocator
protected org.xml.sax.Locator getDocumentLocator()
-
fatalError
public void fatalError(org.xml.sax.SAXParseException e) throws org.xml.sax.SAXException- Overrides:
fatalErrorin classorg.xml.sax.helpers.DefaultHandler- Throws:
org.xml.sax.SAXException- See Also:
DefaultHandler.fatalError(org.xml.sax.SAXParseException)
-
error
public void error(org.xml.sax.SAXParseException e) throws org.xml.sax.SAXException- Overrides:
errorin classorg.xml.sax.helpers.DefaultHandler- Throws:
org.xml.sax.SAXException- See Also:
DefaultHandler.error(org.xml.sax.SAXParseException)
-
warning
public void warning(org.xml.sax.SAXParseException e) throws org.xml.sax.SAXException- Overrides:
warningin classorg.xml.sax.helpers.DefaultHandler- Throws:
org.xml.sax.SAXException- See Also:
DefaultHandler.warning(org.xml.sax.SAXParseException)
-
-