Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
StateNewDelete |
|
| 1.0;1 |
1 | package org.apache.ojb.odmg.states; | |
2 | ||
3 | /* Copyright 2002-2005 The Apache Software Foundation | |
4 | * | |
5 | * Licensed under the Apache License, Version 2.0 (the "License"); | |
6 | * you may not use this file except in compliance with the License. | |
7 | * You may obtain a copy of the License at | |
8 | * | |
9 | * http://www.apache.org/licenses/LICENSE-2.0 | |
10 | * | |
11 | * Unless required by applicable law or agreed to in writing, software | |
12 | * distributed under the License is distributed on an "AS IS" BASIS, | |
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
14 | * See the License for the specific language governing permissions and | |
15 | * limitations under the License. | |
16 | */ | |
17 | ||
18 | import org.apache.ojb.odmg.ObjectEnvelope; | |
19 | ||
20 | /** | |
21 | * this state represents new objects which have been mrked for deletion during tx. | |
22 | */ | |
23 | public class StateNewDelete extends ModificationState | |
24 | { | |
25 | private static StateNewDelete _instance = new StateNewDelete(); | |
26 | ||
27 | /** | |
28 | * return resulting state after marking clean | |
29 | */ | |
30 | public ModificationState markClean() | |
31 | { | |
32 | return StateNewClean.getInstance(); | |
33 | } | |
34 | ||
35 | /** | |
36 | * return resulting state after marking delete | |
37 | */ | |
38 | public ModificationState markDelete() | |
39 | { | |
40 | return this; | |
41 | } | |
42 | ||
43 | /** | |
44 | * return resulting state after marking dirty | |
45 | */ | |
46 | public ModificationState markDirty() | |
47 | { | |
48 | return this; | |
49 | } | |
50 | ||
51 | /** | |
52 | * return resulting state after marking new | |
53 | */ | |
54 | public ModificationState markNew() | |
55 | { | |
56 | return StateNewDirty.getInstance(); | |
57 | } | |
58 | ||
59 | /** | |
60 | * return resulting state after marking old | |
61 | */ | |
62 | public ModificationState markOld() | |
63 | { | |
64 | return StateOldDelete.getInstance(); | |
65 | } | |
66 | ||
67 | /** | |
68 | * returns true is this state requires DELETE | |
69 | * @return boolean | |
70 | */ | |
71 | public boolean needsDelete() | |
72 | { | |
73 | return true; | |
74 | } | |
75 | ||
76 | /** | |
77 | * private constructor: use singleton instance | |
78 | */ | |
79 | private StateNewDelete() | |
80 | { | |
81 | } | |
82 | ||
83 | /** | |
84 | * perform a checkpoint, i.e. perform updates on underlying db but keep locks on objects | |
85 | */ | |
86 | public static StateNewDelete getInstance() | |
87 | { | |
88 | return _instance; | |
89 | } | |
90 | ||
91 | /** | |
92 | * rollback the ObjectModification | |
93 | */ | |
94 | public void checkpoint(ObjectEnvelope mod) | |
95 | { | |
96 | } | |
97 | ||
98 | /** | |
99 | * commit ObjectModification | |
100 | */ | |
101 | public void commit(ObjectEnvelope mod) | |
102 | { | |
103 | mod.doEvictFromCache(); | |
104 | mod.setModificationState(StateTransient.getInstance()); | |
105 | } | |
106 | ||
107 | /** | |
108 | * | |
109 | */ | |
110 | public void rollback(ObjectEnvelope mod) | |
111 | { | |
112 | mod.doEvictFromCache(); | |
113 | mod.setModificationState(StateTransient.getInstance()); | |
114 | } | |
115 | } |