KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > oracle > toplink > essentials > internal > helper > Answer


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the "License"). You may not use this file except
5  * in compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * glassfish/bootstrap/legal/CDDLv1.0.txt or
9  * https://glassfish.dev.java.net/public/CDDLv1.0.html.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * HEADER in each file and include the License file at
15  * glassfish/bootstrap/legal/CDDLv1.0.txt. If applicable,
16  * add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your
18  * own identifying information: Portions Copyright [yyyy]
19  * [name of copyright owner]
20  */

21 // Copyright (c) 1998, 2005, Oracle. All rights reserved.
22

23 /* Copyright (c) 2004, 2005, Oracle. All rights reserved. */
24 /*
25    DESCRIPTION
26     <short description of component this file declares/defines>
27
28    PRIVATE CLASSES
29     <list of private classes defined - with one-line descriptions>
30
31    NOTES
32     <other useful comments, qualifications, etc.>
33
34    MODIFIED (MM/DD/YY)
35     pkrogh 10/07/05 -
36     pkrogh 09/29/05 -
37     gyorke 08/09/05 - gyorke_10-essentials-directory-creation_050808
38     dmahar 08/04/05 -
39     pkrogh 08/28/04 - codeformat
40     smcritch 05/14/04 - smcritch_refactor_session_read031604
41     smcritch 04/25/04 - Creation
42  */

43 package oracle.toplink.essentials.internal.helper;
44
45
46 /**
47  * <b>Purpose</b>:Stores the answer to a simple yes/no question.
48  * <p>
49  * Superior to Boolean in that you can pass it to a method as a parameter,
50  * that method sets the value to either true or false, and then see the
51  * answer after.
52  * <p>
53  * I.e. if a method finds the answer to a question while doing some calculations,
54  * it can mark the answer so another method doesn't need to do those calculations
55  * again just to see what the answer is.
56  * <p>
57  * I.e. in a method that gets something, might want some clue after as to
58  * from where that something was gotten from.
59  *
60  * @author Stephen McRitchie
61  * @since release specific (what release of product did this appear in)
62  */

63 public class Answer {
64     int answer;
65
66     public Answer() {
67         answer = FalseUndefinedTrue.Undefined;
68     }
69
70     public void setFalse() {
71         answer = FalseUndefinedTrue.False;
72     }
73
74     public void setTrue() {
75         answer = FalseUndefinedTrue.True;
76     }
77
78     public void setUndefined() {
79         answer = FalseUndefinedTrue.Undefined;
80     }
81
82     public boolean isFalse() {
83         return (answer == FalseUndefinedTrue.False);
84     }
85
86     public boolean isTrue() {
87         return (answer == FalseUndefinedTrue.True);
88     }
89
90     public boolean isUndefined() {
91         return (answer == FalseUndefinedTrue.Undefined);
92     }
93
94     public int getAnswer() {
95         return answer;
96     }
97 }
98
Popular Tags