KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > java > source > engine > SourceRewriter


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.netbeans.modules.java.source.engine;
21
22 import java.io.IOException JavaDoc;
23 import javax.swing.text.BadLocationException JavaDoc;
24
25 /**
26  * Defines methods used by Jackpot's source rewriting service. These methods
27  * treat the source file as a stream , but an interface is used rather than a
28  * java.io.Writer subclass so that non-stream implementations are possible.
29  * For example, if a source file is already represented by a javax.swing.Document,
30  * it may be more efficient to map these methods to that interface.
31  */

32 public interface SourceRewriter {
33
34     /**
35      * Writes the specified string to the source file at the current position.
36      *
37      * @param s the string to write to the source file.
38      */

39     void writeTo(String JavaDoc s) throws IOException JavaDoc, BadLocationException JavaDoc;
40     
41     /**
42      * Skips the text from the current SourceReader position to the specified
43      * offset. Equivalent to java.io.Reader.skip().
44      *
45      * @param in the SourceReader to copy text from.
46      * @param offset the ending offset of the text range to copy.
47      * @throws IOException if the SourceReader's current position is greater
48      * than the offset, or if the offset is outside the
49      * range of the SourceReader's character array.
50      */

51     void skipThrough(SourceReader in, int offset) throws IOException JavaDoc, BadLocationException JavaDoc;
52
53     /**
54      * Copies the contents of a SourceReader from its current position to the
55      * specified source file offset.
56      *
57      * @param in the SourceReader to copy text from.
58      * @param offset the ending offset of the text range to copy.
59      * @throws IOException if the SourceReader's current position is greater
60      * than the offset, or if the offset is outside the
61      * range of the SourceReader's character array.
62      */

63     void copyTo(SourceReader in, int offset) throws IOException JavaDoc;
64
65     /**
66      * Copies the remaining text from a SourceReader to the SourceWriter.
67      *
68      * @param in the SourceReader to copy text from.
69      */

70     void copyRest(SourceReader in) throws IOException JavaDoc;
71
72     /**
73      * Flush and close the SourceRewriter.
74      *
75      * @param save flush the SourceRewriter before closing.
76      */

77     void close(boolean save) throws IOException JavaDoc;
78 }
79
Popular Tags