KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > components > elementprocessor > types > BooleanResult


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.cocoon.components.elementprocessor.types;
17
18 import java.io.IOException JavaDoc;
19
20 /**
21  * This class holds the result of a boolean conversion. The result is
22  * either a valid value, or an IOException that was created by the
23  * boolean converter
24  *
25  * @author Marc Johnson (marc_johnson27591@hotmail.com)
26  * @version CVS $Id: BooleanResult.java 30932 2004-07-29 17:35:38Z vgritsenko $
27  */

28 public class BooleanResult
29 {
30     private boolean _value;
31     private IOException JavaDoc _exception;
32
33     /**
34      * Constructor; package scope, as only a boolean converter should
35      * generate one of these
36      *
37      * @param value the boolean value
38      */

39
40     BooleanResult(final boolean value) {
41         this();
42         _value = value;
43     }
44
45     /**
46      * Constructor; package scope, as only a boolean converter should
47      * generate one of these
48      *
49      * @param exception the exception to be thrown
50      */

51
52     BooleanResult(final IOException JavaDoc exception) {
53         this();
54         _exception = exception;
55     }
56
57     private BooleanResult() {
58         _value = false;
59         _exception = null;
60     }
61
62     /**
63      * Get the value as a boolean
64      *
65      * @return the value as a boolean
66      *
67      * @exception IOException if there was a problem converting the
68      * value
69      */

70
71     public boolean booleanValue() throws IOException JavaDoc {
72         if (_exception != null) {
73             throw _exception;
74         }
75         return _value;
76     }
77 } // end public class BooleanResult
78
Popular Tags