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.generation;
33
34 import com.unitesk.atp.tree.Node;
35 import com.unitesk.atp.text.generation.Generator;
36
37 /***
38 * The base interface of text generation from attributed tree.
39 *
40 * @author <A href="mailto:demakov@ispras.ru">Alexey Demakov</A>
41 * @version $Id: TextGenerator.java,v 1.1 2004/10/09 06:28:48 all-x Exp $
42 */
43 public interface TextGenerator extends Generator
44 {
45 /***
46 * Line separator string.
47 */
48 String endl = System.getProperty( "line.separator" );
49
50 /***
51 * Sets default <code>node</code> for all operations with attributes.
52 *
53 * @param node The new default node.
54 */
55 void pushNode( Node node );
56
57 /***
58 * Returns current node.
59 *
60 * @return The current node.
61 */
62 Node getNode();
63
64 /***
65 * Restore previous node.
66 */
67 void popNode();
68
69 /***
70 * Makes <code>indent</code> current indent level.
71 * The previous indent level can be restored by {@link #popIndent()}
72 *
73 * @param indent the new indent level
74 * @throws IllegalArgumentException
75 * if <code>indent</code> is negative
76 */
77 void pushIndent( int indent );
78
79 /***
80 * Returns the current indent level.
81 *
82 * @return The current indent level.
83 */
84 int getIndent();
85
86 /***
87 * Increases indent level at one indent step.
88 * The previous indent level can be restored by {@link #popIndent()}
89 */
90 void incIndent();
91
92 /***
93 * Decreases indent level at one indent step.
94 * The previous indent level can be restored by {@link #popIndent()}
95 *
96 * @throws IllegalArgumentException
97 * if resulting indent level is negative
98 */
99 void decIndent();
100
101 /***
102 * Restores previous indent level.
103 *
104 * @throws EmptyStackException
105 * if indent level was not set
106 *
107 * @see #pushIndent(int)
108 * @see #incIndent()
109 * @see #decIndent()
110 */
111 void popIndent();
112
113 /***
114 * Prints list of strings.
115 *
116 * @param index The variable name to store current index of list element.
117 * @param start The starting value of an index
118 * @param end if start < end then<BR>
119 * index is increased by 1
120 * from start to end - 1<BR>
121 * if start > end then<BR>
122 * index is decreased by 1
123 * from start - 1 to end<BR>
124 * if start == end then<BR>
125 * no actions
126 * @param str The string to print for each list element using
127 * {@link #txt(String) txt( str )}
128 * @param separator
129 * The separator to print between strings
130 * for list elements using
131 * {@link #txt(String) txt( str )}
132 *
133 * @throws NullPointerException
134 * if any parameter is <code>null</code>
135 * (except <code>separator</code>)
136 */
137 void list( String index
138 , int start
139 , int end
140 , String str
141 , String separator
142 );
143
144 /***
145 * Starts a new line of text.
146 *
147 */
148 void nl();
149 }