org.opennms.bb.common.filter.xml
Class FilterSchemaParser

java.lang.Object
  |
  +--org.opennms.bb.common.utils.BBParser
        |
        +--org.opennms.bb.common.filter.xml.FilterSchemaParser

public final class FilterSchemaParser
extends BBParser

This class is responsible for parsing the schema data for the filter module. Because this parser is going to be used on multiple rules it is designed as a singleton to insure that any classes in the same VM will use the same instance of this parser. Doing this ensures that the xml file is parse only once and the cost of that parse isn't inccured each time the parser is needed.

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

Inner classes inherited from class org.opennms.bb.common.utils.BBParser
BBParser.BBErrorHandler
 
Field Summary
private static String CNAME
           
private static String COLUMN
           
private  Hashtable columnsHash
          Data structure to hold the information from the dom tree as it is parsed out.
private  Hashtable columnViewRef
          Data structure to hold the list of column names that reference a view.
private static String EXPOSURE
           
private static String HIDDEN
           
private static int INITIAL_CAPACITY
          initial capacity of the various hashtables used is set to 10 just so space is not wasted
private static FilterSchemaParser instance
          Singleton instance variable
private static String JOINFROMCOL
           
private static String JOINREF
           
private static String JOINTBL
           
private static String JOINTOCOL
           
private static String KEY
           
private static String PRIMARY
           
private static String TABLE
          XML TAGS that are relevant
private  Hashtable tables
          Variable to hold all of the non-hidden tables in the PollerDatabaseSchema.xml keyed by table name.
private static String TNAME
           
private static String VCOLUMN
           
private static String VIEW
           
private static String VIEWNAME
           
private static String VIEWREF
           
private  Hashtable views
          Variable to hold all of the views in the PollerDatabaseSchema.xml keyed by view name.
private  Hashtable virtualColumns
          Data structure to hold the list of virtual columns
private static String VLINK
           
private static String VNAME
           
private static String VTABLE
           
 
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
private FilterSchemaParser()
          Parses from the filename passed in
 
Method Summary
 Hashtable getColumns()
          This method returns the list of all columns.
 Hashtable getColumnViewRef()
          This method returns the list of all view columns
static FilterSchemaParser getInstance()
          This method is used to get the instance of the parser when another class needs to use it.
 Hashtable getTables()
          This method returns the list of all tables.
 Hashtable getViews()
          This method returns the list of all views
 Hashtable getVirtualColumns()
          This method returns the list of all virtual columns.
protected  String processColumn(org.w3c.dom.Node columnNode)
          This method is used to process a column node.
protected  boolean processElement(org.w3c.dom.Element el, boolean isRoot)
          This method gets called from BBParser parent class to start walking down the dom tree.
protected  JoinCondition processJoin(org.w3c.dom.Node joinNode, FilterTable table)
          This method is used to process a tag.
protected  boolean processTableNode(org.w3c.dom.Node tableNode)
          This method will process a node associated with a tag.
protected  boolean processViewNode(org.w3c.dom.Node viewNode)
          This method will process a node associated with a tag.
protected  VirtualColumn processVirtualColumn(org.w3c.dom.Node virtualNode)
          This method is used to process a tag, indicating that the column applies to this table but doesn't actually exist in the database as a real column.
 
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

TABLE

private static final String TABLE
XML TAGS that are relevant

TNAME

private static final String TNAME

COLUMN

private static final String COLUMN

VCOLUMN

private static final String VCOLUMN

CNAME

private static final String CNAME

VNAME

private static final String VNAME

VLINK

private static final String VLINK

VTABLE

private static final String VTABLE

EXPOSURE

private static final String EXPOSURE

HIDDEN

private static final String HIDDEN

KEY

private static final String KEY

PRIMARY

private static final String PRIMARY

JOINREF

private static final String JOINREF

JOINTBL

private static final String JOINTBL

JOINTOCOL

private static final String JOINTOCOL

JOINFROMCOL

