01: /*
02: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
03: */
04: package com.tc.objectserver.core.api;
05:
06: import com.tc.exception.ImplementMe;
07: import com.tc.object.dna.api.DNACursor;
08: import com.tc.object.dna.api.DNAEncoding;
09: import com.tc.object.dna.api.LiteralAction;
10: import com.tc.object.dna.api.LogicalAction;
11: import com.tc.object.dna.api.PhysicalAction;
12:
13: import java.util.ArrayList;
14: import java.util.List;
15:
16: /**
17: * @author steve
18: */
19: public class TestDNACursor implements DNACursor {
20:
21: private List actions = new ArrayList();
22: private int current = -1;
23:
24: public void addPhysicalAction(String addFieldName, Object addObj) {
25: actions.add(new PhysicalAction(addFieldName, addObj, true));
26: }
27:
28: public void addPhysicalAction(String addFieldName, Object addObj,
29: boolean isref) {
30: actions.add(new PhysicalAction(addFieldName, addObj, isref));
31: }
32:
33: public void addLogicalAction(int method, Object params[]) {
34: actions.add(new LogicalAction(method, params));
35: }
36:
37: public void addArrayAction(Object[] objects) {
38: actions.add(new PhysicalAction(objects));
39: }
40:
41: public void addLiteralAction(String field, Object value) {
42: //actions.add(new PhysicalAction(field, value));
43: actions.add(new LiteralAction(value));
44: }
45:
46: public boolean next() {
47: return actions.size() > ++current;
48: }
49:
50: public LogicalAction getLogicalAction() {
51: return (LogicalAction) actions.get(current);
52: }
53:
54: public Object getAction() {
55: return actions.get(current);
56: }
57:
58: public PhysicalAction getPhysicalAction() {
59: return (PhysicalAction) actions.get(current);
60: }
61:
62: public boolean next(DNAEncoding encoding) {
63: throw new ImplementMe();
64: }
65:
66: public int getActionCount() {
67: return actions.size();
68: }
69:
70: public void reset() throws UnsupportedOperationException {
71: current = -1;
72: }
73:
74: }
|