KickJava   Java API By Example, From Geeks To Geeks.

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


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 import java.io.PrintWriter JavaDoc;
23
24 /** A trivial implementation of <code>ElementPrinter</code>.
25 * It is backed by the supplied <code>PrintWriter</code>,
26 * and by default just prints the text as supplied to that print
27 * writer.
28 * It does nothing for any of the mark methods, and never
29 * throws {@link ElementPrinterInterruptException}.
30 * Subclasses may use this as an adapter for <code>ElementPrinter</code>,
31 * typically providing a nontrivial body for one of the mark methods.
32 *
33 * @author Petr Hamernik
34 */

35 public class DefaultElementPrinter implements ElementPrinter {
36     /** The underlaying writer. */
37     private PrintWriter JavaDoc writer;
38
39     /** Create a printer.
40     * @param writer the writer to send printed text to
41     */

42     public DefaultElementPrinter(PrintWriter JavaDoc writer) {
43         this.writer = writer;
44     }
45
46     /* Prints the given text.
47     * @param text The text to write
48     */

49     public void print(String JavaDoc text) {
50         writer.print(text);
51     }
52
53     /* Prints the line. New-line character '\n' should be added.
54     * @param text The line to write
55     */

56     public void println(String JavaDoc text) {
57         writer.println(text);
58     }
59
60     /* Marks the notable point of the class element.
61     * @param element The element.
62     * @param what The kind of the event. It must be one of the integer
63     * constants from this interface
64     */

65     public void markClass(ClassElement element, int what) throws ElementPrinterInterruptException {
66     }
67
68     /* Marks the notable point of the initializer element.
69     * @param element The element.
70     * @param what The kind of the event. It must be one of the integer
71     * constants from this interface
72     */

73     public void markInitializer(InitializerElement element, int what) throws ElementPrinterInterruptException {
74     }
75
76     /* Marks the notable point of the field element.
77     * @param element The element.
78     * @param what The kind of the event. It must be one of the integer
79     * constants from this interface
80     */

81     public void markField(FieldElement element, int what) throws ElementPrinterInterruptException {
82     }
83
84     /* Marks the notable point of the constructor element.
85     * @param element The element.
86     * @param what The kind of the event. It must be one of the integer
87     * constants from this interface
88     */

89     public void markConstructor(ConstructorElement element, int what) throws ElementPrinterInterruptException {
90     }
91
92     /* Marks the notable point of the method element.
93     * @param element The element.
94     * @param what The kind of the event. It must be one of the integer
95     * constants from this interface
96     */

97     public void markMethod(MethodElement element, int what) throws ElementPrinterInterruptException {
98     }
99 }
100
Popular Tags