1 | /**
|
---|
2 | * SBoolean.java
|
---|
3 | * Copyright (C) 2010 New Zealand Digital Library, http://expeditee.org
|
---|
4 | *
|
---|
5 | * This program is free software: you can redistribute it and/or modify
|
---|
6 | * it under the terms of the GNU General Public License as published by
|
---|
7 | * the Free Software Foundation, either version 3 of the License, or
|
---|
8 | * (at your option) any later version.
|
---|
9 | *
|
---|
10 | * This program is distributed in the hope that it will be useful,
|
---|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
13 | * GNU General Public License for more details.
|
---|
14 | *
|
---|
15 | * You should have received a copy of the GNU General Public License
|
---|
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>.
|
---|
17 | */
|
---|
18 |
|
---|
19 | package org.expeditee.simple;
|
---|
20 |
|
---|
21 | public class SBoolean extends SPrimitive<Boolean> {
|
---|
22 | public static String prefix = SVariable.prefix + "b" + SVariable.separator;
|
---|
23 |
|
---|
24 | public SBoolean() {
|
---|
25 | super();
|
---|
26 | }
|
---|
27 |
|
---|
28 | public SBoolean(String name, Boolean value) {
|
---|
29 | super(name, value);
|
---|
30 | }
|
---|
31 |
|
---|
32 | public SBoolean(Boolean value) throws IncorrectTypeException {
|
---|
33 | super(value);
|
---|
34 | }
|
---|
35 |
|
---|
36 | @Override
|
---|
37 | public void parse(String s) {
|
---|
38 | String lowerCase = s.toLowerCase();
|
---|
39 | value_ = lowerCase.equals("true") || lowerCase.equals("t")
|
---|
40 | || lowerCase.equals("yes") || lowerCase.equals("on");
|
---|
41 | }
|
---|
42 |
|
---|
43 | @Override
|
---|
44 | public Boolean booleanValue() {
|
---|
45 | return value_;
|
---|
46 | }
|
---|
47 |
|
---|
48 | @Override
|
---|
49 | public Long integerValue() {
|
---|
50 | return value_ ? 1L : 0L;
|
---|
51 | }
|
---|
52 |
|
---|
53 | @Override
|
---|
54 | public Double doubleValue() {
|
---|
55 | return value_ ? 1.0 : 0.0;
|
---|
56 | }
|
---|
57 |
|
---|
58 | @Override
|
---|
59 | public Character characterValue() {
|
---|
60 | return value_ ? 'T' : 'F';
|
---|
61 | }
|
---|
62 |
|
---|
63 | @Override
|
---|
64 | public void setValue(SPrimitive v) throws IncorrectTypeException {
|
---|
65 | value_ = v.booleanValue();
|
---|
66 | }
|
---|
67 | }
|
---|