com.adventnet.tl1
Interface MessageFormatter


public interface MessageFormatter

This inferface allows interworking between a TL1 Manager and a TL1 Network Element which may use different TL1 message formats.

The AdventNet TL1 Message Parser expects the TL1 Messages to be in the TL1 standard compliant format. In some cases, the TL1 Network Element (device) may follow a format that is slightly different from the TL1 standard format and may send and receive TL1 messages in this format. This will give rise to situations where the AdventNet TL1 Message Parser is unable to parse certain TL1 Messages from the peer and throws exceptions. This interface will help avoid such situations and enables interworking between the two message formats by allowing the user to convert or modify messages from one format to another.

This interface allows users to format or process TL1 messages that are :

This interface contains two methods :
formatMessageReceived, which is invoked before the string message received from the peer is processed by the TL1 Message Parser, and
formatMessageToSend, which is invoked after the string message to be sent is processed by the TL1 Message Parser.

For instance, there are lot of TL1 devices which send messages that contain non-standard messages, such as messages with TextBlocks containing characters which are not allowed by the standards and also TextBlocks which contain lines without the delimiters specified by the standards,such as "\r","\n" etc. In such circumstances,this interface provides a useful means to make the message compatible with the standard compliant parser, by defining an appropriate formatting action inside the method contained in this interface implementation.

Registering this handler should have to be done after opening the session The implementation of this interface should be registered with TL1Session as follows.

 
 session.setMessageFormatter(MessageFormatterImpl)
  

where session is the instance of TL1Session and MessageFormatterImpl is the implementation of this interface.

See Also:
TL1Session.setMessageFormatter(com.adventnet.tl1.MessageFormatter), TL1Session.removeMessageFormatter(), TL1Session

Method Summary
 java.lang.String formatMessageReceived(java.lang.String message)
          This callback method is invoked before parsing the received message.
 java.lang.String formatMessageToSend(java.lang.String message)
          This callback method is invoked before the TL1 Message is sent to the peer.
 

Method Detail

formatMessageReceived

java.lang.String formatMessageReceived(java.lang.String message)
This callback method is invoked before parsing the received message. In this method, the application can process the string message and return the formatted message. In case there are no changes required in the processing, this method can return the received message string.

Parameters:
message - String form of the response received.
Returns:
The string form of the message,after formatting.

formatMessageToSend

java.lang.String formatMessageToSend(java.lang.String message)
This callback method is invoked before the TL1 Message is sent to the peer. In this method, the application can process the string message and return the formatted message. In case there are no changes required in the processing, this method can return the received message string.

Parameters:
message - String form of the TL1 message.
Returns:
The string message after formatting.