01: /*
02: * Copyright 2004 (C) TJDO.
03: * All rights reserved.
04: *
05: * This software is distributed under the terms of the TJDO License version 1.0.
06: * See the terms of the TJDO License in the documentation provided with this software.
07: *
08: * $Id: StateFieldManager.java,v 1.2 2004/01/18 03:01:06 jackknifebarber Exp $
09: */
10:
11: package com.triactive.jdo.state;
12:
13: import com.triactive.jdo.GenericFieldManager;
14: import java.util.ArrayList;
15:
16: /**
17: * A simple field manager that stores/fetches field values in memory.
18: * <p>
19: * Calls to the store methods save the value in a local array; calls to the
20: * fetch methods return the previously stored value for that field, or the
21: * "empty" default value if nothing has been stored.
22: *
23: * @author <a href="mailto:mmartin5@austin.rr.com">Mike Martin</a>
24: * @version $Revision: 1.2 $
25: */
26:
27: class StateFieldManager extends GenericFieldManager {
28: private final ArrayList values = new ArrayList();
29:
30: public void storeObjectField(int fieldNum, Object value) {
31: while (values.size() <= fieldNum)
32: values.add(null);
33:
34: values.set(fieldNum, value);
35: }
36:
37: public Object fetchObjectField(int fieldNum) {
38: if (fieldNum < values.size())
39: return values.get(fieldNum);
40: else
41: return null;
42: }
43: }
|