ch.epfl.lsr.apex
Class APEXReply

java.lang.Object
  extended bych.epfl.lsr.apex.APEXReply

public class APEXReply
extends Object

The APEXReply sends a reply containing a three-digit reply code and a reason statement on error replies according a specified message.

 
Some reply samples:

<ok>

<error code='550' />

<reply code='550'>unknown endpoint identity</reply>

Author:
Marc Stoecklin

Constructor Summary
APEXReply(APEXMessage message, int code)
          Instantiates a common reply (error or ok element) to a specified message with a three-digit code.
APEXReply(APEXMessage message, int code, boolean replyElement)
          Instantiates a explicitly a reply element on boolean to a specified message with a three-digit code.
APEXReply(APEXMessage message, int code, String reason)
          Instantiates a reply (error or ok element) to a specified message with a three-digit code and a special textual (XML) content.
APEXReply(APEXMessage message, int code, String reason, boolean replyElement)
          Instantiates a explicitly a reply element on boolean to a specified message with a three-digit code and a special textual (XML) content.
 
Method Summary
 int getCode()
          Returns the code of this option.
 String getReason()
          Returns the reason of this option.
static String getReason(int code)
          Returns a textual (standard) reason for a given three-digit code.
 String getXMLMessage()
          Returns an XML String of this reply.
static String getXMLMessage(int code)
          Returns an ok or error element according the code.
static String getXMLMessage(int code, String reason)
          Returns an ok or error element according the code (adds the specified reason in erro elements).
 String getXMLReply()
          Returns an explicitly a reply element of this reply (used in services, so no ok or error element is generated).
static APEXReply parseReply(InputStream is)
          Parses and builds an APEX reply from an input stream.
 void sendReply()
          Sends the reply to the associated message originator.
static void sendReply(APEXMessage message, int code)
          Sends a reply with the specified code to the specified message originator.
static void sendReply(APEXMessage message, int code, String reason)
          Sends a reply with the specified code and reaseon to the specified message originator.
static void sendReply(MessageMSG message, int code)
          Sends a reply with the specified code to the specified org.beepcore.beep.core.MessageMSG originator.
static void sendReply(MessageMSG message, int code, String reason)
          Sends a reply with the specified code to the specified org.beepcore.beep.core.MessageMSG originator.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

APEXReply

public APEXReply(APEXMessage message,
                 int code)
Instantiates a common reply (error or ok element) to a specified message with a three-digit code.

Parameters:
message - The message
code - The three-digit code

APEXReply

public APEXReply(APEXMessage message,
                 int code,
                 String reason)
Instantiates a reply (error or ok element) to a specified message with a three-digit code and a special textual (XML) content.

Parameters:
message - The message
code - The three-digit code
reason - The reason

APEXReply

public APEXReply(APEXMessage message,
                 int code,
                 boolean replyElement)
Instantiates a explicitly a reply element on boolean to a specified message with a three-digit code.

Parameters:
message - The message
code - The three-digit code
replyElement - If an explicit reply element is needed (for services)

APEXReply

public APEXReply(APEXMessage message,
                 int code,
                 String reason,
                 boolean replyElement)
Instantiates a explicitly a reply element on boolean to a specified message with a three-digit code and a special textual (XML) content.

Parameters:
message - The message
code - The three-digit code
reason - The reason
replyElement - If an explicit reply element is needed (for services)
Method Detail

getReason

public static String getReason(int code)
Returns a textual (standard) reason for a given three-digit code.

Parameters:
code - The code
Returns:
The reason

getCode

public int getCode()
Returns the code of this option.

Returns:
The code

getReason

public String getReason()
Returns the reason of this option.

Returns:
The reason

getXMLMessage

public static String getXMLMessage(int code,
                                   String reason)
Returns an ok or error element according the code (adds the specified reason in erro elements).

Parameters:
code - The code
reason - The reason
Returns:
The String ok element.

getXMLMessage

public static String getXMLMessage(int code)
Returns an ok or error element according the code.

Parameters:
code - The code
Returns:
The String ok element.

getXMLMessage

public String getXMLMessage()
Returns an XML String of this reply.

Returns:
The XML String.

getXMLReply

public String getXMLReply()
Returns an explicitly a reply element of this reply (used in services, so no ok or error element is generated).

Returns:
The String reply element.

sendReply

public void sendReply()
Sends the reply to the associated message originator.


sendReply

public static void sendReply(APEXMessage message,
                             int code)
Sends a reply with the specified code to the specified message originator.

Parameters:
message - The message
code - The three-digit code

sendReply

public static void sendReply(APEXMessage message,
                             int code,
                             String reason)
Sends a reply with the specified code and reaseon to the specified message originator.

Parameters:
message - The message
code - The three-digit code
reason - The reason

sendReply

public static void sendReply(MessageMSG message,
                             int code)
Sends a reply with the specified code to the specified org.beepcore.beep.core.MessageMSG originator.

Parameters:
message - The messageMSG
code - The three-digit code

sendReply

public static void sendReply(MessageMSG message,
                             int code,
                             String reason)
Sends a reply with the specified code to the specified org.beepcore.beep.core.MessageMSG originator.

Parameters:
message - The messageMSG
code - The three-digit code
reason - The reason

parseReply

public static APEXReply parseReply(InputStream is)
                            throws APEXParsingException
Parses and builds an APEX reply from an input stream.

Parameters:
is - The input stream
Returns:
A APEX reply
Throws:
APEXParsingException - Thrown on non-validity of the reply element

toString

public String toString()