1 /*
2 * Copyright (c) 2001, 2002 The XDoclet team
3 * All rights reserved.
4 */
5 package xdoclet.util;
6
7 /***
8 * @author Ara Abrahamian (ara_e@email.com)
9 * @version $Revision: 1.6 $
10 */
11 public final class TypeConversionUtil {
12 /***
13 * A utility method for converting a string to a boolean. "yes", "no", "true", "false", "1", "0", "on" and "off" are
14 * valid values for a boolean string (ignoring case). If not one of then then the value of defaultValue parameter is
15 * returned.
16 *
17 * @param defaultValue Description of Parameter
18 * @param in The String to convert
19 * @return true or false
20 */
21 public static boolean stringToBoolean(String in, boolean defaultValue) {
22 if ((in == null) || (in.trim().length() == 0)) {
23 return defaultValue;
24 } else {
25 if (in.equalsIgnoreCase("on")) {
26 return true;
27 }
28
29 if (in.equalsIgnoreCase("off")) {
30 return false;
31 }
32
33 switch (in.charAt(0)) {
34 case '1':
35 case 't':
36 case 'T':
37 case 'y':
38 case 'Y':
39 return true;
40
41 case '0':
42 case 'f':
43 case 'F':
44 case 'n':
45 case 'N':
46 return false;
47
48 default:
49 return defaultValue;
50 }
51 }
52 }
53
54 public static String getQualifiedClassName(String packageName, String unqualifiedClassName) {
55 <b>if ((packageName == null) || packageName.equals("")) {
56 return unqualifiedClassName;
57 } else {
58 <b>return packageName + "." + unqualifiedClassName;
59 }
60 }
61 }
This page was automatically generated by Maven