util
Class XMLUtilsBean

java.lang.Object
  |
  +--util.XMLUtilsBean

public class XMLUtilsBean
extends java.lang.Object

A JavaBean which uses SAX2 for extracting data from an XML file. The SAX2 callbacks are defined within local classes inside of the bean's getter methods. The general structure is as follows:

 public class XMLUtilsBean
 {
   ...private fields...
   ...public constructor...
   public String[] getXXX()
   {
     ...local vars...
     class Handler extends DefaultHandler
     {
       ...SAX 2.0 callbacks...
     }
     ...parsing operations...
     ...Handler, ErrHandler referenced here... 
   }
   class ErrHandler extends DefaultHandler
   {
     ...
   }
 }
 


Constructor Summary
XMLUtilsBean()
          Requisite no-argument constructor.
 
Method Summary
 java.lang.String getAttName()
          Retrieves the name of the desired XML tag attribute name.
 java.lang.String[] getAttValsByElement()
          Returns all attribute values for a given element name and having a given attribute name.
 java.lang.String getAttValue()
          Retrieves the name of the desired XML tag attribute value.
 java.lang.String[] getData()
          Returns the (#PCDATA) from all XML elements with the given element tag name.
 java.lang.String[] getDataByAttValPair()
          Returns the (#PCDATA) from all XML elements having a given attribute name-value pair.
 java.lang.String getElementName()
          Retrieves the name of the desired XML tag.
 java.lang.String getXMLFileName()
          Retrieves the name of the XML file being processed.
 void setAttName(java.lang.String name)
          Sets the name of the desired XML tag attribute name.
 void setAttValue(java.lang.String name)
          Sets the name of the desired XML tag attribute value.
 void setElementName(java.lang.String name)
          Sets the name of the desired XML tag.
 void setXMLFileName(java.lang.String name)
          Sets the name of the XML file to be processed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLUtilsBean

public XMLUtilsBean()
Requisite no-argument constructor. Performs basic default initialization of instance variables.
Method Detail

getXMLFileName

public java.lang.String getXMLFileName()
Retrieves the name of the XML file being processed.
Returns:
A String containing the name of the XML file being parsed.
See Also:
setXMLFileName(java.lang.String)

setXMLFileName

public void setXMLFileName(java.lang.String name)
Sets the name of the XML file to be processed. This method is invoked directly or via a <jsp:setProperty> bean tag in a JSP page.
Parameters:
name - A String containing the name of the XML file.

getElementName

public java.lang.String getElementName()
Retrieves the name of the desired XML tag.
Returns:
A String containing the name of the XML tag.
See Also:
setElementName(java.lang.String)

setElementName

public void setElementName(java.lang.String name)
Sets the name of the desired XML tag. This method is invoked directly or via a <jsp:setProperty> bean tag in a JSP page.
Parameters:
name - A String containing the name of the XML element name

getAttName

public java.lang.String getAttName()
Retrieves the name of the desired XML tag attribute name.
Returns:
A String containing the name of the XML tag attribute.
See Also:
setAttName(java.lang.String)

setAttName

public void setAttName(java.lang.String name)
Sets the name of the desired XML tag attribute name. This method is invoked directly or via a <jsp:setProperty> bean tag in a JSP page.
Parameters:
name - A String containing the name of the XML tag attribute name.

getAttValue

public java.lang.String getAttValue()
Retrieves the name of the desired XML tag attribute value.
Returns:
A String containing the name of the XML tag attribute value.
See Also:
setAttValue(java.lang.String)

setAttValue

public void setAttValue(java.lang.String name)
Sets the name of the desired XML tag attribute value. This method is invoked directly or via a <jsp:setProperty> bean tag in a JSP page.
Parameters:
name - A String containing the name of the XML tag attribute value.

getData

public java.lang.String[] getData()
                           throws org.xml.sax.SAXException
Returns the (#PCDATA) from all XML elements with the given element tag name. Since this method references the element name, that value is typically set prior to its usage via setElementName(java.lang.String) or using a <jsp:setProperty> bean tag in a JSP page.
Returns:
A String array containing the data
Throws:
org.xml.sax.SAXException - Any SAX exception, possibly wrapping another exception
See Also:
setElementName(java.lang.String)

getAttValsByElement

public java.lang.String[] getAttValsByElement()
                                       throws org.xml.sax.SAXException
Returns all attribute values for a given element name and having a given attribute name. Since this method references both an element name and an attribute name, those values are typically set prior to its usage via setElementName(java.lang.String) and setAttName(java.lang.String) or using a <jsp:setProperty> bean tag in a JSP page.
Returns:
A String array containing the data
Throws:
org.xml.sax.SAXException - Any SAX exception, possibly wrapping another exception
See Also:
setElementName(java.lang.String), setAttName(java.lang.String)

getDataByAttValPair

public java.lang.String[] getDataByAttValPair()
                                       throws org.xml.sax.SAXException
Returns the (#PCDATA) from all XML elements having a given attribute name-value pair. Since this method references both an attribute name and value, those values are typically set prior to its usage via setAttName(java.lang.String) and setAttValue(java.lang.String) or using a <jsp:setProperty> bean tag in a JSP page.
Returns:
A String array containing the data
Throws:
org.xml.sax.SAXException - Any SAX exception, possibly wrapping another exception
See Also:
setAttName(java.lang.String), setAttValue(java.lang.String)