Update of /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/util
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9383/src/java/net/sf/asterisk/util
Added Files:
AstUtil.java
Log Message:
Fixed String to Boolean conversion in EventBuilder
--- NEW FILE: AstUtil.java ---
package net.sf.asterisk.util;
/**
* Some static utility methods to handle Asterisk specific stuff.<br>
* See Asterisk's <code>util.c</code>.
*
* @author srt
* @version $Id: AstUtil.java,v 1.1 2005/07/26 12:16:03 srt Exp $
*/
public class AstUtil
{
// hide constructor
private AstUtil()
{
}
/**
* Checks if a String represents <code>true</code> or <code>false</code>
* according to Asterisk's logic.<br>
* The original implementation is <code>util.c</code> is as follows:
*
* <pre>
* 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;
* }
* </pre>
*
* @param s the String to check for <code>true</code>.
* @return <code>true</code> if s represents <code>true</code>,
* <code>false</code> otherwise.
*/
public static boolean isTrue(String s)
{
if (s == null || s.length() == 0)
{
return false;
}
if (("yes".equalsIgnoreCase(s) || "true".equalsIgnoreCase(s))
|| "y".equalsIgnoreCase(s) || "t".equalsIgnoreCase(s)
|| "1".equalsIgnoreCase(s) || "on".equalsIgnoreCase(s))
{
return true;
}
else
{
return false;
}
}
}
|