org.PingOO.DLAI.lib.util
Class MessageFormatter

java.lang.Object
  |
  +--org.PingOO.DLAI.lib.util.MessageFormatter
Direct Known Subclasses:
MasterMessageFormatter

public abstract class MessageFormatter
extends java.lang.Object

The abstract class wich describs the needed functions for a message formatter.
An instance from this class must format outgoing message so they conform the PingOO protocol and so they can be understood by the server.
It formats incoming messages by removing all parts that are must remain hidden from the upper classes.

Since:
PingOO 2.0
Version:
2.0
Author:
Fabrice Bouyé (bouye@cur-archamps.fr)
See Also:
MessageHashtable

Field Summary
static java.lang.String ACCEPTED_NO_TAG
          indicates the server refused this request.
static java.lang.String ACCEPTED_TAG
          Indicates an accepted line.
static java.lang.String ACCEPTED_YES_TAG
          Indicates the server accepted this request.
static java.lang.String COMMENT_TAG
          Indicates an comment line.
 
Constructor Summary
MessageFormatter()
           
 
Method Summary
 java.lang.String parseIn(MessageHashtable message)
          Formats the outgoing message so it can be sent and unstertood by the server.
 java.lang.String parseIn(MessageHashtable message, java.lang.String server)
          Formats the outgoing message so it can be sent and unstertood by the server.
abstract  java.lang.String parseIn(MessageHashtable message, java.lang.String server, java.lang.String port)
          Formats the outgoing message so it can be sent and unstertood by the server.
abstract  MessageHashtable parseOut(byte[] data, java.lang.String module, java.lang.String function)
          Formats an incoming message so it can be used and routed by the PingOO PPM.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

ACCEPTED_TAG

public static final java.lang.String ACCEPTED_TAG
Indicates an accepted line.

ACCEPTED_YES_TAG

public static final java.lang.String ACCEPTED_YES_TAG
Indicates the server accepted this request.

ACCEPTED_NO_TAG

public static final java.lang.String ACCEPTED_NO_TAG
indicates the server refused this request.

COMMENT_TAG

public static final java.lang.String COMMENT_TAG
Indicates an comment line.
Constructor Detail

MessageFormatter

public MessageFormatter()
Method Detail

parseIn

public final java.lang.String parseIn(MessageHashtable message)
                               throws java.lang.NullPointerException
Formats the outgoing message so it can be sent and unstertood by the server.
Parameters:
message - A MessageHashtable containing the keys and objects needed to be sent to the server.
Returns:
The result String line.
Throws:
java.lang.NullPointerException - If the message is null.

parseIn

public final java.lang.String parseIn(MessageHashtable message,
                                      java.lang.String server)
                               throws java.lang.NullPointerException
Formats the outgoing message so it can be sent and unstertood by the server.
Parameters:
message - A MessageHashtable containing the keys and objects needed to be sent to the server.
server - The targeted server.
Returns:
The result String line.
Throws:
java.lang.NullPointerException - If the message or the server is null.

parseIn

public abstract java.lang.String parseIn(MessageHashtable message,
                                         java.lang.String server,
                                         java.lang.String port)
                                  throws java.lang.NullPointerException
Formats the outgoing message so it can be sent and unstertood by the server.
Parameters:
message - A MessageHashtable containing the keys and objects needed to be sent to the server.
server - The targeted server.
port - The targeted port.
Returns:
The result String line.
Throws:
java.lang.NullPointerException - If the message is null.

parseOut

public abstract MessageHashtable parseOut(byte[] data,
                                          java.lang.String module,
                                          java.lang.String function)
                                   throws java.lang.NullPointerException,
                                          BadMessageException
Formats an incoming message so it can be used and routed by the PingOO PPM.
Parameters:
data - The byte array containing the message.
module - The name of the module wich requires this answer.
function - The name of the function wich requires this answer.
Returns:
A MessageHashtable containing all objects sent by the server associated with their key.
Throws:
java.lang.NullPointerException - If the datas are null.
BadMessageException - If the datas have a bad syntax, or when a problem is encountered during the parsing.