WebNMS CLI 2.0 API Specification

com.adventnet.util.parser.line
Class LineParser

java.lang.Object
  |
  +--com.adventnet.util.parser.line.LineParser

public class LineParser
extends java.lang.Object
implements ParserInterface

This class parses rules based on Token numbers and patterns found in the message to be parsed. It implements the ParserInterface of the Parser Framework. The method parseMessage is called by the ParserAPI whenever a message is to be parsed.It returns the ParsedResult object which can contain either a table or scalar values of Properties (or both) obtained from the message. This class need not be instantiated by the API user. It is internally used by the ParserAPI class.


Constructor Summary
LineParser()
          The default constructor for the LineParser.
 
Method Summary
 void init()
          This method is called by the Parser API for initialization.
 java.lang.Object parseMessage(java.lang.String message, java.lang.String command)
          This method is called by the ParserAPI when a Response is to be parsed.
 void parseRules(java.lang.String[] command, java.lang.String[] ruleList)
          This method is called by the ParserAPI when a Rule needs to be parsed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LineParser

public LineParser()
The default constructor for the LineParser. This class need not be instantiated by the API user. It is internally used by the ParserAPI class
Method Detail

init

public void init()
          throws ParseException
This method is called by the Parser API for initialization.
Specified by:
init in interface ParserInterface
Throws:
ParseException - if any error occurs during initialisation

parseMessage

public java.lang.Object parseMessage(java.lang.String message,
                                     java.lang.String command)
                              throws ParseException
This method is called by the ParserAPI when a Response is to be parsed. The command parameter is used to identify a particular rule with which the response is to be parsed. The Parsed result is returned as any user Object. This default implementation returns the ParsedResult object which contains either Table parameters or Scalar parameters. The method getTable() can be used to get the Table values. This returns a Hashtable with parameter names (columns)as keys and a list of values (column values)in an ArrayList. The method getScalarValues() on the ParsedResult instance returns a Properties object containing the parameter name, value pair.
Specified by:
parseMessage in interface ParserInterface
Parameters:
message - the Response message.
command - the Command which produced the response messsage.
Returns:
the parsed result as a ParsedResult object. This contains the parameters extracted from the message.
Throws:
ParseException - if any error occurs while parsing the response message.

parseRules

public void parseRules(java.lang.String[] command,
                       java.lang.String[] ruleList)
                throws ParseException
This method is called by the ParserAPI when a Rule needs to be parsed. The rule could be a String in XML format or any other string. The list of commands (the command String array) denotes the commands to which this rule belongs.
Specified by:
parseRules in interface ParserInterface
Parameters:
commands - the list of commands for whose response the rule is to be applied.
rule - the Parsing rule which is required to be parsed.
Throws:
ParseException - if any error occurs while parsing the rule

WebNMS CLI 2.0 API Specification