jimm.datavision
Class ParameterReader

java.lang.Object
  extended by org.xml.sax.helpers.DefaultHandler
      extended by jimm.datavision.ParameterReader
All Implemented Interfaces:
org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler

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

A parameter reader reads an XML file and sets a Report's parameter values. This class is used when the report is being run from the command line and the user has given us the name of an XML file containing parameter elements.

Unlike a ReportReader, a parameter reader's constructor takes not only the report but also the input method (file name, stream, or reader). That way the report object doesn't have to know how to hold on to those multipule input types.

Author:
Jim Menard, jimm@io.com

Field Summary
protected static double DEFAULT_DTD_VERSION
          If there is no report element dtd-version attribute, this is the default value to use.
protected  java.io.File inFile
           
protected  org.xml.sax.InputSource inInputSource
           
protected  Parameter parameter
           
protected  Report report
           
protected  java.lang.String textData
           
 
Constructor Summary
ParameterReader(Report report, java.io.File f)
          Constructor.
ParameterReader(Report report, org.xml.sax.InputSource in)
          Constructor.
 
Method Summary
 void characters(char[] ch, int start, int length)
          Reads text data.
 void endElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName)
           
 java.lang.String getInputName()
          Returns the file name or, if that is null, the class name of whatever input source was handed to a constructor.
 void read()
          Reads parameter values from whichever input method was specified in the constructor.
 void startElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes attributes)
           
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endDocument, 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
 

Field Detail

DEFAULT_DTD_VERSION

protected static final double DEFAULT_DTD_VERSION
If there is no report element dtd-version attribute, this is the default value to use.

See Also:
Constant Field Values

report

protected Report report

parameter

protected Parameter parameter

textData

protected java.lang.String textData

inFile

protected java.io.File inFile

inInputSource

protected org.xml.sax.InputSource inInputSource
Constructor Detail

ParameterReader

public ParameterReader(Report report,
                       java.io.File f)
Constructor.

Parameters:
report - the report whose parameters we are setting
f - the parameter XML file

ParameterReader

public ParameterReader(Report report,
                       org.xml.sax.InputSource in)
Constructor. To specify a URL, use new InputSource("http://...").

Parameters:
report - the report whose parameters we are setting
in - the param XML input source
Method Detail

getInputName

public java.lang.String getInputName()
Returns the file name or, if that is null, the class name of whatever input source was handed to a constructor.

Returns:
a file name or class name

read

public void read()
          throws java.lang.Exception
Reads parameter values from whichever input method was specified in the constructor.

Throws:
java.lang.Exception

startElement

public void startElement(java.lang.String namespaceURI,
                         java.lang.String localName,
                         java.lang.String qName,
                         org.xml.sax.Attributes attributes)
                  throws org.xml.sax.SAXException
Specified by:
startElement in interface org.xml.sax.ContentHandler
Overrides:
startElement in class org.xml.sax.helpers.DefaultHandler
Throws:
org.xml.sax.SAXException

endElement

public void endElement(java.lang.String namespaceURI,
                       java.lang.String localName,
                       java.lang.String qName)
                throws org.xml.sax.SAXException
Specified by:
endElement in interface org.xml.sax.ContentHandler
Overrides:
endElement in class org.xml.sax.helpers.DefaultHandler
Throws:
org.xml.sax.SAXException

characters

public void characters(char[] ch,
                       int start,
                       int length)
Reads text data. Text data inside a single tag can be broken up into multiple calls to this method.

Specified by:
characters in interface org.xml.sax.ContentHandler
Overrides:
characters in class org.xml.sax.helpers.DefaultHandler