|
Asterisk-Java | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.asteriskjava.manager.action.AbstractManagerAction
org.asteriskjava.manager.action.GetVarAction
public class GetVarAction
The GetVarAction queries for a global or local channel variable.
Reading global variables is supported since Asterisk 1.2.
You cannot read built-in channel variables such as LANGUAGE
or
CALLERIDNUM
using the Manager API. You can only
read channel variables that you have explicitly set using the
Set
or SetVar
(for Asterisk 1.0.x)
applications in the dialplan, in an AGI script or by using
the SetVarAction
through
the Manager API itself.
GetVarAction returns a GetVarResponse
.
To get the actual value from the corresponding
ManagerResponse
call
ManagerResponse.getAttribute(String)
with either the variable name as parameter (for Asterisk 1.0.x) or
with "Value" as parameter (for Asterisk since 1.2).
Example (for Asterisk 1.2):
GetVarAction getVarAction = new GetVarAction(channel, "MY_VAR"); ManagerResponse response = c.sendAction(getVarAction); String value = response.getAttribute("Value"); System.out.println("MY_VAR on " + channel + " is " + value);Where
c
is an instance of
ManagerConnection
and channel
contains the name of a channel instance, for example "SIP/1234-9cd".
Since Asterisk-Java 1.0.0 you can also call
GetVarResponse.getValue()
when using Asterisk 1.2 or later.
Since Asterisk 1.4 this action also supports built-in functions like
DB()
, CALLERID()
and ENV()
.
Constructor Summary | |
---|---|
GetVarAction()
Creates a new empty GetVarAction. |
|
GetVarAction(java.lang.String variable)
Creates a new GetVarAction that queries for the given global variable. |
|
GetVarAction(java.lang.String channel,
java.lang.String variable)
Creates a new GetVarAction that queries for the given local channel variable. |
Method Summary | |
---|---|
java.lang.String |
getAction()
Returns the name of this action, i.e. |
java.lang.String |
getChannel()
Returns the name of the channel if you query for a local channel variable or null if it is a global variable. |
java.lang.String |
getVariable()
Retruns the name of the variable to query. |
void |
setChannel(java.lang.String channel)
Sets the name of the channel if you query for a local channel variable. |
void |
setVariable(java.lang.String variable)
Sets the name of the variable to query. |
Methods inherited from class org.asteriskjava.manager.action.AbstractManagerAction |
---|
getActionId, setActionId, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public GetVarAction()
public GetVarAction(java.lang.String variable)
variable
- the name of the global variable to query.public GetVarAction(java.lang.String channel, java.lang.String variable)
channel
- the name of the channel, for example "SIP/1234-9cd".variable
- the name of the variable to query.Method Detail |
---|
public java.lang.String getAction()
getAction
in interface ManagerAction
getAction
in class AbstractManagerAction
public java.lang.String getChannel()
null
if it is a global variable.
public void setChannel(java.lang.String channel)
channel
- the channel if you query for a local channel variable or
null
to query for a gloabl variable.public java.lang.String getVariable()
public void setVariable(java.lang.String variable)
|
Asterisk-Java | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |