com.caucho.java
Class JavaWriter

java.lang.Object
  extended by java.io.Writer
      extended by com.caucho.java.JavaWriter
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable, java.lang.Appendable
Direct Known Subclasses:
JavaWriterWrapper, JspJavaWriter

public class JavaWriter
extends java.io.Writer

Writing class for generated Java code.


Field Summary
 
Fields inherited from class java.io.Writer
lock
 
Constructor Summary
JavaWriter(WriteStream os)
           
 
Method Summary
 void close()
           
 java.lang.String errorMessage(java.lang.String message)
          Returns the error message with proper line number.
static java.lang.String escapeJavaString(java.lang.String s)
          Prints a Java escaped string
 void flush()
           
 int generateId()
          Generates a unique id.
 void generateSmap()
          Generates the smap file.
 int getDestLine()
          Returns the destination line.
 LineMap getLineMap()
          Gets the line map
 WriteStream getWriteStream()
          Returns the underlying stream.
 void popDepth()
          Pops an indentation depth.
 void print(boolean b)
          Prints a boolean.
 void print(char ch)
          Prints a character.
 void print(int i)
          Prints an integer.
 void print(long l)
          Prints an long
 void print(java.lang.Object o)
          Prints an object.
 void print(java.lang.String s)
          Prints a string
 void printClass(java.lang.Class<?> cl)
          Prints the Java represention of the class
 void printIndent()
          Prints the indentation at the beginning of a line.
 void printJavaChar(char ch)
          Prints a Java escaped string
 void printJavaString(java.lang.String s)
          Prints a Java escaped string
 void printJavaTypeToObject(java.lang.String value, java.lang.Class<?> javaType)
          Converts a java primitive type to a Java object.
 void printJavaTypeToObject(java.lang.String value, JClass javaType)
          Converts a java primitive type to a Java object.
 void println()
          Prints a newline
 void println(boolean v)
          Prints a boolean with a new line
 void println(char ch)
          Prints a character.
 void println(int v)
          Prints an integer with a new line
 void println(long v)
          Prints an long with a new line
 void println(java.lang.Object v)
          Prints an object with a new line
 void println(java.lang.String s)
          Prints a string with a new line
 void printType(java.lang.reflect.Type type)
          Prints the Java representation of the type
 void printVarType(java.lang.reflect.TypeVariable<?> typeVariable)
           
 void pushDepth()
          Pushes an indentation depth.
 void setLineMap(LineMap lineMap)
          Sets the line map
 void setLocation(java.lang.String filename, int line)
          Sets the source filename and line.
 void setPreferLast(boolean isPreferLast)
          True if later source line numbers should override earlier ones
 void write(char[] buffer, int offset, int length)
           
 
Methods inherited from class java.io.Writer
append, append, append, write, write, write, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JavaWriter

public JavaWriter(WriteStream os)
Method Detail

getWriteStream

public WriteStream getWriteStream()
Returns the underlying stream.


getDestLine

public int getDestLine()
Returns the destination line.


setLineMap

public void setLineMap(LineMap lineMap)
Sets the line map


getLineMap

public LineMap getLineMap()
Gets the line map


setLocation

public void setLocation(java.lang.String filename,
                        int line)
                 throws java.io.IOException
Sets the source filename and line.

Parameters:
filename - the filename of the source file.
line - the line of the source file.
Throws:
java.io.IOException

setPreferLast

public void setPreferLast(boolean isPreferLast)
True if later source line numbers should override earlier ones


generateId

public int generateId()
Generates a unique id.


printJavaString

public void printJavaString(java.lang.String s)
                     throws java.io.IOException
Prints a Java escaped string

Throws:
java.io.IOException

printJavaChar

public void printJavaChar(char ch)
                   throws java.io.IOException
Prints a Java escaped string

Throws:
java.io.IOException

escapeJavaString

public static java.lang.String escapeJavaString(java.lang.String s)
Prints a Java escaped string


pushDepth

public void pushDepth()
               throws java.io.IOException
Pushes an indentation depth.

Throws:
java.io.IOException

popDepth

public void popDepth()
              throws java.io.IOException
Pops an indentation depth.

Throws:
java.io.IOException

print

public void print(java.lang.String s)
           throws java.io.IOException
Prints a string

Throws:
java.io.IOException

write

public void write(char[] buffer,
                  int offset,
                  int length)
           throws java.io.IOException
Specified by:
write in class java.io.Writer
Throws:
java.io.IOException

print

public void print(char ch)
           throws java.io.IOException
Prints a character.

Throws:
java.io.IOException

print

public void print(boolean b)
           throws java.io.IOException
Prints a boolean.

Throws:
java.io.IOException

print

public void print(int i)
           throws java.io.IOException
Prints an integer.

Throws:
java.io.IOException

print

public void print(long l)
           throws java.io.IOException
Prints an long

Throws:
java.io.IOException

print

public void print(java.lang.Object o)
           throws java.io.IOException
Prints an object.

Throws:
java.io.IOException

println

public void println(java.lang.String s)
             throws java.io.IOException
Prints a string with a new line

Throws:
java.io.IOException

println

public void println(boolean v)
             throws java.io.IOException
Prints a boolean with a new line

Throws:
java.io.IOException

println

public void println(char ch)
             throws java.io.IOException
Prints a character.

Throws:
java.io.IOException

println

public void println(int v)
             throws java.io.IOException
Prints an integer with a new line

Throws:
java.io.IOException

println

public void println(long v)
             throws java.io.IOException
Prints an long with a new line

Throws:
java.io.IOException

println

public void println(java.lang.Object v)
             throws java.io.IOException
Prints an object with a new line

Throws:
java.io.IOException

println

public void println()
             throws java.io.IOException
Prints a newline

Throws:
java.io.IOException

printClass

public void printClass(java.lang.Class<?> cl)
                throws java.io.IOException
Prints the Java represention of the class

Throws:
java.io.IOException

printType

public void printType(java.lang.reflect.Type type)
               throws java.io.IOException
Prints the Java representation of the type

Throws:
java.io.IOException

printVarType

public void printVarType(java.lang.reflect.TypeVariable<?> typeVariable)
                  throws java.io.IOException
Throws:
java.io.IOException

printJavaTypeToObject

public void printJavaTypeToObject(java.lang.String value,
                                  java.lang.Class<?> javaType)
                           throws java.io.IOException
Converts a java primitive type to a Java object.

Parameters:
value - the java expression to be converted
javaType - the type of the converted expression.
Throws:
java.io.IOException

printJavaTypeToObject

public void printJavaTypeToObject(java.lang.String value,
                                  JClass javaType)
                           throws java.io.IOException
Converts a java primitive type to a Java object.

Parameters:
value - the java expression to be converted
javaType - the type of the converted expression.
Throws:
java.io.IOException

printIndent

public void printIndent()
                 throws java.io.IOException
Prints the indentation at the beginning of a line.

Throws:
java.io.IOException

generateSmap

public void generateSmap()
                  throws java.io.IOException
Generates the smap file.

Throws:
java.io.IOException

errorMessage

public java.lang.String errorMessage(java.lang.String message)
Returns the error message with proper line number.


flush

public void flush()
Specified by:
flush in interface java.io.Flushable
Specified by:
flush in class java.io.Writer

close

public void close()
Specified by:
close in interface java.io.Closeable
Specified by:
close in class java.io.Writer