KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openide > src > ElementPrinter


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.openide.src;
21
22 /** Prints elements in a textual form.
23 * For example code generators use this.
24 * <p>Contains three kinds of public members:
25 * <UL>
26 * <LI> Constants to indicate events occurring while an element is printed,
27 * e.g. {@link #ELEMENT_BEGIN} and {@link #ELEMENT_END}.
28 * <LI> Methods to print: {@link #print} and {@link #println}.
29 * <LI> A method for each kind of element, such as methods: {@link #markMethod}, etc.
30 * notify about notable points inside the elements.
31 * For example, if a printer implementation wants to print only
32 * the header for a method, it may implement {@link #markMethod} to throw
33 * {@link ElementPrinterInterruptException} to stop the printing there
34 * when it encounters {@link #HEADER_END}.
35 * </UL>
36 *
37 * @author Petr Hamernik
38 */

39 public interface ElementPrinter {
40     /** Beginning of whole element. */
41     public static final int ELEMENT_BEGIN = 0;
42     /** End of whole element. */
43     public static final int ELEMENT_END = 1;
44
45     /** Beginning of JavaDoc comment (if any). */
46     public static final int JAVADOC_BEGIN = 2;
47     /** End of JavaDoc comment (if any). */
48     public static final int JAVADOC_END = 3;
49
50     /** Beginning of header.
51     * For methods, constructors, and classes.
52     */

53     public static final int HEADER_BEGIN = 4;
54     /** End of header.
55     * For methods, constructors, and classes.
56     */

57     public static final int HEADER_END = 5;
58
59     /** Beginning of body.
60     * For initializers, methods, constructors, and classes.
61     */

62     public static final int BODY_BEGIN = 6;
63
64     /** End of body.
65     * For initializers, methods, constructors, and classes.
66     */

67     public static final int BODY_END = 7;
68
69     /** Print some text.
70     * @param text the text
71     * @exception ElementPrinterInterruptException - see class description
72     */

73     public void print(String JavaDoc text) throws ElementPrinterInterruptException;
74
75     /** Print a line of text with a newline.
76     * @param text the text
77     * @exception ElementPrinterInterruptException - see class description
78     */

79     public void println(String JavaDoc text) throws ElementPrinterInterruptException;
80
81     /** Mark a notable point in a class element.
82     * @param element the element
83     * @param what which point
84     * @exception ElementPrinterInterruptException - see class description
85     */

86     public void markClass(ClassElement element, int what)
87     throws ElementPrinterInterruptException;
88
89     /** Mark a notable point in a initializer element.
90     * @param element the element
91     * @param what which point
92     * @exception ElementPrinterInterruptException - see class description
93     */

94     public void markInitializer(InitializerElement element, int what)
95     throws ElementPrinterInterruptException;
96
97     /** Mark a notable point in a field element.
98     * @param element the element
99     * @param what which point
100     * @exception ElementPrinterInterruptException - see class description
101     */

102     public void markField(FieldElement element, int what)
103     throws ElementPrinterInterruptException;
104
105     /** Mark a notable point in a constructor element.
106     * @param element the element
107     * @param what which point
108     * @exception ElementPrinterInterruptException - see class description
109     */

110     public void markConstructor(ConstructorElement element, int what)
111     throws ElementPrinterInterruptException;
112
113     /** Mark a notable point in a method element.
114     * @param element the element
115     * @param what which point
116     * @exception ElementPrinterInterruptException - see class description
117     */

118     public void markMethod(MethodElement element, int what)
119     throws ElementPrinterInterruptException;
120 }
121
Popular Tags