[4939] | 1 | /**
|
---|
| 2 | *#########################################################################
|
---|
| 3 | *
|
---|
| 4 | * A component of the Gatherer application, part of the Greenstone digital
|
---|
| 5 | * library suite from the New Zealand Digital Library Project at the
|
---|
| 6 | * University of Waikato, New Zealand.
|
---|
| 7 | *
|
---|
| 8 | * Author: John Thompson, Greenstone Digital Library, University of Waikato
|
---|
| 9 | *
|
---|
| 10 | * Copyright (C) 1999 New Zealand Digital Library Project
|
---|
| 11 | *
|
---|
| 12 | * This program is free software; you can redistribute it and/or modify
|
---|
| 13 | * it under the terms of the GNU General Public License as published by
|
---|
| 14 | * the Free Software Foundation; either version 2 of the License, or
|
---|
| 15 | * (at your option) any later version.
|
---|
| 16 | *
|
---|
| 17 | * This program is distributed in the hope that it will be useful,
|
---|
| 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 20 | * GNU General Public License for more details.
|
---|
| 21 | *
|
---|
| 22 | * You should have received a copy of the GNU General Public License
|
---|
| 23 | * along with this program; if not, write to the Free Software
|
---|
| 24 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
| 25 | *########################################################################
|
---|
| 26 | */
|
---|
| 27 | package org.greenstone.gatherer.util;
|
---|
| 28 | /**************************************************************************************
|
---|
| 29 | * Written: 04/07/03
|
---|
| 30 | * Revised:
|
---|
| 31 | **************************************************************************************/
|
---|
| 32 | /** Like a boolean except with three states, true, false and undecided. */
|
---|
| 33 | public class Troolean {
|
---|
| 34 | static final private byte FALSE = 0;
|
---|
| 35 | static final private byte TRUE = 1;
|
---|
| 36 | static final private byte UNDECIDED = -1;
|
---|
| 37 |
|
---|
| 38 | private byte state = UNDECIDED;
|
---|
| 39 |
|
---|
| 40 | public Troolean() {
|
---|
| 41 | }
|
---|
| 42 |
|
---|
| 43 | public Troolean(boolean state) {
|
---|
| 44 | set(state);
|
---|
| 45 | }
|
---|
| 46 |
|
---|
| 47 | public boolean isDecided() {
|
---|
| 48 | return (state != UNDECIDED);
|
---|
| 49 | }
|
---|
| 50 |
|
---|
| 51 | public boolean isFalse() {
|
---|
| 52 | return (state == FALSE);
|
---|
| 53 | }
|
---|
| 54 |
|
---|
| 55 | public boolean isTrue() {
|
---|
| 56 | return (state == TRUE);
|
---|
| 57 | }
|
---|
| 58 |
|
---|
| 59 | public void reset() {
|
---|
| 60 | state = UNDECIDED;
|
---|
| 61 | }
|
---|
| 62 |
|
---|
| 63 | public void set(boolean state) {
|
---|
| 64 | if(state) {
|
---|
| 65 | this.state = TRUE;
|
---|
| 66 | }
|
---|
| 67 | else {
|
---|
| 68 | this.state = FALSE;
|
---|
| 69 | }
|
---|
| 70 | }
|
---|
| 71 | }
|
---|