User: pathoss 
  Date: 02/05/15 00:21:18

  Modified:    core/src/xdoclet/util Tag: MODULE_REFACTORING_BRANCH
                        TypeConversionUtil.java
  Log:
  Updated to support "on" - "off", "1" - "0", "t" - "f", ignoring case.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.4.2.2   +29 -16    xdoclet/core/src/xdoclet/util/TypeConversionUtil.java
  
  Index: TypeConversionUtil.java
  ===================================================================
  RCS file: /cvsroot/xdoclet/xdoclet/core/src/xdoclet/util/TypeConversionUtil.java,v
  retrieving revision 1.4.2.1
  retrieving revision 1.4.2.2
  diff -u -w -r1.4.2.1 -r1.4.2.2
  --- TypeConversionUtil.java   12 May 2002 11:58:04 -0000      1.4.2.1
  +++ TypeConversionUtil.java   15 May 2002 07:21:18 -0000      1.4.2.2
  @@ -7,35 +7,48 @@
   /**
    * @author    Ara Abrahamian ([EMAIL PROTECTED])
    * @created   Oct 15, 2001
  - * @version   $Revision: 1.4.2.1 $
  + * @version   $Revision: 1.4.2.2 $
    */
   public final class TypeConversionUtil
   {
       /**
  -     * A utility method for converting a string to a boolean. "yes", "no",
  -     * "true" and "false" are valid values for a boolean string. If not one of
  -     * then then the value of default_value parameter is returned.
  +     * A utility method for converting a string to a boolean. "yes", "no", "true", 
"false", "1", "0", "on" and "off" are
  +     * valid values for a boolean string (ignoring case). If not one of then then 
the value of defaultValue parameter is
  +     * returned.
        *
  -     * @param str            Description of Parameter
  -     * @param default_value  Description of Parameter
  -     * @return               Description of the Returned Value
  +     * @param defaultValue  Description of Parameter
  +     * @param in            The String to convert
  +     * @return              true or false
        */
  -    public static boolean stringToBoolean(String str, boolean default_value)
  +    public static boolean stringToBoolean(String in, boolean defaultValue)
       {
  -        if (str == null) {
  -            return default_value;
  +        if (in == null || in.trim().length() == 0) {
  +            return defaultValue;
           }
           else {
  -            if (str.equalsIgnoreCase("false") || str.equalsIgnoreCase("no")) {
  +            if (in.equalsIgnoreCase("on")) {
  +                return true;
  +            }
  +            if (in.equalsIgnoreCase("off")) {
                   return false;
               }
  -            else if (str.equalsIgnoreCase("true") || str.equalsIgnoreCase("yes")) {
  +
  +            switch (in.charAt(0)) {
  +            case '1':
  +            case 't':
  +            case 'T':
  +            case 'y':
  +            case 'Y':
                   return true;
  -            }
  -            else {
  -                return default_value;
  +            case '0':
  +            case 'f':
  +            case 'F':
  +            case 'n':
  +            case 'N':
  +                return false;
  +            default:
  +                return defaultValue;
               }
           }
       }
   }
  -
  
  
  

_______________________________________________________________

Have big pipes? SourceForge.net is looking for download mirrors. We supply
the hardware. You get the recognition. Email Us: [EMAIL PROTECTED]
_______________________________________________
Xdoclet-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-devel

Reply via email to