OpenNMS API 1.2.3

org.opennms.netmgt.filter
Class Filter

java.lang.Object
  extended byorg.opennms.netmgt.filter.Filter

public class Filter
extends java.lang.Object

This class is the main entry point for filtering the rules expressions. By creating a Filter object the application can parse a rules expression and get back the list of applicable ip addresses or verify if an ip address adhers to a certain rule.

Author:
Jason Johns , OpenNMS

Field Summary
private  Start m_parseTree
          This is the parse tree produced by the parser
 
Constructor Summary
Filter()
          The default constructor.
Filter(java.lang.String rule)
          Constructs a new filter with the pre-defined rule as the comparision method.
 
Method Summary
 java.lang.String getInterfaceWithServiceStatement()
           
 java.util.List getIPList(java.lang.String rule)
          This method returns a list of all ip addresses that match the rule that is passed in.
 java.util.Map getIPServiceMap(java.lang.String rule)
           
 java.lang.String getIPServiceMappingStatement()
           
 java.lang.String getSQLStatement()
          This method parses a rule and returns the SQL select statement equivalent of the rule.
 java.lang.String getSQLStatement(long nodeId, java.lang.String ipaddr, java.lang.String service)
           
 boolean isValid(java.lang.String addr, java.lang.String rule)
          This method verifies if an ip address adhers to a given rule.
 void parseRule(java.lang.String rule)
          This method is used to parse and valiate a rule into its graph tree.
 void validateRule(java.lang.String rule)
          This method is used to validate that a rule is syntactically correct.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_parseTree

private Start m_parseTree
This is the parse tree produced by the parser

Constructor Detail

Filter

public Filter()
The default constructor. Initializes the filter rule to accept new input.


Filter

public Filter(java.lang.String rule)
       throws FilterParseException
Constructs a new filter with the pre-defined rule as the comparision method.

Parameters:
rule - The filter rule.
Throws:
FilterParseException, - if a rule is syntactically incorrect or failed in executing the SQL statement.
FilterParseException
Method Detail

parseRule

public void parseRule(java.lang.String rule)
               throws FilterParseException
This method is used to parse and valiate a rule into its graph tree. If the parser cannot validate the rule then an exception is generated.

Parameters:
rule - The rule to parse.
Throws:
FilterParseException - Thrown if the rule cannot be parsed.

isValid

public boolean isValid(java.lang.String addr,
                       java.lang.String rule)
                throws FilterParseException
This method verifies if an ip address adhers to a given rule.

Parameters:
addr - an octet string ip to be validated against a rule.
rule - an expression rule to be parsed and executed.
Returns:
indicating that the ip is included in the rule
Throws:
FilterParseException - if a rule is syntactically incorrect or failed in executing the SQL statement.

getIPServiceMap

public java.util.Map getIPServiceMap(java.lang.String rule)

getIPList

public java.util.List getIPList(java.lang.String rule)
                         throws FilterParseException
This method returns a list of all ip addresses that match the rule that is passed in.

Parameters:
rule - an expression rule to be parsed and executed.
Returns:
interface containing all ip addresses selected by the rule.
Throws:
FilterParseException - if a rule is syntactically incorrect or failed in executing the SQL statement

getSQLStatement

public java.lang.String getSQLStatement()
This method parses a rule and returns the SQL select statement equivalent of the rule.

Returns:
the sql select statement

getSQLStatement

public java.lang.String getSQLStatement(long nodeId,
                                        java.lang.String ipaddr,
                                        java.lang.String service)

getIPServiceMappingStatement

public java.lang.String getIPServiceMappingStatement()

getInterfaceWithServiceStatement

public java.lang.String getInterfaceWithServiceStatement()

validateRule

public void validateRule(java.lang.String rule)
                  throws FilterParseException
This method is used to validate that a rule is syntactically correct. The method will throw an exception on an invalid parse and will not do anything in the case of a good parse. The FilterParseException holds the error message of the failure.

Parameters:
rule - The expression rule to validate
Throws:
FilterParseException

OpenNMS API 1.2.3

Generated by eevans on May 29 2005 2015.