01: /*
02: * MCS Media Computer Software Copyright (c) 2005 by MCS
03: * -------------------------------------- Created on 16.01.2004 by w.klaas
04: *
05: * Licensed under the Apache License, Version 2.0 (the "License"); you may not
06: * use this file except in compliance with the License. You may obtain a copy of
07: * the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13: * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14: * License for the specific language governing permissions and limitations under
15: * the License.
16: */
17: package de.mcs.utils;
18:
19: /**
20: * this function is missing in java.
21: *
22: * @author W.Klaas
23: */
24: public final class ExtendedBoolean {
25: /**
26: * Damit man diese Klasse nicht instanzieren kann.
27: */
28: private ExtendedBoolean() {
29: // nothing to do here
30: }
31:
32: /**
33: * String in Boolean verwandeln.
34: *
35: * @param name
36: * String
37: * @return boolean
38: */
39: public static boolean toBoolean(final String name) {
40: return ((name != null) && (name.equalsIgnoreCase("true") || name
41: .equalsIgnoreCase("1")));
42: }
43:
44: /**
45: * String in Boolean verwandeln.
46: *
47: * @param name
48: * String
49: * @param defaultValue
50: * the default value.
51: * @return boolean
52: */
53: public static boolean toBoolean(final String name,
54: final boolean defaultValue) {
55: boolean value = defaultValue;
56: if ((name != null)) {
57: if (!name.equals("")) {
58: value = name.equalsIgnoreCase("true")
59: || name.equalsIgnoreCase("1");
60: }
61: }
62: return value;
63: }
64: }
|