1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32 package com.unitesk.atp.tree;
33
34 /***
35 * A node of an attributed tree (AT).
36 * Each node except <code>root</code> node has <code>parent</code> node.
37 * {@link com.unitesk.atp.dynattrs.Accessor Accessor} can be used to work with node attributes.
38 * <code>Child</code> of node is an attribute's value or an element
39 * of an indexed attribute that implement this interface and have this node
40 * as parent.
41 * <P>Implementations of this interface should provide read-only attribute
42 * <code>"this"</code> whose value is object itself.
43 *
44 * @author <A href="mailto:demakov@ispras.ru">Alexey Demakov</A>
45 * @version $Id: Node.java,v 1.9 2005/09/07 14:40:56 all-x Exp $
46 */
47 public interface Node extends Keyed
48 {
49 /***
50 * Gets the parent of this node.
51 *
52 * @return The parent of this node.
53 * Can be <code>null</code> only for root node.
54 */
55 Node getParent();
56
57 /***
58 * Sets the parent of this node.
59 *
60 * @param parent The node to become parent of this node.
61 * @throws NullPointerException
62 * If <code>parent</code> is <code>null</code>.
63 * @throws IllegalArgumentException
64 * If parent was already set.
65 * @see #resetParent()
66 */
67 void setParent( Node parent );
68
69 /***
70 * Reset parent of this node.
71 *
72 * @see #setParent(Node)
73 * @since 3.6
74 */
75 void resetParent();
76
77 /***
78 * Makes a value of the specified attribute a child of this node.
79 * If this attribute is indexed makes each element of its value
80 * a child of this node.
81 * <code>null</code> an attribute value or an element are allowed.
82 *
83 * @param name The name of an attribute of this node.
84 * @throws IllegalArgumentException
85 * If the specified name is not a name of an attribute
86 * of this node.
87 * @throws ClassCastException
88 * If a value of an attribute or an element
89 * of indexed attribute does not implement
90 * {@link Node} interface.
91 */
92 void makeChild( String name );
93
94 /***
95 * Accepts the specified visitor.
96 * This is an implementation of <code>Visitor</code> design pattern.
97 * Each inherited node type <code>NodeType</code> must override this method
98 * to call <code>void visit<I>NodeType</I>( NodeType node )</code>
99 * visitor's method.
100 *
101 * @param visitor The visitor to accept.
102 */
103 void accept( Visitor visitor );
104 }