01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of 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,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.cocoon.components.elementprocessor.types;
18:
19: import java.io.IOException;
20:
21: /**
22: * This class holds the result of a boolean conversion. The result is
23: * either a valid value, or an IOException that was created by the
24: * boolean converter
25: *
26: * @author Marc Johnson (marc_johnson27591@hotmail.com)
27: * @version CVS $Id: BooleanResult.java 433543 2006-08-22 06:22:54Z crossley $
28: */
29: public class BooleanResult {
30: private boolean _value;
31: private IOException _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 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 {
72: if (_exception != null) {
73: throw _exception;
74: }
75: return _value;
76: }
77: } // end public class BooleanResult
|