View Javadoc

1   /*
2    * Copyright (c) 2001-2004,
3    * RedVerst Group, ISP RAS http://www.ispras.ru
4    * All rights reserved.
5    *
6    * Redistribution and use in source and binary forms, with or without
7    * modification, are permitted provided that the following conditions are met:
8    *
9    * 1. Redistributions of source code must retain the above copyright notice, this
10   *    list of conditions and the following disclaimer.
11   *
12   * 2. Redistributions in binary form must reproduce the above copyright notice,
13   *    this list of conditions and the following disclaimer in the documentation
14   *    and/or other materials provided with the distribution.
15   *
16   * 3. The names "ATP", "TreeDL", "RedVerst", "ISP RAS"
17   *    may not be used to endorse or promote products derived from this software
18   *    without specific prior written permission.
19   *
20   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
21   * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22   * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23   * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
24   * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25   * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
26   * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
27   * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28   * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29   * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
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      *                   &nbsp;&nbsp;index is increased by 1
120      *                 from start to end - 1<BR>
121      *                 if start > end then<BR>
122      *                   &nbsp;&nbsp;index is decreased by 1
123      *                   from start - 1 to end<BR>
124      *                 if start == end then<BR>
125      *                   &nbsp;&nbsp;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 }