01: /**********************************************************************
02: Copyright (c) 2006 Erik Bengtson and others. All rights reserved.
03: Licensed under the Apache License, Version 2.0 (the "License");
04: you may not use this file except in compliance with the License.
05: You may obtain a copy of the License at
06:
07: http://www.apache.org/licenses/LICENSE-2.0
08:
09: Unless required by applicable law or agreed to in writing, software
10: distributed under the License is distributed on an "AS IS" BASIS,
11: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12: See the License for the specific language governing permissions and
13: limitations under the License.
14:
15:
16: Contributors:
17: ...
18: **********************************************************************/package org.jpox.jdo.state;
19:
20: import org.jpox.state.LifeCycleState;
21:
22: /**
23: * Factory for life cycle states
24: *
25: * @version $Revision: 1.2 $
26: **/
27: public abstract class LifeCycleStateFactory {
28: private static LifeCycleState states[];
29:
30: static {
31: states = new LifeCycleState[LifeCycleState.TOTAL];
32:
33: states[LifeCycleState.HOLLOW] = new Hollow();
34: states[LifeCycleState.P_CLEAN] = new PersistentClean();
35: states[LifeCycleState.P_DIRTY] = new PersistentDirty();
36: states[LifeCycleState.P_NEW] = new PersistentNew();
37: states[LifeCycleState.P_NEW_DELETED] = new PersistentNewDeleted();
38: states[LifeCycleState.P_DELETED] = new PersistentDeleted();
39: states[LifeCycleState.P_NONTRANS] = new PersistentNontransactional();
40: states[LifeCycleState.T_CLEAN] = new TransientClean();
41: states[LifeCycleState.T_DIRTY] = new TransientDirty();
42: states[LifeCycleState.P_NONTRANS_DIRTY] = new PersistentNontransactionalDirty();
43: states[LifeCycleState.DETACHED_CLEAN] = new DetachedClean();
44: states[LifeCycleState.DETACHED_DIRTY] = new DetachedDirty();
45: states[LifeCycleState.TRANSIENT] = null;
46: }
47:
48: /**
49: * Returns the LifeCycleState for the state constant.
50: * @param stateType the type as integer
51: * @return the type as LifeCycleState object
52: */
53: public static final LifeCycleState getLifeCycleState(int stateType) {
54: return states[stateType];
55: }
56:
57: }
|