KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > object > tx > optimistic > TCObjectClone


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright
3  * notice. All rights reserved.
4  */

5 package com.tc.object.tx.optimistic;
6
7 /**
8  * In the clone objects we create for rollback we put one of these in the Managed field in order to be able to correlate
9  * them with the original object they were created from.
10  */

11
12 import com.tc.exception.ImplementMe;
13 import com.tc.object.ObjectID;
14 import com.tc.object.TCClass;
15 import com.tc.object.TCObject;
16 import com.tc.object.dna.api.DNA;
17 import com.tc.object.dna.api.DNAException;
18 import com.tc.object.dna.api.DNAWriter;
19
20 import gnu.trove.TLinkable;
21
22 public class TCObjectClone implements TCObject {
23   private final ObjectID objectID;
24   private final long version;
25   private final OptimisticTransactionManager txManager;
26   private final TCClass tcClass;
27   private final int arrayLength;
28
29   public TCObjectClone(TCObject source, OptimisticTransactionManager txManager) {
30     this(source, txManager, -1);
31   }
32
33   public TCObjectClone(TCObject source, OptimisticTransactionManager txManager, int arrayLength) {
34     this.version = source.getVersion();
35     this.objectID = source.getObjectID();
36     this.txManager = txManager;
37     this.tcClass = source.getTCClass();
38     this.arrayLength = arrayLength;
39   }
40
41   public void setNext(TLinkable link) {
42     throw new ImplementMe();
43   }
44
45   public void setPrevious(TLinkable link) {
46     throw new ImplementMe();
47   }
48
49   public TLinkable getNext() {
50     throw new ImplementMe();
51   }
52
53   public TLinkable getPrevious() {
54     throw new ImplementMe();
55   }
56
57   public ObjectID getObjectID() {
58     return objectID;
59   }
60
61   public Object JavaDoc getPeerObject() {
62     throw new ImplementMe();
63   }
64
65   public TCClass getTCClass() {
66     return tcClass;
67   }
68
69   public int clearReferences(int toClear) {
70     throw new ImplementMe();
71   }
72
73   public Object JavaDoc getResolveLock() {
74     return this;
75   }
76
77   public void objectFieldChanged(String JavaDoc classname, String JavaDoc fieldname, Object JavaDoc newValue, int index) {
78     txManager.objectFieldChanged(this, classname, fieldname, newValue, index);
79   }
80
81   public void booleanFieldChanged(String JavaDoc classname, String JavaDoc fieldname, boolean newValue, int index) {
82     this.objectFieldChanged(classname, fieldname, new Boolean JavaDoc(newValue), index);
83   }
84
85   public void byteFieldChanged(String JavaDoc classname, String JavaDoc fieldname, byte newValue, int index) {
86     this.objectFieldChanged(classname, fieldname, new Byte JavaDoc(newValue), index);
87   }
88
89   public void charFieldChanged(String JavaDoc classname, String JavaDoc fieldname, char newValue, int index) {
90     this.objectFieldChanged(classname, fieldname, new Character JavaDoc(newValue), index);
91   }
92
93   public void doubleFieldChanged(String JavaDoc classname, String JavaDoc fieldname, double newValue, int index) {
94     this.objectFieldChanged(classname, fieldname, new Double JavaDoc(newValue), index);
95   }
96
97   public void floatFieldChanged(String JavaDoc classname, String JavaDoc fieldname, float newValue, int index) {
98     this.objectFieldChanged(classname, fieldname, new Float JavaDoc(newValue), index);
99   }
100
101   public void intFieldChanged(String JavaDoc classname, String JavaDoc fieldname, int newValue, int index) {
102     this.objectFieldChanged(classname, fieldname, new Integer JavaDoc(newValue), index);
103   }
104
105   public void longFieldChanged(String JavaDoc classname, String JavaDoc fieldname, long newValue, int index) {
106     this.objectFieldChanged(classname, fieldname, new Long JavaDoc(newValue), index);
107   }
108
109   public void shortFieldChanged(String JavaDoc classname, String JavaDoc fieldname, short newValue, int index) {
110     this.objectFieldChanged(classname, fieldname, new Short JavaDoc(newValue), index);
111   }
112
113   public void logicalInvoke(int method, String JavaDoc methodName, Object JavaDoc[] parameters) {
114     txManager.logicalInvoke(this, method, methodName, parameters);
115   }
116
117   public void hydrate(DNA from, boolean force) throws DNAException {
118     throw new ImplementMe();
119   }
120
121   public void resolveReference(String JavaDoc fieldName) {
122     // do nothing
123
}
124
125   public void resolveArrayReference(int index) {
126     // do Nothing
127
}
128
129   public boolean isShared() {
130     return false;
131   }
132
133   public void resolveAllReferences() {
134     // do nothing
135
}
136
137   public void setReference(String JavaDoc fieldName, ObjectID id) {
138     throw new ImplementMe();
139
140   }
141
142   public void clearReference(String JavaDoc fieldName) {
143     throw new ImplementMe();
144
145   }
146
147   public void setValue(String JavaDoc fieldName, Object JavaDoc obj) {
148     throw new ImplementMe();
149
150   }
151
152   public long getVersion() {
153     return version;
154   }
155
156   public void setVersion(long version) {
157     throw new ImplementMe();
158   }
159
160   public void dehydrate(DNAWriter writer) throws DNAException {
161     throw new ImplementMe();
162   }
163
164   public boolean getAndResetNew() {
165     throw new ImplementMe();
166   }
167
168   public void setIsNew() {
169     throw new ImplementMe();
170   }
171
172   public boolean isNew() {
173     return false;
174   }
175
176   public void markAccessed() {
177     throw new ImplementMe();
178   }
179
180   public void clearAccessed() {
181     throw new ImplementMe();
182   }
183
184   public boolean recentlyAccessed() {
185     throw new ImplementMe();
186   }
187
188   public void objectFieldChangedByOffset(String JavaDoc classname, long fieldOffset, Object JavaDoc newValue, int index) {
189     String JavaDoc fieldname = tcClass.getFieldNameByOffset(fieldOffset);
190     objectFieldChanged(classname, fieldname, newValue, index);
191   }
192
193   public String JavaDoc getFieldNameByOffset(long fieldOffset) {
194     throw new ImplementMe();
195   }
196
197   public void disableAutoLocking() {
198     throw new ImplementMe();
199   }
200
201   public boolean autoLockingDisabled() {
202     return false;
203   }
204
205   public boolean canEvict() {
206     throw new ImplementMe();
207   }
208
209   public void objectArrayChanged(int startPos, Object JavaDoc[] array, int length) {
210     throw new ImplementMe();
211   }
212
213   public void primitiveArrayChanged(int startPos, Object JavaDoc arra, int lengthy) {
214     throw new ImplementMe();
215   }
216
217   public int accessCount(int factor) {
218     throw new ImplementMe();
219   }
220
221   public void literalValueChanged(Object JavaDoc newValue, Object JavaDoc oldValue) {
222     throw new ImplementMe();
223   }
224
225   public void setLiteralValue(Object JavaDoc newValue) {
226     throw new ImplementMe();
227   }
228
229   public ArrayIndexOutOfBoundsException JavaDoc checkArrayIndex(int index) {
230     if (arrayLength < 0) { throw new AssertionError JavaDoc(); }
231     if (index < 0 || index >= arrayLength) { return new ArrayIndexOutOfBoundsException JavaDoc(index); }
232     return null;
233   }
234
235 }
236
Popular Tags