KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > objectserver > core > api > TestDNACursor


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

4 package com.tc.objectserver.core.api;
5
6 import com.tc.exception.ImplementMe;
7 import com.tc.object.dna.api.DNACursor;
8 import com.tc.object.dna.api.LiteralAction;
9 import com.tc.object.dna.api.LogicalAction;
10 import com.tc.object.dna.api.PhysicalAction;
11 import com.tc.object.dna.impl.DNAEncoding;
12
13 import java.util.ArrayList JavaDoc;
14 import java.util.List JavaDoc;
15
16 /**
17  * @author steve
18  */

19 public class TestDNACursor implements DNACursor {
20
21   private List JavaDoc actions = new ArrayList JavaDoc();
22   private int current = -1;
23
24   public void addPhysicalAction(String JavaDoc addFieldName, Object JavaDoc addObj) {
25     actions.add(new PhysicalAction(addFieldName, addObj, true));
26   }
27   
28   public void addPhysicalAction(String JavaDoc addFieldName, Object JavaDoc addObj, boolean isref) {
29     actions.add(new PhysicalAction(addFieldName, addObj, isref));
30   }
31   
32   public void addLogicalAction(int method, Object JavaDoc params[]) {
33     actions.add(new LogicalAction(method, params));
34   }
35   
36   public void addArrayAction(Object JavaDoc[] objects) {
37     actions.add(new PhysicalAction(objects));
38   }
39
40   public void addLiteralAction(String JavaDoc field, Object JavaDoc value) {
41     //actions.add(new PhysicalAction(field, value));
42
actions.add(new LiteralAction(value));
43   }
44
45   public boolean next() {
46     return actions.size() > ++current;
47   }
48
49   public LogicalAction getLogicalAction() {
50     return (LogicalAction) actions.get(current);
51   }
52
53   public Object JavaDoc getAction() {
54     return actions.get(current);
55   }
56
57   public PhysicalAction getPhysicalAction() {
58     return (PhysicalAction) actions.get(current);
59   }
60
61   public boolean next(DNAEncoding encoding) {
62     throw new ImplementMe();
63   }
64
65   public int getActionCount() {
66     return actions.size();
67   }
68
69   public void reset() throws UnsupportedOperationException JavaDoc {
70     current = -1;
71   }
72
73 }
Popular Tags