KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > aspectj > ajde > internal > StreamPrintWriter


1
2 /* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
3  *
4  * This file is part of the IDE support for the AspectJ(tm)
5  * programming language; see http://aspectj.org
6  *
7  * The contents of this file are subject to the Mozilla Public License
8  * Version 1.1 (the "License"); you may not use this file except in
9  * compliance with the License. You may obtain a copy of the License at
10  * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
11  *
12  * Software distributed under the License is distributed on an "AS IS" basis,
13  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
14  * for the specific language governing rights and limitations under the
15  * License.
16  *
17  * The Original Code is AspectJ.
18  *
19  * The Initial Developer of the Original Code is Xerox Corporation. Portions
20  * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation.
21  * All Rights Reserved.
22  *
23  * Contributor(s):
24  */

25  
26 package org.aspectj.ajde.internal;
27
28 import java.io.*;
29
30 /**
31  * Used for writing converting text written to an output stream into
32  * a string.
33  *
34  * @author Mik Kersten
35  */

36 public class StreamPrintWriter extends PrintWriter {
37     private String JavaDoc contents = "";
38
39     public StreamPrintWriter(Writer out) {
40         super(out);
41     }
42
43     public String JavaDoc getContents() {
44         return contents;
45     }
46
47     public void flushBuffer() {
48         contents = "";
49         super.flush();
50     }
51
52     public void print(char x) {
53         contents += x + "\n";
54     }
55
56     public void print(char[] x) {
57         contents += new String JavaDoc( x );
58     }
59
60     public void print(int x) {
61         contents += x;
62     }
63
64     public void print(String JavaDoc x) {
65         contents += x;
66     }
67
68     public void println(char x) {
69         contents += x + "\n";
70     }
71
72     public void println(char[] x) {
73         contents += new String JavaDoc( x ) + "\n";
74     }
75
76     public void println(int x) {
77         contents += x + "\n";
78     }
79
80     public void println(String JavaDoc x) {
81         contents += x + "\n";
82     }
83
84     public void write( byte[] x ) {
85         contents += new String JavaDoc( x );
86     }
87
88     public void write( byte[] x, int i1, int i2 ) {
89         StringWriter writer = new StringWriter();
90         String JavaDoc s = new String JavaDoc( x );
91         writer.write( s.toCharArray(), i1, i2 );
92         contents += writer.getBuffer().toString();
93     }
94
95     public void write( int c ) {
96         contents += c;
97     }
98
99     public void write( String JavaDoc s ) {
100         contents += s;
101     }
102
103     public void write( String JavaDoc s, int i1, int i2 ) {
104         contents += s;
105     }
106 }
107
Popular Tags