1 4 package com.tc.object; 5 6 import com.tc.exception.ImplementMe; 7 import com.tc.object.dna.api.DNA; 8 import com.tc.object.dna.api.DNAException; 9 import com.tc.object.dna.api.DNAWriter; 10 11 import gnu.trove.TLinkable; 12 13 import java.util.LinkedList ; 14 import java.util.List ; 15 16 19 public class MockTCObject implements TCObject { 20 private ObjectID id; 21 private Object peer; 22 private List history = new LinkedList (); 23 private final Object resolveLock = new Object (); 24 private long version = 0; 25 private TCClass tcClazz; 26 private boolean accessed = false; 27 28 public MockTCObject(final ObjectID id, final Object obj) { 29 this(id, obj, false, false); 30 } 31 32 public MockTCObject(final ObjectID id, final Object obj, boolean isIndexed, boolean isLogical) { 33 this.peer = obj; 34 this.id = id; 35 this.tcClazz = new MockTCClass(isIndexed, isLogical); 36 } 37 38 public List getHistory() { 39 return history; 40 } 41 42 public ObjectID getObjectID() { 43 return this.id; 44 } 45 46 public Object getPeerObject() { 47 return this.peer; 48 } 49 50 public TCClass getTCClass() { 51 return this.tcClazz; 52 } 53 54 public void booleanFieldChanged(String classname, String fieldname, boolean newValue, int index) { 55 throw new ImplementMe(); 56 } 57 58 public void byteFieldChanged(String classname, String fieldname, byte newValue, int index) { 59 throw new ImplementMe(); 60 } 61 62 public void charFieldChanged(String classname, String fieldname, char newValue, int index) { 63 throw new ImplementMe(); 64 } 65 66 public void doubleFieldChanged(String classname, String fieldname, double newValue, int index) { 67 throw new ImplementMe(); 68 } 69 70 public void floatFieldChanged(String classname, String fieldname, float newValue, int index) { 71 throw new ImplementMe(); 72 } 73 74 public void intFieldChanged(String classname, String fieldname, int newValue, int index) { 75 throw new ImplementMe(); 76 } 77 78 public void longFieldChanged(String classname, String fieldname, long newValue, int index) { 79 throw new ImplementMe(); 80 } 81 82 public void shortFieldChanged(String classname, String fieldname, short newValue, int index) { 83 throw new ImplementMe(); 84 } 85 86 public void hydrate(DNA from, boolean force) throws DNAException { 87 } 89 90 public void resolveReference(String fieldName) { 91 throw new ImplementMe(); 92 } 93 94 public void resolveArrayReference(int index) { 95 return; 96 } 97 98 public void dehydrate(DNAWriter writer) throws DNAException { 99 return; 100 } 101 102 public void objectFieldChanged(String classname, String fieldname, Object newValue, int index) { 103 return; 104 } 105 106 public boolean isPhysical() { 107 return true; 108 } 109 110 public boolean isLogical() { 111 return false; 112 } 113 114 public static class MethodCall { 115 public int method; 116 public Object [] parameters; 117 118 public MethodCall(int method, Object [] parameters) { 119 this.method = method; 120 this.parameters = parameters; 121 } 122 123 public String toString() { 124 StringBuffer sb = new StringBuffer (); 125 sb.append(method); 126 sb.append("("); 127 for (int i = 0; i < parameters.length; i++) { 128 sb.append(parameters[i].toString()); 129 if (i + 1 < parameters.length) { 130 sb.append(','); 131 } 132 } 133 sb.append(")"); 134 return sb.toString(); 135 } 136 } 137 138 public void setReference(String fieldName, ObjectID id) { 139 throw new ImplementMe(); 140 } 141 142 public void setValue(String fieldName, Object obj) { 143 throw new ImplementMe(); 144 } 145 146 public long getVersion() { 147 return version; 148 } 149 150 public void setVersion(long version) { 151 this.version = version; 152 } 153 154 public int clearReferences(int toClear) { 155 return 0; 156 } 157 158 public Object getResolveLock() { 159 return resolveLock; 160 } 161 162 public void setNext(TLinkable link) { 163 throw new ImplementMe(); 164 } 165 166 public void setPrevious(TLinkable link) { 167 throw new ImplementMe(); 168 } 169 170 public TLinkable getNext() { 171 return null; 172 } 173 174 public TLinkable getPrevious() { 175 return null; 176 } 177 178 public ClassLoader getClassLoader() { 179 return null; 180 } 181 182 public void markAccessed() { 183 this.accessed = true; 184 } 185 186 public void clearAccessed() { 187 this.accessed = false; 188 } 189 190 public boolean recentlyAccessed() { 191 return this.accessed; 192 } 193 194 public int accessCount(int factor) { 195 throw new ImplementMe(); 196 } 197 198 public void clearReference(String fieldName) { 199 throw new ImplementMe(); 200 } 201 202 public void resolveAllReferences() { 203 } 205 206 public boolean getAndResetNew() { 207 return false; 208 } 209 210 public void setIsNew() { 211 } 213 214 public boolean isNew() { 215 return false; 216 } 217 218 public boolean isShared() { 219 return true; 220 } 221 222 public void objectFieldChangedByOffset(String classname, long fieldOffset, Object newValue, int index) { 223 return; 224 } 225 226 public void logicalInvoke(int method, String methodSignature, Object [] params) { 227 history.add(new MethodCall(method, params)); 228 System.out.println("This:" + this + " logging:" + methodSignature + " params:" + params + " history:" + history); 229 } 230 231 public String getFieldNameByOffset(long fieldOffset) { 232 throw new ImplementMe(); 233 } 234 235 public void disableAutoLocking() { 236 throw new ImplementMe(); 237 } 238 239 public boolean autoLockingDisabled() { 240 return false; 241 } 242 243 public boolean canEvict() { 244 throw new ImplementMe(); 245 } 246 247 public void objectArrayChanged(int startPos, Object [] array, int length) { 248 throw new ImplementMe(); 249 } 250 251 public void primitiveArrayChanged(int startPos, Object array, int length) { 252 throw new ImplementMe(); 253 } 254 255 public void literalValueChanged(Object newValue, Object oldValue) { 256 throw new ImplementMe(); 257 } 258 259 public void setLiteralValue(Object newValue) { 260 throw new ImplementMe(); 261 } 262 263 public ArrayIndexOutOfBoundsException checkArrayIndex(int index) { 264 throw new ImplementMe(); 265 } 266 } 267 | Popular Tags |