Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.gersonworks.xml.util
Class XMLPropertiesHandler  view XMLPropertiesHandler download XMLPropertiesHandler.java

java.lang.Object
  extended byorg.xml.sax.helpers.DefaultHandler
      extended bycom.gersonworks.xml.util.XMLPropertiesHandler
All Implemented Interfaces:
org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler

class XMLPropertiesHandler
extends org.xml.sax.helpers.DefaultHandler

The XMLPropertiesHandler class acts as a handler to the XMLProperties file while it is being parsed by the SAX Parser. Most of the methods provided by this class only handles events wherein the SAX parser has entered and left the property and value elements.

This is not a public class because only the XMLProperties object directly accesses it.

Copyright: Copyright (c) 21 January 2004

Version:
1.1, 29 January 2004

Field Summary
private  boolean insideValueElement
           
private  java.io.PrintWriter log
           
private  java.lang.String propertyKey
           
private  java.lang.String propertyValue
           
private  XMLPropertyValues propertyValues
           
private  boolean verbose
           
private  java.util.Map xmlProperties
           
 
Constructor Summary
XMLPropertiesHandler(java.io.File file)
          Constructs an XMLPropertiesHandler for the given File instance of the XML document to be parsed.
XMLPropertiesHandler(java.io.InputStream inStream)
          Constructs an XMLPropertiesHandler for the given InputStream as the XML document to be parsed.
XMLPropertiesHandler(java.lang.String uri)
          Constructs an XMLPropertiesHandler for the URI of the XML document to be parsed.
 
Method Summary
 void characters(char[] ch, int start, int length)
          Creates a string from the text found inside the value element.
private  void constructXMLPropertiesHandler(java.lang.Object o)
          A special purpose method to lessen the number of lines I need to write especially if the only difference between the two contructors is the way the SAXParser.parse() method is called.
 java.lang.String detailedMessage()
          Returns the key-value pair when the error occured.
 void endDocument()
          Used only for debugging purposes
 void endElement(java.lang.String namespaceURI, java.lang.String sName, java.lang.String qName)
          Overrides the endElement() method of the DefaultHandler class.
 void error(org.xml.sax.SAXParseException ex)
          Outputs a detailed error message.
 void fatalError(org.xml.sax.SAXParseException ex)
          Outputs a detailed fatal error message.
 java.util.Map getProperties()
          Returns the property list (key-values pair) generated by this handler.
 void startDocument()
          Used only for debugging purposes
 void startElement(java.lang.String namespaceURI, java.lang.String sName, java.lang.String qName, org.xml.sax.Attributes attrs)
          Overrides the startElement() method of the DefaultHandler class.
private  void verbosePrint(java.lang.String str)
          For debugging purposes.
private  void verbosePrintln(java.lang.String str)
          For debugging purposes.
 void warning(org.xml.sax.SAXParseException ex)
          Outputs a detailed warning message.
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endPrefixMapping, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startPrefixMapping, unparsedEntityDecl
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

xmlProperties

private java.util.Map xmlProperties

propertyValues

private XMLPropertyValues propertyValues

insideValueElement

private boolean insideValueElement

log

private java.io.PrintWriter log

propertyKey

private java.lang.String propertyKey

propertyValue

private java.lang.String propertyValue

verbose

private boolean verbose
Constructor Detail

XMLPropertiesHandler

public XMLPropertiesHandler(java.io.File file)
Constructs an XMLPropertiesHandler for the given File instance of the XML document to be parsed.


XMLPropertiesHandler

public XMLPropertiesHandler(java.lang.String uri)
Constructs an XMLPropertiesHandler for the URI of the XML document to be parsed.


XMLPropertiesHandler

public XMLPropertiesHandler(java.io.InputStream inStream)
Constructs an XMLPropertiesHandler for the given InputStream as the XML document to be parsed.

Since:
XMLProperties version 1.1
Method Detail

constructXMLPropertiesHandler

private void constructXMLPropertiesHandler(java.lang.Object o)
A special purpose method to lessen the number of lines I need to write especially if the only difference between the two contructors is the way the SAXParser.parse() method is called.


getProperties

public java.util.Map getProperties()
Returns the property list (key-values pair) generated by this handler.


startDocument

public void startDocument()
                   throws org.xml.sax.SAXException
Used only for debugging purposes


endDocument

public void endDocument()
                 throws org.xml.sax.SAXException
Used only for debugging purposes


startElement

public void startElement(java.lang.String namespaceURI,
                         java.lang.String sName,
                         java.lang.String qName,
                         org.xml.sax.Attributes attrs)
                  throws org.xml.sax.SAXException
Overrides the startElement() method of the DefaultHandler class.


endElement

public void endElement(java.lang.String namespaceURI,
                       java.lang.String sName,
                       java.lang.String qName)
                throws org.xml.sax.SAXException
Overrides the endElement() method of the DefaultHandler class.


characters

public void characters(char[] ch,
                       int start,
                       int length)
                throws org.xml.sax.SAXException
Creates a string from the text found inside the value element.


warning

public void warning(org.xml.sax.SAXParseException ex)
             throws XMLPropertiesFormatException
Outputs a detailed warning message.


error

public void error(org.xml.sax.SAXParseException ex)
           throws XMLPropertiesFormatException
Outputs a detailed error message.


fatalError

public void fatalError(org.xml.sax.SAXParseException ex)
                throws XMLPropertiesFormatException
Outputs a detailed fatal error message.


detailedMessage

public java.lang.String detailedMessage()
Returns the key-value pair when the error occured.


verbosePrint

private void verbosePrint(java.lang.String str)
For debugging purposes.


verbosePrintln

private void verbosePrintln(java.lang.String str)
For debugging purposes.