KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > caucho > java > gen > JavaWriterWrapper


1 /*
2  * Copyright (c) 1998-2006 Caucho Technology -- all rights reserved
3  *
4  * This file is part of Resin(R) Open Source
5  *
6  * Each copy or derived work must preserve the copyright notice and this
7  * notice unmodified.
8  *
9  * Resin Open Source is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * Resin Open Source is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
17  * of NON-INFRINGEMENT. See the GNU General Public License for more
18  * details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with Resin Open Source; if not, write to the
22  *
23  * Free Software Foundation, Inc.
24  * 59 Temple Place, Suite 330
25  * Boston, MA 02111-1307 USA
26  *
27  * @author Scott Ferguson
28  */

29
30 package com.caucho.java.gen;
31
32 import com.caucho.bytecode.JClass;
33 import com.caucho.java.JavaWriter;
34 import com.caucho.java.LineMap;
35 import com.caucho.vfs.WriteStream;
36
37 import java.io.IOException JavaDoc;
38
39 /**
40  * Wrapper
41  */

42 public class JavaWriterWrapper extends JavaWriter {
43   // Write stream for generating the code
44
private JavaWriter _writer;
45
46   public JavaWriterWrapper(JavaWriter writer)
47   {
48     super(null);
49     
50     _writer = writer;
51   }
52
53   /**
54    * Returns the underlying stream.
55    */

56   public WriteStream getWriteStream()
57   {
58     return _writer.getWriteStream();
59   }
60
61   /**
62    * Returns the destination line.
63    */

64   public int getDestLine()
65   {
66     return _writer.getDestLine();
67   }
68
69   /**
70    * Sets the line map
71    */

72   public void setLineMap(LineMap lineMap)
73   {
74     _writer.setLineMap(lineMap);
75   }
76
77   /**
78    * Gets the line map
79    */

80   public LineMap getLineMap()
81   {
82     return _writer.getLineMap();
83   }
84
85   /**
86    * Sets the source filename and line.
87    *
88    * @param filename the filename of the source file.
89    * @param line the line of the source file.
90    */

91   public void setLocation(String JavaDoc filename, int line)
92     throws IOException JavaDoc
93   {
94     _writer.setLocation(filename, line);
95   }
96
97   /**
98    * Generates a unique id.
99    */

100   public int generateId()
101   {
102     return _writer.generateId();
103   }
104
105   /**
106    * Prints a Java escaped string
107    */

108   public void printJavaString(String JavaDoc s)
109     throws IOException JavaDoc
110   {
111     _writer.printJavaString(s);
112   }
113
114   /**
115    * Prints a Java escaped string
116    */

117   public void printJavaChar(char ch)
118     throws IOException JavaDoc
119   {
120     _writer.printJavaChar(ch);
121   }
122
123   /**
124    * Pushes an indentation depth.
125    */

126   public void pushDepth()
127     throws IOException JavaDoc
128   {
129     _writer.pushDepth();
130   }
131
132   /**
133    * Pops an indentation depth.
134    */

135   public void popDepth()
136     throws IOException JavaDoc
137   {
138     _writer.popDepth();
139   }
140
141   /**
142    * Prints a string
143    */

144   public void print(String JavaDoc s)
145     throws IOException JavaDoc
146   {
147     _writer.print(s);
148   }
149
150   /**
151    * Prints a character.
152    */

153   public void print(char ch)
154     throws IOException JavaDoc
155   {
156     _writer.print(ch);
157   }
158
159   /**
160    * Prints a boolean.
161    */

162   public void print(boolean b)
163     throws IOException JavaDoc
164   {
165     _writer.print(b);
166   }
167
168   /**
169    * Prints an integer.
170    */

171   public void print(int i)
172     throws IOException JavaDoc
173   {
174     _writer.print(i);
175   }
176
177   /**
178    * Prints an long
179    */

180   public void print(long l)
181     throws IOException JavaDoc
182   {
183     _writer.print(l);
184   }
185
186   /**
187    * Prints an object.
188    */

189   public void print(Object JavaDoc o)
190     throws IOException JavaDoc
191   {
192     _writer.print(o);
193   }
194
195   /**
196    * Prints a string with a new line
197    */

198   public void println(String JavaDoc s)
199     throws IOException JavaDoc
200   {
201     _writer.println(s);
202   }
203
204   /**
205    * Prints a boolean with a new line
206    */

207   public void println(boolean v)
208     throws IOException JavaDoc
209   {
210     _writer.println(v);
211   }
212
213   /**
214    * Prints a character.
215    */

216   public void println(char ch)
217     throws IOException JavaDoc
218   {
219     _writer.println(ch);
220   }
221
222   /**
223    * Prints an integer with a new line
224    */

225   public void println(int v)
226     throws IOException JavaDoc
227   {
228     _writer.println(v);
229   }
230
231   /**
232    * Prints an long with a new line
233    */

234   public void println(long v)
235     throws IOException JavaDoc
236   {
237     _writer.println(v);
238   }
239
240   /**
241    * Prints an object with a new line
242    */

243   public void println(Object JavaDoc v)
244     throws IOException JavaDoc
245   {
246     _writer.println(v);
247   }
248
249   /**
250    * Prints a newline
251    */

252   public void println()
253     throws IOException JavaDoc
254   {
255     _writer.println();
256   }
257   
258   /**
259    * Prints the Java represention of the class
260    */

261   public void printClass(Class JavaDoc cl)
262     throws IOException JavaDoc
263   {
264     _writer.printClass(cl);
265   }
266   
267   /**
268    * Converts a java primitive type to a Java object.
269    *
270    * @param value the java expression to be converted
271    * @param javaType the type of the converted expression.
272    */

273   public void printJavaTypeToObject(String JavaDoc value, Class JavaDoc javaType)
274     throws IOException JavaDoc
275   {
276     _writer.printJavaTypeToObject(value, javaType);
277   }
278   
279   /**
280    * Converts a java primitive type to a Java object.
281    *
282    * @param value the java expression to be converted
283    * @param javaType the type of the converted expression.
284    */

285   public void printJavaTypeToObject(String JavaDoc value, JClass javaType)
286     throws IOException JavaDoc
287   {
288     _writer.printJavaTypeToObject(value, javaType);
289   }
290
291   /**
292    * Prints the indentation at the beginning of a line.
293    */

294   public void printIndent()
295     throws IOException JavaDoc
296   {
297     _writer.printIndent();
298   }
299
300   /**
301    * Returns the error message with proper line number.
302    */

303   public String JavaDoc errorMessage(String JavaDoc message)
304   {
305     return _writer.errorMessage(message);
306   }
307 }
308
Popular Tags