org.deegree.cs.persistence.deegree.d3.parsers
Class DefinitionParser

java.lang.Object
  extended by org.deegree.cs.persistence.deegree.d3.parsers.DefinitionParser
Direct Known Subclasses:
CoordinateSystemParser, DatumParser, EllipsoidParser, PrimemeridianParser, ProjectionParser, TransformationParser

public abstract class DefinitionParser
extends Object

The parent class of all parsers defines convenience methods common to all StAX based crs parsers as well as reading in the locations of the crs components defintions.

Version:
$Revision: 31619 $, $Date: 2011-08-23 14:56:28 +0200 (Tue, 23 Aug 2011) $
Author:
Rutger Bezema, last edited by: $Author: mschneider $

Field Summary
protected  DeegreeCRSStore store
           
 
Constructor Summary
protected DefinitionParser(DeegreeCRSStore store, URL configURL)
           
 
Method Summary
protected abstract  QName expectedRootName()
           
protected  XMLStreamReader getConfigReader()
          Get the configuration reader.
protected  URL getConfigURL()
           
 DeegreeCRSStore getStore()
           
 boolean moveReaderToNextIdentifiable(XMLStreamReader reader, QName elementName)
          Forwards the stream
 boolean moveReaderToNextIdentifiable(XMLStreamReader reader, Set<QName> allowedElements)
          Forwards the stream
protected  CRSResource parseIdentifiable(XMLStreamReader reader)
          Parses all elements of the identifiable object, it is assumed the reader is on a top level element, the next element will be an id.
protected  double parseLatLonType(XMLStreamReader reader, QName qName, boolean required, double defaultValue)
          Post: reader will be at XMLStreamConstants.START_ELEMENT of the next element.
protected  Unit parseUnit(XMLStreamReader reader, boolean required)
          Parses a unit from the given xml-parent.
 boolean readEntireFile()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

store

protected DeegreeCRSStore store
Constructor Detail

DefinitionParser

protected DefinitionParser(DeegreeCRSStore store,
                           URL configURL)
Parameters:
store -
configURL -
Method Detail

expectedRootName

protected abstract QName expectedRootName()
Returns:
the top level element of a configuration file.

getConfigReader

protected XMLStreamReader getConfigReader()
                                   throws XMLStreamException
Get the configuration reader. The stream will be before the end document event or null if the entire file was read.

Returns:
the configuration reader.
Throws:
XMLStreamException

parseIdentifiable

protected CRSResource parseIdentifiable(XMLStreamReader reader)
                                 throws CRSConfigurationException
Parses all elements of the identifiable object, it is assumed the reader is on a top level element, the next element will be an id. After this method the reader will point to the first element after areasOfUse.

Parameters:
reader - the xml-reader pointing to parent of the first id-element
Returns:
the identifiable object or null if no id was given.
Throws:
CRSConfigurationException

parseUnit

protected Unit parseUnit(XMLStreamReader reader,
                         boolean required)
                  throws CRSConfigurationException
Parses a unit from the given xml-parent.

Parameters:
reader - xml-reader to parse the unit from.
required - if the unit is required.
Returns:
the unit object or null if not required and not found.
Throws:
CRSConfigurationException - if the unit object could not be created.

getStore

public DeegreeCRSStore getStore()
Returns:
the provider used for reversed look ups, will never be null

moveReaderToNextIdentifiable

public boolean moveReaderToNextIdentifiable(XMLStreamReader reader,
                                            QName elementName)
                                     throws XMLStreamException
Forwards the stream

Parameters:
reader - to forward
elementName -
Returns:
true if the stream is pointing to an element with the given qname.
Throws:
XMLStreamException

parseLatLonType

protected double parseLatLonType(XMLStreamReader reader,
                                 QName qName,
                                 boolean required,
                                 double defaultValue)
                          throws XMLStreamException
Post: reader will be at XMLStreamConstants.START_ELEMENT of the next element.

Parameters:
reader - to be used.
qName - name of the element
required - if true and the element is missing an exception will be thrown.
defaultValue -
Returns:
the value of the lat lon type or 0 if the element was not defined (and was not required.)
Throws:
XMLStreamException

moveReaderToNextIdentifiable

public boolean moveReaderToNextIdentifiable(XMLStreamReader reader,
                                            Set<QName> allowedElements)
                                     throws XMLStreamException
Forwards the stream

Parameters:
reader - to forward
allowedElements -
Returns:
true if the stream is pointing to an element with the given qname.
Throws:
XMLStreamException

readEntireFile

public boolean readEntireFile()
Returns:
true if the entire file has been read, false otherwise.

getConfigURL

protected URL getConfigURL()
Returns:
the configuration url.


Copyright © 2011. All Rights Reserved.