private static final String JOINFROMCOL

VIEW

private static final String VIEW

VIEWNAME

private static final String VIEWNAME

VIEWREF

private static final String VIEWREF

INITIAL_CAPACITY

private static final int INITIAL_CAPACITY
initial capacity of the various hashtables used is set to 10 just so space is not wasted

instance

private static FilterSchemaParser instance
Singleton instance variable

tables

private Hashtable tables
Variable to hold all of the non-hidden tables in the PollerDatabaseSchema.xml keyed by table name.

views

private Hashtable views
Variable to hold all of the views in the PollerDatabaseSchema.xml keyed by view name.

columnsHash

private Hashtable columnsHash
Data structure to hold the information from the dom tree as it is parsed out. As each column name is discovered it is placed in this hash along with the table name its in.

virtualColumns

private Hashtable virtualColumns
Data structure to hold the list of virtual columns

columnViewRef

private Hashtable columnViewRef
Data structure to hold the list of column names that reference a view. Used to support the IPLIKE operator.
Constructor Detail

FilterSchemaParser

private FilterSchemaParser()
                    throws IOException
Parses from the filename passed in
Throws:
IOException, - thrown from the parent BBParser if the file fails to open or match DTD
Method Detail

getInstance

public static FilterSchemaParser getInstance()
This method is used to get the instance of the parser when another class needs to use it. If the parser has never been called it will be initialized, otherwise it has already been initialized so just return the all ready created instance.
Returns:
FilterSchemaParser, static instance of the FilterSchemaParser class

processElement

protected boolean processElement(org.w3c.dom.Element el,
                                 boolean isRoot)
This method gets called from BBParser parent class to start walking down the dom tree. It looks for the tag and will walk down the tag when it finds one.
Overrides:
processElement in class BBParser
Parameters:
Element - el, current element to process
boolean - isRoot, indicating if this element is the root
Returns:
boolean, indicates if the process is successful

processViewNode

protected boolean processViewNode(org.w3c.dom.Node viewNode)
This method will process a node associated with a tag. It will examine its children and look for the , and tags and walk down those children nodes.
Returns:
boolean, indicates if the process is successful

processTableNode

protected boolean processTableNode(org.w3c.dom.Node tableNode)
This method will process a node associated with a
tag. It will examine its children and look for the , and tags and walk down those children nodes.
Parameters:
Node - tableNode, a node containing table information
Returns:
boolean, indicates if the process is successful

processVirtualColumn

protected VirtualColumn processVirtualColumn(org.w3c.dom.Node virtualNode)
This method is used to process a tag, indicating that the column applies to this table but doesn't actually exist in the database as a real column. A VirtualColumn object is constructed by extracting the , , and sub tags.
Parameters:
Node - virtualNode, a node containing virtual column information
Returns:
VirtualColumn, the object parsed from the virtual column node

processJoin

protected JoinCondition processJoin(org.w3c.dom.Node joinNode,
                                    FilterTable table)
This method is used to process a tag. A JoinCondition object is constructed by extracting the information from the , , and sub tags.
Parameters:
Node - joinNode, node containing join information
FilterTable, - table object that the join information belongs to
Returns:
JoinCondition, object built from the join node

processColumn

protected String processColumn(org.w3c.dom.Node columnNode)
This method is used to process a column node. It is called when a tag is discovered and will extract the data from the tag. Currently it will walk through all tags of a column even though the tag is the only tag that information is exctracted from.
Parameters:
Node - columnNode, node containing column information
Returns:
String, the column name parsed from the node

getColumns

public Hashtable getColumns()
This method returns the list of all columns.

getVirtualColumns

public Hashtable getVirtualColumns()
This method returns the list of all virtual columns.

getColumnViewRef

public Hashtable getColumnViewRef()
This method returns the list of all view columns

getTables

public Hashtable getTables()
This method returns the list of all tables.

getViews

public Hashtable getViews()
This method returns the list of all views