001: /**********************************************************************
002: Copyright (c) 2002 Kelly Grizzle (TJDO) and others. All rights reserved.
003: Licensed under the Apache License, Version 2.0 (the "License");
004: you may not use this file except in compliance with the License.
005: You may obtain a copy of the License at
006:
007: http://www.apache.org/licenses/LICENSE-2.0
008:
009: Unless required by applicable law or agreed to in writing, software
010: distributed under the License is distributed on an "AS IS" BASIS,
011: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012: See the License for the specific language governing permissions and
013: limitations under the License.
014:
015: Contributors:
016: 2002 Mike Martin - unknown changes
017: 2003 Andy Jefferson - commented
018: ...
019: **********************************************************************/package org.jpox.store.fieldmanager;
020:
021: /**
022: * Field manager for single field. Stores only a single field value, unlike the
023: * StateFieldManager which stores various types.
024: * <p>
025: * The field number arguments to each method are ignored.
026: *
027: * @version $Revision: 1.2 $
028: **/
029: public class SingleValueFieldManager implements FieldManager {
030: private Object fieldValue = null;
031:
032: /**
033: * Mutator for boolean field.
034: * @param fieldNumber Number of field
035: * @param value Value
036: **/
037: public void storeBooleanField(int fieldNumber, boolean value) {
038: fieldValue = value ? Boolean.TRUE : Boolean.FALSE;
039: }
040:
041: /**
042: * Accessor for boolean field.
043: * @param fieldNumber Number of field
044: * @return Boolean value
045: **/
046: public boolean fetchBooleanField(int fieldNumber) {
047: return ((Boolean) fieldValue).booleanValue();
048: }
049:
050: /**
051: * Mutator for char field.
052: * @param fieldNumber Number of field
053: * @param value Value
054: **/
055: public void storeCharField(int fieldNumber, char value) {
056: fieldValue = new Character(value);
057: }
058:
059: /**
060: * Accessor for int field.
061: * @param fieldNumber Number of field
062: * @return int value
063: **/
064: public char fetchCharField(int fieldNumber) {
065: return ((Character) fieldValue).charValue();
066: }
067:
068: /**
069: * Mutator for byte field.
070: * @param fieldNumber Number of field
071: * @param value Value
072: **/
073: public void storeByteField(int fieldNumber, byte value) {
074: fieldValue = new Byte(value);
075: }
076:
077: /**
078: * Accessor for byte field.
079: * @param fieldNumber Number of field
080: * @return byte value
081: **/
082: public byte fetchByteField(int fieldNumber) {
083: return ((Byte) fieldValue).byteValue();
084: }
085:
086: /**
087: * Mutator for boolean field.
088: * @param fieldNumber Number of field
089: * @param value Value
090: **/
091: public void storeShortField(int fieldNumber, short value) {
092: fieldValue = new Short(value);
093: }
094:
095: /**
096: * Accessor for short field.
097: * @param fieldNumber Number of field
098: * @return short value
099: **/
100: public short fetchShortField(int fieldNumber) {
101: return ((Short) fieldValue).shortValue();
102: }
103:
104: /**
105: * Mutator for int field.
106: * @param fieldNumber Number of field
107: * @param value Value
108: **/
109: public void storeIntField(int fieldNumber, int value) {
110: fieldValue = new Integer(value);
111: }
112:
113: /**
114: * Accessor for int field.
115: * @param fieldNumber Number of field
116: * @return int value
117: **/
118: public int fetchIntField(int fieldNumber) {
119: return ((Integer) fieldValue).intValue();
120: }
121:
122: /**
123: * Mutator for long field.
124: * @param fieldNumber Number of field
125: * @param value Value
126: **/
127: public void storeLongField(int fieldNumber, long value) {
128: fieldValue = new Long(value);
129: }
130:
131: /**
132: * Accessor for long field.
133: * @param fieldNumber Number of field
134: * @return long value
135: **/
136: public long fetchLongField(int fieldNumber) {
137: return ((Long) fieldValue).longValue();
138: }
139:
140: /**
141: * Mutator for float field.
142: * @param fieldNumber Number of field
143: * @param value Value
144: **/
145: public void storeFloatField(int fieldNumber, float value) {
146: fieldValue = new Float(value);
147: }
148:
149: /**
150: * Accessor for float field.
151: * @param fieldNumber Number of field
152: * @return float value
153: **/
154: public float fetchFloatField(int fieldNumber) {
155: return ((Float) fieldValue).floatValue();
156: }
157:
158: /**
159: * Mutator for double field.
160: * @param fieldNumber Number of field
161: * @param value Value
162: **/
163: public void storeDoubleField(int fieldNumber, double value) {
164: fieldValue = new Double(value);
165: }
166:
167: /**
168: * Accessor for double field.
169: * @param fieldNumber Number of field
170: * @return double value
171: **/
172: public double fetchDoubleField(int fieldNumber) {
173: return ((Double) fieldValue).doubleValue();
174: }
175:
176: /**
177: * Mutator for String field.
178: * @param fieldNumber Number of field
179: * @param value Value
180: **/
181: public void storeStringField(int fieldNumber, String value) {
182: fieldValue = value;
183: }
184:
185: /**
186: * Accessor for String field.
187: * @param fieldNumber Number of field
188: * @return String value
189: **/
190: public String fetchStringField(int fieldNumber) {
191: return (String) fieldValue;
192: }
193:
194: /**
195: * Mutator for Object field.
196: * @param fieldNumber Number of field
197: * @param value Value
198: **/
199: public void storeObjectField(int fieldNumber, Object value) {
200: fieldValue = value;
201: }
202:
203: /**
204: * Accessor for Object field.
205: * @param fieldNumber Number of field
206: * @return Object value
207: **/
208: public Object fetchObjectField(int fieldNumber) {
209: return fieldValue;
210: }
211: }
|