net.sf.asterisk.manager.response
Class ManagerResponse

java.lang.Object
  extended by net.sf.asterisk.manager.response.ManagerResponse
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
ChallengeResponse, CommandResponse, ExtensionStateResponse, MailboxCountResponse, MailboxStatusResponse, ManagerError

public class ManagerResponse
extends java.lang.Object
implements java.io.Serializable

Represents a response received from the Asterisk server as the result of a previously sent ManagerAction.
The response can be linked with the action that caused it by looking the action id attribute that will match the action id of the corresponding action.

Version:
$Id: ManagerResponse.java,v 1.5 2005/04/24 13:39:40 srt Exp $
Author:
srt
See Also:
ManagerAction, Serialized Form

Constructor Summary
ManagerResponse()
           
 
Method Summary
 java.lang.String getActionId()
          Returns the action id received with this response referencing the action that generated this response.
 java.lang.String getAttribute(java.lang.String key)
          Returns the value of the attribute with the given key.
This is particulary important when a response contains special attributes that are dependent on the action that has been sent.
An example of this is the response to the GetVarAction.
 java.util.Map getAttributes()
          Returns a Map with all attributes of this response.
The keys are all lower case!
 java.util.Date getDateReceived()
          Returns the point in time this response was received from the asterisk server.
 java.lang.String getMessage()
          Returns the message received with this response.
 java.lang.String getResponse()
          Returns the value of the "Response:" line.
 java.lang.String getUniqueId()
          Returns the unique id received with this response.
 void setActionId(java.lang.String actionId)
          Sets the action id.
 void setAttributes(java.util.Map attributes)
          Sets the Map with all attributes.
 void setDateReceived(java.util.Date dateReceived)
          Sets the point in time this response was received from the asterisk server.
 void setMessage(java.lang.String message)
          Sets the message.
 void setResponse(java.lang.String response)
          Sets the response.
 void setUniqueId(java.lang.String uniqueId)
          Sets the unique id received with this response.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ManagerResponse

public ManagerResponse()
Method Detail

getAttributes

public java.util.Map getAttributes()
Returns a Map with all attributes of this response.
The keys are all lower case!

See Also:
getAttribute(String)

setAttributes

public void setAttributes(java.util.Map attributes)
Sets the Map with all attributes.

Parameters:
attributes - Map with containing the attributes with all lower case keys.

getAttribute

public java.lang.String getAttribute(java.lang.String key)
Returns the value of the attribute with the given key.
This is particulary important when a response contains special attributes that are dependent on the action that has been sent.
An example of this is the response to the GetVarAction. It contains the value of the channel variable as an attribute stored under the key of the variable name.
Example:
 GetVarAction action = new GetVarAction();
 action.setChannel("SIP/1310-22c3");
 action.setVariable("ALERT_INFO");
 ManagerResponse response = connection.sendAction(action);
 String alertInfo = response.getAttribute("ALERT_INFO");
 
As all attributes are internally stored in lower case the key is automatically converted to lower case before lookup.

Parameters:
key - the key to lookup.
Returns:
the value of the attribute stored under this key or null if there is no such attribute.

getDateReceived

public java.util.Date getDateReceived()
Returns the point in time this response was received from the asterisk server.


setDateReceived

public void setDateReceived(java.util.Date dateReceived)
Sets the point in time this response was received from the asterisk server.


getActionId

public java.lang.String getActionId()
Returns the action id received with this response referencing the action that generated this response.


setActionId

public void setActionId(java.lang.String actionId)
Sets the action id.


getMessage

public java.lang.String getMessage()
Returns the message received with this response. The content depends on the action that generated this response.


setMessage

public void setMessage(java.lang.String message)
Sets the message.


getResponse

public java.lang.String getResponse()
Returns the value of the "Response:" line. This typically a String like "Success" or "Error" but depends on the action that generated this response.


setResponse

public void setResponse(java.lang.String response)
Sets the response.


getUniqueId

public java.lang.String getUniqueId()
Returns the unique id received with this response. The unique id is used to keep track of channels created by the action sent, for example an OriginateAction.


setUniqueId

public void setUniqueId(java.lang.String uniqueId)
Sets the unique id received with this response.


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 2004-2005 Stefan Reuter. All Rights Reserved.