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.object.dna.api;
05:
06: import java.io.IOException;
07:
08: /**
09: * A ResultSet-like interface for iterating over the fields of a DNA strand. Generally the set
10: * of actions to cursor over consist of either all logical or all physical depending on the class.
11: * <p>
12: * TODO: Perhaps this could be better integrated into some Class hierarchy.
13: *
14: * @author orion
15: */
16: public interface DNACursor {
17:
18: /**
19: * Get total number of actions
20: * @return Action count
21: */
22: public int getActionCount();
23:
24: /**
25: * Move to next action
26: * @return True if there is a next action, false if no more actions
27: * @throws IOException If an IO error occurs while moving the cursor
28: */
29: public boolean next() throws IOException;
30:
31: /**
32: * Move to next action and use specific encoding
33: * @param encoding The DNA encoding
34: * @return True if there is a next action, false if no more actions
35: * @throws IOException If an IO error occurs while moving the cursor
36: * @throws ClassNotFoundException If a class is not found while deserializing DNA
37: */
38: public boolean next(DNAEncoding encoding) throws IOException,
39: ClassNotFoundException;
40:
41: /**
42: * Reset the cursor
43: * @throws UnsupportedOperationException If this cursor implementation does not support reset()
44: */
45: public void reset() throws UnsupportedOperationException;
46:
47: /**
48: * Get a logical action at the current cursor location.
49: * @return Logical action
50: */
51: public LogicalAction getLogicalAction();
52:
53: /**
54: * Get a physical action at the current cursor location.
55: * @return Physical action
56: */
57: public PhysicalAction getPhysicalAction();
58:
59: /**
60: * Return the action at the current cursor location.
61: *
62: * XXX: This should be removed or cleaned up at some point. It's here to support TreeMap which is treated logically,
63: * except for it's "comparator" field which is treated physically
64: * @return LogicalAction, PhysicalAction, or LiteralAction
65: */
66: public Object getAction();
67:
68: }
|