|
Asterisk-Java | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.asteriskjava.util.AstUtil
public class AstUtil
Some static utility methods to imitate Asterisk specific logic.
See Asterisk'sutil.c.
Client code is not supposed to use this class.
| Method Summary | |
|---|---|
static boolean |
isNull(java.lang.Object s)
Checks if the value of s was null in Asterisk. |
static boolean |
isTrue(java.lang.Object o)
Checks if a String represents true or false
according to Asterisk's logic. |
static java.lang.String[] |
parseCallerId(java.lang.String s)
Parses a string for caller id information. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static boolean isTrue(java.lang.Object o)
true or false
according to Asterisk's logic.
The original implementation is util.c is as follows:
int ast_true(const char *s)
{
if (!s || ast_strlen_zero(s))
return 0;
if (!strcasecmp(s, "yes") ||
!strcasecmp(s, "true") ||
!strcasecmp(s, "y") ||
!strcasecmp(s, "t") ||
!strcasecmp(s, "1") ||
!strcasecmp(s, "on"))
return -1;
return 0;
}
To support the dnd property of
ZapShowChannelsEvent this method
also consideres the string "Enabled" as true.
o - the Object (usually a String) to check for true.
true if s represents true,
false otherwise.public static java.lang.String[] parseCallerId(java.lang.String s)
"Some Name" <1234>.
This resembles ast_callerid_parse in
callerid.c but strips any whitespace.
s - the string to parse
public static boolean isNull(java.lang.Object s)
null in Asterisk.
This method is useful as Asterisk likes to replace null
values with different string values like "unknown", "<unknown>"
or "<null>".
To find such replacements search for S_OR in Asterisk's
source code. You will find things like
S_OR(chan->cid.cid_num, "<unknown>") fdprintf(fd, "agi_callerid: %s\n", S_OR(chan->cid.cid_num, "unknown"));and more...
s - the string to test, may be null. If s is not a string
the only test that is performed is a check for null.
true if the s was null in Asterisk;
false otherwise.
|
Asterisk-Java | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||