1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.asn1.ber ;
18
19
20 import java.nio.ByteBuffer;
21 import java.util.Iterator;
22 import java.util.List;
23
24
25 /***
26 * A TLV Tuple tree node modeled in the likeness of a TreeNode.
27 *
28 * @author <a href="mailto:dev@directory.apache.org">
29 * Apache Directory Project</a>
30 * @version $Rev: 157644 $
31 */
32 public interface TupleNode
33 {
34 /***
35 * Gets the parent tuple node to this node or null if a parent does not
36 * exist. The analogous method on the <code>TreeNode</code> interface
37 * would be <code>getParent()</code>.
38 *
39 * @return the parent node or null if one does not exist
40 */
41 TupleNode getParentTupleNode() ;
42
43 /***
44 * Gets an iterator over this node's children. The analogous interface on
45 * the <code>TreeNode</code> interface would be <code>children</code> which
46 * returns an <code>Enumeration</code> instead of an <code>Iterator</code>.
47 *
48 * @return an iterator over this node's children
49 */
50 Iterator getChildren() ;
51
52 /***
53 * Gets a tuple node at an index. The analogous interface on <code>TreeNode
54 * </code> would be the <code>getChildAt</code> method.
55 *
56 * @param index the index of the child to get
57 * @return the child node at the specified index
58 */
59 TupleNode getChildTupleNodeAt( int index ) ;
60
61 /***
62 * Gets the chunked value buffer fragments collected within this node.
63 *
64 * @return the value buffer parts for this node
65 */
66 List getValueChunks() ;
67
68 /***
69 * Gets the index of a child if the child node if it exists. The analog
70 * within <code>TreeNode<code> takes a <code>TreeNode</code> instead of a
71 * <code>TupleNode</code>.
72 *
73 * @param node the child node to get the index for
74 * @return the index of the child node or -1 if the node does not exist
75 */
76 int getIndex( TupleNode node ) ;
77
78 /***
79 * Gets the number of child nodes contained. This is the same as in
80 * <code>TreeNode.getChildCount()</code> as well.
81 *
82 * @return the number of child nodes contained.
83 */
84 int getChildCount() ;
85
86 /***
87 * Gets the number of child nodes contained. This is the same as in
88 * <code>TreeNode.size()</code> as well.
89 *
90 * @return the number of children
91 */
92 int size() ;
93
94 /***
95 * Gets the Tuple this node represents. This is the analogous to <code>
96 * TreeNode.getUserObject()</code>.
97 *
98 * @return the tuple this node represents or null if one has not been
99 * assigned
100 */
101 Tuple getTuple() ;
102
103 /***
104 * Recursively encodes the tree rooted at this node.
105 *
106 * @param buf the buffer populated with the BER encoded tlv tree contents
107 */
108 void encode( ByteBuffer buf ) ;
109
110 /***
111 * Checks to see if two trees are equal. Note that the order of children
112 * within the tree as well as the tuples and their contents make a
113 * difference to <code>equals()</code>.
114 *
115 * @param obj the object to compare this node to
116 * @return true if the obj and this node are exact replicas of one another
117 */
118 boolean equals( Object obj ) ;
119
120 /***
121 * Element/node accept method for visitor pattern.
122 *
123 * @param visitor the tuple node tree structure visitor
124 * @see TupleNodeVisitor
125 */
126 void accept( TupleNodeVisitor visitor ) ;
127 }