org.opennms.bb.dp.poller.parsers
Class PackageParser

java.lang.Object
  |
  +--org.opennms.bb.common.utils.BBParser
        |
        +--org.opennms.bb.dp.poller.parsers.PackageParser

public final class PackageParser
extends BBParser

This class is used to parse the packages.xml and load the information into classes to be used programatically.

Version:
$Revision: 1.2 $
Author:
Jason Johns, OpenNMS

Inner classes inherited from class org.opennms.bb.common.utils.BBParser
BBParser.BBErrorHandler
 
Field Summary
private  String DEFAULT
           
private  String ERANGE
           
private  String FILTER
           
private  String FILTER_COMMENT
           
private  String FILTER_EXPR
           
private  String IRANGE
           
private  List m_modelNames
          The list of model names that are associated with the packages
private  List m_packageList
          The list of packages to parse from the xml file.
private  List m_packages
          The list of Package objects that are created by parsing from the list of packages.
private  PollerPackage m_pollerPackage
          As each package is parsed this object will be built and then placed into the m_packages list when complete
private  boolean m_readPackage
          Indicates if a certain package should be read or ignored
private  String MODEL
           
private  String PACKAGENAME
           
private  String PARM
           
private  String PARM_NAME
           
private  String PARM_TYPE
           
private  String PARM_VALUE
           
private  String PARMS
           
private  String RANGES
           
private  String SERVICE
           
private  String SERVICE_NAME
           
private  String SPECIFIC
           
private  String URL
           
 
Fields inherited from class org.opennms.bb.common.utils.BBParser
ATTRIB_VALUE_PAIR_ERR, ATTRIB_VALUE_PAIR_ERR_STR, EXCEPTION, m_curElement, m_errNum, m_exceptionMsg, m_inpSource, m_parser, NULL_VALUE_ERR, NULL_VALUE_ERR_STR
 
Constructor Summary
PackageParser(List aPackageList)
          Creates the new parser that can be used to disassemble an XML file corresponding to the m_packages.dtd as defined by the OpenNMS specifications.
 
Method Summary
 List getModelNames()
          
 List getPackages()
          This method returns the list of Packages that was created by parsing.
protected  boolean getParameterName(org.w3c.dom.Node parmNameNode, Parameter parm)
          This method process the parameter <name> element of the parameter block in the DTD.
protected  boolean getParameterValue(org.w3c.dom.Node parmValNode, Parameter parm)
          Process the <value> element of the parm block and returns the information in the passed parm element.
private  boolean processDefRangeElement(org.w3c.dom.Element defaultElement, PollerPackage m_pollerPackage)
          This method is used to process the default range tags
protected  boolean processElement(org.w3c.dom.Element el, boolean isRoot)
          This method override the method in the base class that is the default target for processing elements in the DOM tree.
private  boolean processERangeElement(org.w3c.dom.Element erangeElement, PollerPackage m_pollerPackage)
          This method is used to process the tags
private  boolean processFilterTag(org.w3c.dom.Node filterNode, PollerPackage m_pollerPackage)
          This method is used to process the filter tag section of the document.
private  boolean processIRangeElement(org.w3c.dom.Element irangeElement, PollerPackage m_pollerPackage)
          This method is used to process the tags
protected  Parameter processParameter(org.w3c.dom.Node parmsNode)
          This method is used to process the DTDs parameter block.
private  void processRange(org.w3c.dom.Node rangeNode, PollerRange aRange)
          This method parses the parameter tags () from within the , , , and tags
private  boolean processServiceElement(org.w3c.dom.Element serviceElement, PollerPackage m_pollerPackage)
          This method is used to process the tags
private  void processServiceParameters(org.w3c.dom.Node paramNode, ServiceInfo aService)
          This method parses the parameter tags () from within the tags
private  boolean processSpecificElement(org.w3c.dom.Element specificElement, PollerPackage m_pollerPackage)
          This method is used to process the tags
private  boolean processUrlElement(org.w3c.dom.Element urlElement, PollerPackage m_pollerPackage)
          This method is used to process the tags
 
Methods inherited from class org.opennms.bb.common.utils.BBParser
getErrorMessage, getErrorNumber, parse, parse, parse, parse, processDocument, processNode, processParmValue
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

m_packageList

private List m_packageList
The list of packages to parse from the xml file. If a package name is not in this list it will not be parsed.

m_packages

private List m_packages
The list of Package objects that are created by parsing from the list of packages.

m_modelNames

private List m_modelNames
The list of model names that are associated with the packages

m_readPackage

private boolean m_readPackage
Indicates if a certain package should be read or ignored

m_pollerPackage

private PollerPackage m_pollerPackage
As each package is parsed this object will be built and then placed into the m_packages list when complete

FILTER

private final String FILTER

FILTER_COMMENT

private final String FILTER_COMMENT

MODEL

private final String MODEL

FILTER_EXPR

private final String FILTER_EXPR

SERVICE

private final String SERVICE

SERVICE_NAME

private final String SERVICE_NAME

PARMS

private final String PARMS

PARM

private final String PARM

PARM_NAME

private final String PARM_NAME

PARM_VALUE

private final String PARM_VALUE

PARM_TYPE

private final String PARM_TYPE

PACKAGENAME

private final String PACKAGENAME

DEFAULT

private final String DEFAULT

RANGES

private final String RANGES

IRANGE

private final String IRANGE

