xmlgen
Class XMLGenerator

java.lang.Object
  |
  +--xmlgen.XMLGenerator

public class XMLGenerator
extends java.lang.Object

Contains the methods necessary to create a XML document for display on the web or for use by another application.


Constructor Summary
XMLGenerator()
          Constructor that initializes a new StringBuffer
 
Method Summary
 void addData(java.sql.ResultSet rs, java.lang.String dataType)
          Loops through the ResultSet and converts the records to XML data elements
 void addElement(java.lang.String elementName, java.lang.String elementValue)
          Allows for one element at a time to be added to the XML
 void addInput(java.lang.String inputType, java.lang.String inputName, int inputValue)
          Prints the XML tags that are used to generate a HTML form element
 void addInput(java.lang.String inputType, java.lang.String inputName, java.lang.String inputValue)
          Prints the XML tags that are used to generate a HTML form element
 void addInput(java.lang.String inputType, java.lang.String inputName, java.lang.String inputValue, java.lang.String onClick)
          Prints the XML tags that are used to generate a HTML form element (button type)
 void addScript(java.lang.String scriptLanguage, java.lang.String scriptOps)
          Allows for a script to be added into the XML document (i.e.
 java.lang.String format(java.lang.String input)
          Determines if the string is a decimal number and truncates all decimal values to the desired precision length.
 void printBeginForm(java.lang.String formName, java.lang.String formMethod, java.lang.String formAction)
          Prints the start tag and parameters of the form section
 void printBeginRoot(java.lang.String rootElement)
          Creates the strating root element tag.
 void printEndForm()
          Prints the end tag of the form section
 void printEndRoot(java.lang.String rootElement)
          Closes the root element tag.
 void printStylesheet(java.lang.String stylesheet)
          Prints the stylesheet line in the XML document, allowing to format the data for output
 void printXMLHeader()
          Prints the XML tag necessary at the beginning of the XML document
 void setFormat(boolean format)
          Method to set formatting flag used to determine if decimal values should be set to a specific precision
 java.lang.String toXML()
          Converts the StringBuffer object to a string wich the servlet can display
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLGenerator

public XMLGenerator()
Constructor that initializes a new StringBuffer
Method Detail

printXMLHeader

public void printXMLHeader()
Prints the XML tag necessary at the beginning of the XML document

printStylesheet

public void printStylesheet(java.lang.String stylesheet)
Prints the stylesheet line in the XML document, allowing to format the data for output
Parameters:
stylesheet - the name of the stylesheet to reference

printBeginRoot

public void printBeginRoot(java.lang.String rootElement)
Creates the strating root element tag. Used with printEndRoot(String)
Parameters:
rootElement - the name of the root element

printEndRoot

public void printEndRoot(java.lang.String rootElement)
Closes the root element tag. Usually used with printBeginRoot(String)
Parameters:
rootElement - the name of the root element

addData

public void addData(java.sql.ResultSet rs,
                    java.lang.String dataType)
             throws java.sql.SQLException
Loops through the ResultSet and converts the records to XML data elements
Parameters:
rs - the ResultSet data to be displayed as XML
dataType - the type of data, which is then used as a encapsulating XML element
Throws:
java.sql.SQLException - error thrown when something is wrong with the ResultSet

addElement

public void addElement(java.lang.String elementName,
                       java.lang.String elementValue)
Allows for one element at a time to be added to the XML
Parameters:
elementName - the name of the element to be added
elementValue - the value of the element to be added

addScript

public void addScript(java.lang.String scriptLanguage,
                      java.lang.String scriptOps)
Allows for a script to be added into the XML document (i.e. JavaScript)
Parameters:
scriptLanguage - the scripting language being used
scriptOps - the JavaScript variables and methods to be embedded in the webpage

printBeginForm

public void printBeginForm(java.lang.String formName,
                           java.lang.String formMethod,
                           java.lang.String formAction)
Prints the start tag and parameters of the form section
Parameters:
formName - the name of the HTML form
formMethod - the method of the HTML form, either 'get' or 'post'
formAction - the URL the form will be submitted to

printEndForm

public void printEndForm()
Prints the end tag of the form section

addInput

public void addInput(java.lang.String inputType,
                     java.lang.String inputName,
                     java.lang.String inputValue)
Prints the XML tags that are used to generate a HTML form element
Parameters:
inputType - the input type of the form element
inputName - the name of the form element
inputValue - the value of the form element

addInput

public void addInput(java.lang.String inputType,
                     java.lang.String inputName,
                     int inputValue)
Prints the XML tags that are used to generate a HTML form element
Parameters:
inputType - the input type of the form element
inputName - the name of the form element
inputValue - the value of the form element

addInput

public void addInput(java.lang.String inputType,
                     java.lang.String inputName,
                     java.lang.String inputValue,
                     java.lang.String onClick)
Prints the XML tags that are used to generate a HTML form element (button type)
Parameters:
inputType - the input type of the form element
inputName - the name of the form element
inputValue - the value of the form element
onClick - the action to be performed when the button is clicked

toXML

public java.lang.String toXML()
Converts the StringBuffer object to a string wich the servlet can display
Returns:
a string of XML

setFormat

public void setFormat(boolean format)
Method to set formatting flag used to determine if decimal values should be set to a specific precision
Parameters:
format - formatting on/off indicator

format

public java.lang.String format(java.lang.String input)
Determines if the string is a decimal number and truncates all decimal values to the desired precision length. The modified string is returned.
Parameters:
input - the data value string
Returns:
the modifed data value string