org.hackystat.sensorbase.db.postgres
Class SensorPropertiesHandler

java.lang.Object
  extended by org.xml.sax.helpers.DefaultHandler
      extended by org.hackystat.sensorbase.db.postgres.SensorPropertiesHandler
All Implemented Interfaces:
org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler

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

The DefaultHandler implementation that parses the optional property key-value pairs. The getKeyValMap() method returns a mapping of property keys to values when an xml document is parsed.

Author:
Austen Ito

Constructor Summary
SensorPropertiesHandler()
           
 
Method Summary
 void characters(char[] ch, int start, int length)
          Reads the characters of the parsed string at the specified start and end positions.
 java.util.Map<java.lang.String,java.lang.String> getKeyValMap()
          Returns the populated property key-value mapping.
 void startElement(java.lang.String uri, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes attributes)
          Determines if the current element is the "Key" tag or "Value" tag.
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
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
 

Constructor Detail

SensorPropertiesHandler

public SensorPropertiesHandler()
Method Detail

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
Determines if the current element is the "Key" tag or "Value" tag. If the element is either or those, the values of the elements are read.

Specified by:
startElement in interface org.xml.sax.ContentHandler
Overrides:
startElement in class org.xml.sax.helpers.DefaultHandler
Parameters:
uri - the uri of the element.
localName - the local name of the element.
qName - the tag name.
attributes - the element attributes.
Throws:
org.xml.sax.SAXException - thrown if the xml document can't be parsed.

characters

public void characters(char[] ch,
                       int start,
                       int length)
                throws org.xml.sax.SAXException
Reads the characters of the parsed string at the specified start and end positions.

Specified by:
characters in interface org.xml.sax.ContentHandler
Overrides:
characters in class org.xml.sax.helpers.DefaultHandler
Parameters:
ch - the parsed xml string.
start - the start index to read from the string.
length - the amount of characters to read from the string.
Throws:
org.xml.sax.SAXException - thrown if the xml document can't be parsed.

getKeyValMap

public java.util.Map<java.lang.String,java.lang.String> getKeyValMap()
Returns the populated property key-value mapping.

Returns:
the property mapping.