org.openstreetmap.osmosis.core.xml.v0_6.impl
Class OsmHandler

java.lang.Object
  extended by org.xml.sax.helpers.DefaultHandler
      extended by org.openstreetmap.osmosis.core.xml.v0_6.impl.OsmHandler
All Implemented Interfaces:
org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler

public class OsmHandler
extends org.xml.sax.helpers.DefaultHandler

This class is a SAX default handler for processing OSM XML files. It utilises a tree of element processors to extract the data from the xml structure.

Author:
Brett Henderson

Constructor Summary
OsmHandler(Sink osmSink, boolean enableDateParsing)
          Creates a new instance.
 
Method Summary
 void endElement(java.lang.String uri, java.lang.String localName, java.lang.String qName)
          Ends processing of the current element.
 void error(org.xml.sax.SAXParseException e)
          Called by the SAX parser when an error occurs.
 void setDocumentLocator(org.xml.sax.Locator documentLocator)
          Sets the document locator which is used to report the position in the file when errors occur.
 void startElement(java.lang.String uri, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes attributes)
          Begins processing of a new element.
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
characters, endDocument, endPrefixMapping, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OsmHandler

public OsmHandler(Sink osmSink,
                  boolean enableDateParsing)
Creates a new instance.

Parameters:
osmSink - The new osmSink to write data to.
enableDateParsing - If true, dates will be parsed from xml data, else the current date will be used thus saving parsing time.
Method Detail

startElement

public void startElement(java.lang.String uri,
                         java.lang.String localName,
                         java.lang.String qName,
                         org.xml.sax.Attributes attributes)
Begins processing of a new element.

Specified by:
startElement in interface org.xml.sax.ContentHandler
Overrides:
startElement in class org.xml.sax.helpers.DefaultHandler
Parameters:
uri - The uri.
localName - The localName.
qName - The qName.
attributes - The attributes.

endElement

public void endElement(java.lang.String uri,
                       java.lang.String localName,
                       java.lang.String qName)
Ends processing of the current element.

Specified by:
endElement in interface org.xml.sax.ContentHandler
Overrides:
endElement in class org.xml.sax.helpers.DefaultHandler
Parameters:
uri - The uri.
localName - The localName.
qName - The qName.

setDocumentLocator

public void setDocumentLocator(org.xml.sax.Locator documentLocator)
Sets the document locator which is used to report the position in the file when errors occur.

Specified by:
setDocumentLocator in interface org.xml.sax.ContentHandler
Overrides:
setDocumentLocator in class org.xml.sax.helpers.DefaultHandler
Parameters:
documentLocator - The document locator.

error

public void error(org.xml.sax.SAXParseException e)
           throws org.xml.sax.SAXException
Called by the SAX parser when an error occurs. Used by this class to report the current position in the file.

Specified by:
error in interface org.xml.sax.ErrorHandler
Overrides:
error in class org.xml.sax.helpers.DefaultHandler
Parameters:
e - The exception that occurred.
Throws:
org.xml.sax.SAXException - if the error reporting throws an exception.