Package org.h2gis.functions.io.osm

# Class OSMPreParser

java.lang.Object
org.xml.sax.helpers.DefaultHandler
org.h2gis.functions.io.osm.OSMPreParser

All Implemented Interfaces:
  `ContentHandler`, `DTDHandler`, `EntityResolver`, `ErrorHandler`

public class OSMPreParser extends DefaultHandler
OSMPreParser class just reads the document. It says what type of elements (nodes, ways and relation) the document contains. It also counts each type of elements.

Author:
  Erwan Bocher

## Constructor Summary

Constructors
Constructor
Description
`OSMPreParser()`
Initializing of the pre-parser.

## Method Summary

Modifier and Type
Method
Description
`int`
`getTotalNode()`
`int`
`getTotalRelation()`
`int`
`getTotalWay()`
`String`
`getVersion()`
`boolean`
`read(File inputFile)`
Reads the document and pre-parses it.
`void`
`startElement(String uri, String localName, String qName, Attributes attributes)`
Fires whenever an XML start markup is encountered.

### Methods inherited from class org.xml.sax.helpers.DefaultHandler

`characters, endDocument, endElement, endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warning`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface org.xml.sax.ContentHandler

`declaration`

## Constructor Details

### OSMPreParser

public OSMPreParser()
Initializing of the pre-parser. All values are set to zero.

## Method Details

### read

public boolean read(File inputFile) throws SAXException, IOException
Reads the document and pre-parses it. The other method is called automatically when a start markup is found.

Parameters:
  `inputFile` - the file to read
Returns:
  a boolean if the parser ends successfully or not
Throws:
  `SAXException`
  `IOException`

### startElement

public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException
Fires whenever an XML start markup is encountered. It indicates which version of osm file is to be parsed.

Specified by:
  `startElement` in interface `ContentHandler`
Overrides:
  `startElement` in class `DefaultHandler`
Parameters:
  `uri` - URI of the local element
  `localName` - Name of the local element (without prefix)
  `qName` - qName of the local element (with prefix)
  `attributes` - Attributes of the local element (contained in the markup)
Throws:
  `SAXException` - Any SAX exception, possibly wrapping another exception

### getVersion

public String getVersion()

### getTotalNode

public int getTotalNode()

### getTotalWay

public int getTotalWay()

### getTotalRelation

public int getTotalRelation()