com.sun.slamd.message
Class HelloResponseMessage

java.lang.Object
  extended bycom.sun.slamd.message.Message
      extended bycom.sun.slamd.message.HelloResponseMessage

public class HelloResponseMessage
extends Message

This class defines a message that will be sent as a response to a hello message (either client or server hello). It provides a response code that indicates whether the application was successful or if not the reason that it was not successful. It may also optionally contain a message explaining the reason for the failure.


Field Summary
 
Fields inherited from class com.sun.slamd.message.Message
ASN1_TYPE_CLASS_TRANSFER_REQUEST, ASN1_TYPE_CLASS_TRANSFER_RESPONSE, ASN1_TYPE_CLIENT_HELLO, ASN1_TYPE_CLIENT_MANAGER_HELLO, ASN1_TYPE_HELLO_RESPONSE, ASN1_TYPE_JOB_COMPLETED, ASN1_TYPE_JOB_CONTROL_REQUEST, ASN1_TYPE_JOB_CONTROL_RESPONSE, ASN1_TYPE_JOB_REQUEST, ASN1_TYPE_JOB_RESPONSE, ASN1_TYPE_KEEPALIVE, ASN1_TYPE_REGISTER_STAT, ASN1_TYPE_REPORT_STAT, ASN1_TYPE_SERVER_HELLO, ASN1_TYPE_SERVER_SHUTDOWN, ASN1_TYPE_START_CLIENT_REQUEST, ASN1_TYPE_START_CLIENT_RESPONSE, ASN1_TYPE_STATUS_REQUEST, ASN1_TYPE_STATUS_RESPONSE, ASN1_TYPE_STOP_CLIENT_REQUEST, ASN1_TYPE_STOP_CLIENT_RESPONSE, messageID
 
Constructor Summary
HelloResponseMessage(int messageID, int responseCode, long serverTime)
          Creates a new hello response message with the specified response code.
HelloResponseMessage(int messageID, int responseCode, java.lang.String responseMessage, long serverTime)
          Creates a new hello response message with the specified response code and message
 
Method Summary
static HelloResponseMessage decodeHelloResponse(int messageID, ASN1Element element)
          Decodes the provided ASN.1 element as a hello response message.
 ASN1Element encode()
          Encodes this message into an ASN.1 element.
 int getResponseCode()
          Retrieves the response code associated with this message.
 java.lang.String getResponseMessage()
          Retrieves the text message included in this hello response.
 long getServerTime()
          Retrieves the current time on the server at the time this response was created.
 java.lang.String toString()
          Retrieves a string representation of this message.
 
Methods inherited from class com.sun.slamd.message.Message
decode, getMessageID, getMessageType, send
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

HelloResponseMessage

public HelloResponseMessage(int messageID,
                            int responseCode,
                            long serverTime)
Creates a new hello response message with the specified response code. It will not contain a response message.

Parameters:
messageID - The message ID for this message.
responseCode - The response code to include in this response message.
serverTime - The current time on the server at the time this message was created.

HelloResponseMessage

public HelloResponseMessage(int messageID,
                            int responseCode,
                            java.lang.String responseMessage,
                            long serverTime)
Creates a new hello response message with the specified response code and message

Parameters:
messageID - The message ID for this message.
responseCode - The response code to include in this response message.
responseMessage - The text to include in this response message.
serverTime - The current time on the server at the time this message was created.
Method Detail

getResponseCode

public int getResponseCode()
Retrieves the response code associated with this message. The value will be that of one of the MESSAGE_RESPONSE_* constants.

Returns:
The response code associated with this response message.

getResponseMessage

public java.lang.String getResponseMessage()
Retrieves the text message included in this hello response.

Returns:
The text message included in this hello response.

getServerTime

public long getServerTime()
Retrieves the current time on the server at the time this response was created.

Returns:
The current time on the server at the time this response was created, or -1 if the client does not support time synchronization.

toString

public java.lang.String toString()
Retrieves a string representation of this message.

Overrides:
toString in class Message
Returns:
A string representation of this message.

decodeHelloResponse

public static HelloResponseMessage decodeHelloResponse(int messageID,
                                                       ASN1Element element)
                                                throws SLAMDException
Decodes the provided ASN.1 element as a hello response message.

Parameters:
messageID - The message ID to use for this message.
element - The ASN.1 element containing the HelloResponse sequence.
Returns:
The hello response message decoded from the ASN.1 element.
Throws:
SLAMDException - If the provided ASN.1 element cannot be decoded as a hello response message.

encode

public ASN1Element encode()
Encodes this message into an ASN.1 element. A hello response message has the following syntax:

HelloResponse ::= [APPLICATION 2] SEQUENCE { responseCode ResponseCode, responseMessage OCTET STRING }

Specified by:
encode in class Message
Returns:
An ASN.1 encoded representation of this message.