ERANGE

private final String ERANGE

SPECIFIC

private final String SPECIFIC

URL

private final String URL
Constructor Detail

PackageParser

public PackageParser(List aPackageList)

Creates the new parser that can be used to disassemble an XML file corresponding to the m_packages.dtd as defined by the OpenNMS specifications. A new instance of a DOM parser is created to parse the passed file. The list of package that should be read by the parser are passed to the object on construction.

Parameters:
List - aPackageList, The list of m_packages to be read.
Method Detail

processElement

protected boolean processElement(org.w3c.dom.Element el,
                                 boolean isRoot)

This method override the method in the base class that is the default target for processing elements in the DOM tree. The method is invoked by the DOM parser to handle each element. This extends the DiscIcebergParser by parsing out all information from the xml file. Additions will be commented.

Overrides:
processElement in class BBParser
Parameters:
el - The DOM element to be processed.
isRoot - True if the element is a root element.
Returns:
True if the element was successfully handled.

processFilterTag

private boolean processFilterTag(org.w3c.dom.Node filterNode,
                                 PollerPackage m_pollerPackage)

This method is used to process the filter tag section of the document. If there is a return between the tag and the CDATA section the data will not be retrieved. This seems to be an issue with either Xerces or the XML spec. Make sure that the tag and the data for the filter expression are on the same line.

Parameters:
List - aPackageList, the DOM node to handle.
PollerPackage - m_pollerPackage, the package object we are building
Returns:
Returns true if successful, false otherwise.

processServiceElement

private boolean processServiceElement(org.w3c.dom.Element serviceElement,
                                      PollerPackage m_pollerPackage)

This method is used to process the tags

Parameters:
Element - serviceElement, the DOM element to handle.
PollerPackage - m_pollerPackage, the package object we are building
Returns:
Returns true if successful, false otherwise.

processServiceParameters

private void processServiceParameters(org.w3c.dom.Node paramNode,
                                      ServiceInfo aService)

This method parses the parameter tags () from within the tags

Parameters:
Node - paramNode, the DOM node to handle.
ServiceInfo - aService, the object to place the Parameter into

processDefRangeElement

private boolean processDefRangeElement(org.w3c.dom.Element defaultElement,
                                       PollerPackage m_pollerPackage)

This method is used to process the default range tags

Parameters:
Element - defaultElement, the DOM element to handle.
PollerPackage - m_pollerPackage, the package object we are building
Returns:
Returns true if successful, false otherwise.

processIRangeElement

private boolean processIRangeElement(org.w3c.dom.Element irangeElement,
                                     PollerPackage m_pollerPackage)

This method is used to process the tags

Parameters:
Element - irangeElement, the DOM element to handle.
PollerPackage - m_pollerPackage, the package object we are building
Returns:
Returns true if successful, false otherwise.

processERangeElement

private boolean processERangeElement(org.w3c.dom.Element erangeElement,
                                     PollerPackage m_pollerPackage)

This method is used to process the tags

Parameters:
Element - erangeElement, the DOM element to handle.
PollerPackage - m_pollerPackage, the package object we are building
Returns:
Returns true if successful, false otherwise.

processSpecificElement

private boolean processSpecificElement(org.w3c.dom.Element specificElement,
                                       PollerPackage m_pollerPackage)

This method is used to process the tags

Parameters:
Element - specificElement, the DOM element to handle.
PollerPackage - m_pollerPackage, the package object we are building
Returns:
Returns true if successful, false otherwise.

processUrlElement

private boolean processUrlElement(org.w3c.dom.Element urlElement,
                                  PollerPackage m_pollerPackage)

This method is used to process the tags

Parameters:
Element - urlElement, the DOM element to handle.
PollerPackage - m_pollerPackage, the package object we are building
Returns:
Returns true if successful, false otherwise.

processRange

private void processRange(org.w3c.dom.Node rangeNode,
                          PollerRange aRange)

This method parses the parameter tags () from within the , , , and tags

Parameters:
Node - rangeNode, the DOM node to handle.
PollerRange - aRange, the object to place the Parameter into

processParameter

protected Parameter processParameter(org.w3c.dom.Node parmsNode)

This method is used to process the DTDs parameter block. The parameter block consist of a name, value, and the values type as an attribute. The elements are parsed out and stored in the returned Parameter object.

Parameters:
parmsNode - The node containing the parameter information
Returns:
The Parameter object containing the parsed data on success. If an error occurs then a null is returned.

getParameterName

protected boolean getParameterName(org.w3c.dom.Node parmNameNode,
                                   Parameter parm)

This method process the parameter <name> element of the parameter block in the DTD. The value for the element is returned to the caller upon success.

Parameters:
parmNameNode - The DOM Node containing the parm name.
parm - The parameter element to store the name.
Returns:
True if the call succeeds, false if an error occurs.

getParameterValue

protected boolean getParameterValue(org.w3c.dom.Node parmValNode,
                                    Parameter parm)

Process the <value> element of the parm block and returns the information in the passed parm element. If the data is successfully extracted then a value of true is returned. If an error occurs then a false value is returned.

Parameters:
parmValNode - The node element from the DOM parser.
parm - The [in/out] element modified by the call.
Returns:
True if the call succeeds, false if an error occurs.

getPackages

public List getPackages()

This method returns the list of Packages that was created by parsing.

Returns:
List, the list of Packages

getModelNames

public List getModelNames()