WebNMS TL1 API Release 4 Specification

com.adventnet.tl1
Interface MessageFormatter


public interface MessageFormatter

This interface allows interworking between the TL1 Manager and a TL1Device which uses different TL1 message formats.

The TL1 Message Parser expects TL1 Messages to be in the TL1 standard compliant format. In some cases, the TL1Device may follow a format that is slightly different from the TL1 standard format and may send and receive TL1Messages in this format. This will give rise to situations where the TL1MessageParser is unable to parse certain TL1Messages 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 TL1 Devices which send non-standard messages , such as messages with TextBlocks containing characters which are not complaint with 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 way to make the message compatible with the standard compliant parser, by defining an appropriate formatting action inside the method in the interface implementation.

You must register this handler 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, TL1Session.setMessageFormatter(com.adventnet.tl1.MessageFormatter), TL1Session.removeMessageFormatter()

Method Summary
 java.lang.String formatMessageReceived(TL1Session session, java.lang.String message)
          Invoked before parsing the received message.
 java.lang.String formatMessageToSend(TL1Session session, java.lang.String message)
          Invoked before the essage is sent to the TL1Device.
 

Method Detail

formatMessageReceived

public java.lang.String formatMessageReceived(TL1Session session,
                                              java.lang.String message)
Invoked before parsing the received message. The implementation of this method can process the string message and return the formatted message. In case if there are no changes required in the processing, then this method can return the received message string.

Parameters:
session - TL1Session instance.
message - String form of message from the TL1Device.
Returns:
The String form of the message from the TL1Device after formatting.

formatMessageToSend

public java.lang.String formatMessageToSend(TL1Session session,
                                            java.lang.String message)
Invoked before the essage is sent to the TL1Device. The implementation of this method can process the string message and return the formatted message. In case if there are no changes required in the processing, then this method can return the received message string.

Parameters:
session - TL1Session instance.
message - String form of the message to the TL1Device.
Returns:
The String message after formatting.

WebNMS TL1 API Release 4 Specification