public interface IDataTreeCursor extends IDataCursor
This cursor class has been deprecated. To position a cursor by key, use the key-based methods in the IDataCursor
or IDataSharedCursor
classes.
This interface defines methods you can use to traverse a tree of IData objects. It is returned by an IData object's getTreeCursor method.
Because this interface extends IDataCursor, you can also use the methods from that interface to access, traverse, and manipulate the IData object--you may arbitrarily mix the methods in IDataTreeCursor and IDataCursor as needed. For example, you might use IDataCursor.last to position the cursor at the last name/value pair in the object and then use IDataHashTreeCursor.down method to move into the nested IData object.
If you write a class that implements the IData interface, that class must support the getTreeCursor method and that method must return a class that implements this interface.
Note: The contents of an IData object is not synchronized, so information, such as the value returned by count, might not be accurate if multiple cursors modify a single IData.
The following is an example of how a this interface might be used to navigate an IData object. In this example, every one of the println messages will display "true":
IData id = IDataFactory.create(); IData idChild1 = IDataFactory.create(); IDataCursor idcChild1 = idChild1.getCursor(); idcChild1.insertAfter("s", "s1"); idcChild1.destroy(); IDataTreeCursor idtc = id.getTreeCursor(); idtc.insertAfter("a", "a1"); idtc.insertAfter("child1", idChild1); idtc.first(); // can’t move up, because there is no parent to this IData. // the parent had to be walked through with a down(). System.out.println("TreeCursor up(false) "+ !idtc.up()); // can’t move down, because the current value is not an IData. System.out.println( "TreeCursor down(false)" + !idtc.down()); // move to the second name/value pair, which does have an IData value System.out.println( "TreeCursor next(true) "+ idtc.next()); // can move down, because the current value is an IData. System.out.println("TreeCursor down(true) "+ idtc.down()); String key; System.out.println("TreeCursor first() of child "+ idtc.first()); key = idtc.getKey(); System.out.println("TreeCursor getKey():'"+key+"'"); if( key!=null ) if ( key.equals("s")) System.out.println("TreeCursor getKey('s')");
IData
,
IDataFactory
,
IDataCursor
,
IDataHashCursor
Modifier and Type | Method and Description |
---|---|
boolean |
down()
Deprecated.
No replacement.
|
boolean |
up()
Deprecated.
No replacement.
|
delete, destroy, first, first, getCursorClone, getKey, getLastError, getValue, hasMoreData, hasMoreErrors, insertAfter, insertBefore, insertDataAfter, insertDataBefore, last, last, next, next, previous, previous, setErrorMode, setKey, setValue
boolean up()
boolean down()