Package org.gvsig.fmap.geom.jts.gml
Class GMLHandler
java.lang.Object
org.xml.sax.helpers.DefaultHandler
org.gvsig.fmap.geom.jts.gml.GMLHandler
- All Implemented Interfaces:
ContentHandler,DTDHandler,EntityResolver,ErrorHandler
A SAX
DefaultHandler which builds Geometrys
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
- Author:
- David Zwiers, Vivid Solutions.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionGMLHandler(com.vividsolutions.jts.geom.GeometryFactory gf, ErrorHandler delegate) Creates a new handler. -
Method Summary
Modifier and TypeMethodDescriptionvoidcharacters(char[] ch, int start, int length) voidendElement(String uri, String localName, String qName) voidvoidprotected Locatorcom.vividsolutions.jts.geom.GeometryGets the geometry parsed by this handler.voidignorableWhitespace(char[] ch, int start, int length) booleanTests whether this handler has completed parsing a geometry.voidsetDocumentLocator(Locator locator) voidstartElement(String uri, String localName, String qName, Attributes attributes) voidMethods inherited from class org.xml.sax.helpers.DefaultHandler
endDocument, endPrefixMapping, notationDecl, processingInstruction, resolveEntity, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDeclMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.xml.sax.ContentHandler
declaration
-
Constructor Details
-
GMLHandler
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:
-
-
Method Details
-
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 com.vividsolutions.jts.geom.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:
IllegalStateException- if called before the parse is complete
-
characters
- Specified by:
charactersin interfaceContentHandler- Overrides:
charactersin classDefaultHandler- Throws:
SAXException- See Also:
-
ignorableWhitespace
- Specified by:
ignorableWhitespacein interfaceContentHandler- Overrides:
ignorableWhitespacein classDefaultHandler- Throws:
SAXException- See Also:
-
endElement
- Specified by:
endElementin interfaceContentHandler- Overrides:
endElementin classDefaultHandler- Throws:
SAXException- See Also:
-
startElement
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException - Specified by:
startElementin interfaceContentHandler- Overrides:
startElementin classDefaultHandler- Throws:
SAXException- See Also:
-
setDocumentLocator
- Specified by:
setDocumentLocatorin interfaceContentHandler- Overrides:
setDocumentLocatorin classDefaultHandler- See Also:
-
getDocumentLocator
-
fatalError
- Specified by:
fatalErrorin interfaceErrorHandler- Overrides:
fatalErrorin classDefaultHandler- Throws:
SAXException- See Also:
-
error
- Specified by:
errorin interfaceErrorHandler- Overrides:
errorin classDefaultHandler- Throws:
SAXException- See Also:
-
warning
- Specified by:
warningin interfaceErrorHandler- Overrides:
warningin classDefaultHandler- Throws:
SAXException- See Also:
-