01: /*
02: * $Id: Sum.java 6115 2006-01-30 04:50:47Z dfs $
03: *
04: * Copyright 2006 Daniel F. Savarese
05: *
06: * Licensed under the Apache License, Version 2.0 (the "License");
07: * you may not use this file except in compliance with the License.
08: * You may obtain a copy of the License at
09: *
10: * http://www.savarese.org/software/ApacheLicense-2.0
11: *
12: * Unless required by applicable law or agreed to in writing, software
13: * distributed under the License is distributed on an "AS IS" BASIS,
14: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15: * See the License for the specific language governing permissions and
16: * limitations under the License.
17: */
18:
19: package example.uniquery;
20:
21: /**
22: * A sample JavaBean that can be loaded into the uniquery
23: *{@link Main example program}. Sum adds two integers, A and B.
24: */
25: public final class Sum {
26: private int a, b, sum;
27:
28: /**
29: * Creates a Sum JavaBean with all members initialized to zero.
30: */
31: public Sum() {
32: a = b = sum = 0;
33: }
34:
35: /**
36: * Sets the value of A.
37: *
38: * @param a The new value of A.
39: */
40: public void setA(int a) {
41: this .a = a;
42: }
43:
44: /**
45: * Returns the value of A.
46: *
47: * @return The value of A.
48: */
49: public int getA() {
50: return a;
51: }
52:
53: /**
54: * Sets the value of B.
55: *
56: * @param b The new value of B.
57: */
58: public void setB(int b) {
59: this .b = b;
60: }
61:
62: /**
63: * Returns the value of B.
64: *
65: * @return The value of B.
66: */
67: public int getB() {
68: return b;
69: }
70:
71: /**
72: * Adds A and B and makes the result available via {@link #getSum}.
73: */
74: public void add() {
75: sum = a + b;
76: }
77:
78: /**
79: * Returns the sum of A and B produced by the last call of {@link #add}.
80: *
81: * @return The sum of A and B produced by the last call of {@link #add}.
82: */
83: public int getSum() {
84: return sum;
85: }
86: }
|