|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--com.adventnet.tl1.parser.TL1InputMessageParser
This TL1InputMessageParser class is used to generate a
com.adventnet.tl1.message.TL1InputMessage object from a
raw TL1 input message string. In other words, this parser is a
TL1InputMessage factory. It employs powerful
regular-expression based pattern recognition algorithms to scan and extract
relevant information as well as performs exhaustive grammar (rule) checks
on the raw message string.
Background Information : Typically, TL1 based management applications need to interface with TL1 devices / infrastructure belonging to diverse technologies, domains, and vendors. These devices, although conforming to the Bellcore (Telcordia) standards at a high level often do have many variations and flavors when it comes to specific TL1 messages. Apart from this, each standard TL1 message has its own information structure and size, and there is no standard way of capturing TL1 message formats for management applications to automate message processing. Flexible and smart parsing of TL1 messages is crucial for building robust, interoperable TL1 management applications.
On the other hand, TL1 agents / north-bound interfaces need to construct standard, Bellcore specification compliant TL1 messages. Rigorous grammar checking of TL1 messages is crucial for building standard compliant, interoperable TL1 agents / interfaces.
Key Benefits :
TL1InputMessage objects. Warning : This parser class is meant for single threaded usage. In other words, methods of this class are not synchronized or multi-threaded. Therefore each thread must create and use a new instance of this parser. However, this constraint is not a problem as this parser is light-weight.
Options Supported :
setParserMode(boolean)) TL1ParserException) in this mode, it means that it is not
a valid input message. To initialize the parser to Flexible Parser mode,
use the setParserMode(false) method.
By default, the parser is set to Flexible Parser mode.
TL1ParserException). To initialize the
parser to Rigid Parser mode, use the setParserMode(true)
method.
setChainedComment(boolean))setChainedComment(true) method.
By default, the parser is set to Chained Comment mode.
setChainedComment(false) method.
TL1InputMessageParser object, use the default constructor
TL1InputMessageParser. The parser is initialized to the
various default options. To change the default setting use the
appropriate setter methods mentioned above.
isInputMessage(java.lang.String) method.
If a message string is valid this method returns true, otherwise returns
false. If a message string is valid it means that a valid
TL1InputMessage object can be generated, atleast in the
Flexible Parser mode.
TL1InputMessage object, use the
createTL1Message(String) method. If the management system needs
to dynamically vary the parser mode, to Flexible or Rigid, while
generating TL1InputMessage objects, use the
createTL1Message(String, boolean) method.
rule(String, int) method, with the appropriate
Rule Constant for that building-block. To know more about these
individual building-blocks refer to the GR-831-CORE specification.
Most of the Rule Constants are applicable (active) for both Flexible and
Rigid parser modes. But some of them are applicable for only one parser
mode, depending on which mode they are used by the parser for pattern
recognition. The following table maps each of the Rule Constants to
their pattern structures and their applicable parser modes.
All the Rule Constants are of public static final int type.
| Rule Constant | Pattern Structure | Parser Mode |
| RULE_InputMessage | Input Message |
- Flexible - Rigid |
| RULE_CommandCode | Command Code |
- Flexible - Rigid |
| RULE_TargetId | Target Identifier |
- Flexible - Rigid |
| RULE_AccessId | Access Identifier |
- Flexible - Rigid |
| RULE_CorrelationTag | Correlation Tag |
- Flexible - Rigid |
| RULE_GeneralBlock | General Block |
- Flexible - Rigid |
| RULE_GBDate | General Block Date | - Rigid |
| RULE_GBTime | General Block Time | - Rigid |
| RULE_CommandParameterBlock | Command Parameter Block |
- Flexible - Rigid |
| RULE_CommandParameter | Command Parameter |
- Flexible - Rigid |
| RULE_CommandParamName | Command Parameter Name |
- Flexible - Rigid |
| RULE_CommandParamValue | Command Parameter Value |
- Flexible - Rigid |
| RULE_CommandSequenceChain | Command Sequence Chain | - Rigid |
| RULE_CommandSimpleSequence | Command Simple Sequence | - Rigid |
| RULE_CommandComplexChain | Command Complex Chain | - Rigid |
| RULE_CommandComplexSequence | Command Complex Sequence | - Rigid |
| RULE_CommandComplexArg | Command Complex Argument | - Rigid |
| RULE_CommandLinkedSequence | Command Linked Sequence | - Rigid |
| RULE_CommandInfoUnit | Command Information Unit | - Rigid |
Example code snippet :
This is a code snippet for creating a TL1InputMessage
object by parsing a raw message string.
String message = "RTRV-OC12:FMX117S:OC12-ALL:9:,,,::STINFO=YES;";
TL1InputMessage imsg = null;
TL1InputMessageParser ipsr = new TL1InputMessageParser();
ipsr.setParserMode(true); // RIGID Parser mode
try {
imsg = ipsr.createTL1Message(message);
// Instead you can also use the method shown below
// In this case, you need not code ipsr.setParserMode(true)
// imsg = ipsr.createTL1Message(message, true);
} catch(TL1ParserException tpex) {
tpex.printStackTrace();
... // Error recovery code
}
Authors:
TL1InputMessage,
TL1MessageParser| Constructor Summary | |
TL1InputMessageParser()
Creates a new TL1InputMessageParser object. |
|
| Method Summary | |
com.adventnet.tl1.message.TL1InputMessage |
createTL1Message(java.lang.String message)
Generates a TL1InputMessage object from a raw input
message string. |
com.adventnet.tl1.message.TL1InputMessage |
createTL1Message(java.lang.String message,
boolean isrigid)
Generates a TL1InputMessage object from a raw input
message string. |
com.adventnet.tl1.message.TL1ParamBlock |
getAccessId(java.lang.String message)
Gets the Access Identifier from the raw input message string. |
java.lang.String |
getCommandCode(java.lang.String message)
Gets the Command Code from the raw input message string. |
java.lang.String |
getCorrelationTag(java.lang.String message)
Gets the Correlation Tag from the raw input message string. |
com.adventnet.tl1.message.TL1ParamBlock |
getGeneralBlock(java.lang.String message)
Gets the General Block from the raw input message string. |
com.adventnet.tl1.message.TL1ParamGroup |
getMessagePayloadBlock(java.lang.String message)
Gets the Message Payload Block from the raw input message string. |
java.lang.String |
getTargetId(java.lang.String message)
Gets the Target Identifier from the raw input message string. |
boolean |
isChainedComment()
Gets the comment recognition mode. |
boolean |
isInputMessage(java.lang.String message)
Checks whether the raw message string is a valid (recognizable) TL1 input message or not. |
boolean |
isRigidParser()
Gets the parser mode. |
void |
rule(java.lang.String parsable,
int rule)
Checks the grammar (rule) of any of the individual building-blocks (micro pattern structures) of the TL1 input message. |
void |
setChainedComment(boolean ischain)
Sets the comment recognition mode to Chained or Standard. |
void |
setParserMode(boolean isrigid)
Sets the parser mode to Flexible or Rigid Parser. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public TL1InputMessageParser()
TL1InputMessageParser object.
The new parser object is initialized to the default options. That is,
the parser mode is set to Flexible Parser and the comment recognition
mode is set to Chained Comment. To switch the parser mode to Rigid
Parser, call the setParserMode method explicitly.
To switch the comment recognition mode to Standard Comment, call the
setChainedComment method explicitly.
| Method Detail |
public void setParserMode(boolean isrigid)
createTL1Message(String) and rule(String, int)
methods parse according to the parser mode set.
Flexible Mode : The focus is on flexible and smart pattern
recognition. Input messages that deviate from the GR-831-CORE
specification should be parsed using this mode. If a particular
message string is rejected by the parser (throws
TL1ParserException) in this mode, it means that it is not a
valid input message. By default, the parser mode is
set to Flexible Parser.
Rigid Mode : The focus is on rigorous Grammar (rule) Checks.
Only input messages that are fully compliant with the GR-831-CORE
specification are parsed. All other messages with any deviation are
rejected (throws TL1ParserException). To switch the parser
mode to Rigid Parser, call this method explicitly.
isrigid - the parser mode.isRigidParser()public boolean isRigidParser()
setParserMode(boolean)public void setChainedComment(boolean ischain)
createTL1Message(String) and rule(String, int)
methods recognise comments according to the comment recognition
mode set.
Chained Comment : Special pattern recognition logic for enabling chained comments is triggered. Systems that need to process input messages with multiple chained comments (comments inside comments) should use this mode. By default, the comment recognition mode is set to Chained.
Standard Comment : Comments are parsed for the GR-831-CORE
specification compliance. Here chained comments are rejected
(throws TL1ParserException) and only standard comments are
allowed. To switch the comment recognition mode to Standard Comment,
call this method explicitly.
ischain - the comment recognition mode.isChainedComment()public boolean isChainedComment()
setChainedComment(boolean)public boolean isInputMessage(java.lang.String message)
TL1InputMessage object can be generated,
atleast in the Flexible Parser mode.
message - the raw message string.
public java.lang.String getCommandCode(java.lang.String message)
throws TL1ParserException
TL1ParserException) messages that are not valid (recognizable)
input messages.
message - the raw message string.
null for a null message string and
if message.trim() is an empty string.
TL1ParserException - if the message string is not a valid input message.
public java.lang.String getTargetId(java.lang.String message)
throws TL1ParserException
TL1ParserException) messages that are not valid (recognizable)
input messages.
message - the raw message string.
null for a null message string and
if message.trim() is an empty string.
TL1ParserException - if the message string is not a valid input message.
public com.adventnet.tl1.message.TL1ParamBlock getAccessId(java.lang.String message)
throws TL1ParserException
TL1ParserException) messages that are not valid (recognizable)
input messages.
message - the raw message string.
TL1ParamBlock for a valid input message string;
null for a null message string and
if message.trim() is an empty string.
TL1ParserException - if the message string is not a valid input message.
public java.lang.String getCorrelationTag(java.lang.String message)
throws TL1ParserException
TL1ParserException) messages that are not valid (recognizable)
input messages.
message - the raw message string.
null for a null message string and
if message.trim() is an empty string.
TL1ParserException - if the message string is not a valid input message.
public com.adventnet.tl1.message.TL1ParamBlock getGeneralBlock(java.lang.String message)
throws TL1ParserException
TL1ParserException) messages that are not valid (recognizable)
input messages.
message - the raw message string.
TL1ParamBlock for a valid input message string;
null for a null message string and
if message.trim() is an empty string.
TL1ParserException - if the message string is not a valid input message.
public com.adventnet.tl1.message.TL1ParamGroup getMessagePayloadBlock(java.lang.String message)
throws TL1ParserException
TL1ParserException) messages that are not valid (recognizable)
input messages.
message - the raw message string.
TL1ParamGroup for a valid input message string;
null for a null message string and
if message.trim() is an empty string.
TL1ParserException - if the message string is not a valid input message.
public com.adventnet.tl1.message.TL1InputMessage createTL1Message(java.lang.String message)
throws TL1ParserException
TL1InputMessage object from a raw input
message string.
This factory method parses according to the parser mode and the comment
recognition mode set.
Rejects (throws TL1ParserException)
messages that are not valid (recognizable) input messages.
message - the raw message string.
TL1InputMessage object for a valid input message
string; null for a null message
string and if message.trim() is an empty string.
TL1ParserException - if the message string is not a valid input message.
public com.adventnet.tl1.message.TL1InputMessage createTL1Message(java.lang.String message,
boolean isrigid)
throws TL1ParserException
TL1InputMessage object from a raw input
message string.
This factory method parses according to the parser mode and the comment
recognition mode set.
Rejects (throws TL1ParserException) messages that are not valid
(recognizable) input messages.
message - the raw message string.
TL1InputMessage object for a valid input message
string; null for a null message
string and if message.trim() is an empty string.
TL1ParserException - if the message string is not a valid input message.
public void rule(java.lang.String parsable,
int rule)
throws TL1ParserException
This rule checker method offers fine-grained grammar validation
capability to applications. It parses according to the parser mode
and the comment recognition mode set.
Rejects (throws TL1ParserException) patterns that donot conform
to the valid grammar of that particular Rule Constant passed.
Most of the Rule Constants are applicable (active) for both Flexible and Rigid parser modes. But some of them are applicable for only one parser mode, depending on which mode they are used by the parser for pattern. All the Rule Constants are of public static final int type. Please refer to the Rule Constant Matrix for more information on specific Rule Constants.
Example code snippet : This is a code snippet for validating the Access Identifier of a input message Rigid Parser mode is used here. The default Chained Comment mode is left as it is, as comments donot matter here.
String pattern = "OC3-6-1-2&OC3-6-1-4,OC3-6-1-3&OC3-6-1-5";
TL1InputMessageParser ipsr = new TL1InputMessageParser();
ipsr.setParserMode(true);
try {
ipsr.rule(pattern, TL1InputMessageParser.RULE_AccessId);
} catch (TL1ParseException tpex) {
tpex.printStackTrace();
... // Error recovery code
}
parsable - the raw building-block (pattern structure) string.rule - the Rule Constant corresponding to the particular pattern
structure checked.
TL1ParserException - if the message string is a valid pattern.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||