com.adventnet.util.parser.generic
Class GenericParser
java.lang.Object
|
+--com.adventnet.util.parser.generic.GenericParser
- public class GenericParser
- 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 a Vector of parameters that are
obtained from the message
|
Constructor Summary |
GenericParser()
The default constructor for this class. |
|
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[] commandList,
java.lang.String[] ruleList)
This method is called by the ParserAPI when Parsing Rules need to be
parsed. |
| Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
GenericParser
public GenericParser()
- The default constructor for this class. The API user need not instantiate
this class. It is internally used by the ParserAPI.
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. Gets the Parameters extracted from the Response as a
Vector of Hashtables.
Each Hashtable contains the Parameter Name as Key and
the Parameter Value as the Value. The Parameter Name is the name defined
in the XML file used to parse the response. Each Hashtable corresponds
to one group of parameters in the Response.
- 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 Vector 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[] commandList,
java.lang.String[] ruleList)
throws ParseException
- This method is called by the ParserAPI when Parsing Rules need to be
parsed.
Each command in the commandList array has the corresponding rule in the
ruleList array, i.e. the first String in the ruleList array is the rule
for parsing the response for the command in the first element of the
commandList array.
- Specified by:
- parseRules in interface ParserInterface
- Parameters:
commandList - the list of commands whose response is to be
parsed based on the rules in the ruleList array .ruleList - each rule in this list corresponds to a command in the
command list.- Throws:
- ParseException - if any error occurs while parsing any of the
rules