Package com.sun.codemodel
Class JFormatter
java.lang.Object
com.sun.codemodel.JFormatter
This is a utility class for managing indentation and other basic
formatting for PrintWriter.
-
Constructor Summary
ConstructorDescriptionCreates a formatter with default incremental indentations of four spaces.JFormatter
(PrintWriter s, String space) Creates a JFormatter.JFormatter
(PrintWriter s, String space, Map<String, String> classNameReplacer) Creates a JFormatter.JFormatter
(PrintWriter s, Map<String, String> classNameReplacer) Creates a formatter with default incremental indentations of four spaces and replaces the class names in classNameReplacer.JFormatter
(Writer w) Creates a formatter with default incremental indentations of four spaces. -
Method Summary
Modifier and TypeMethodDescriptionCause the JVar to generate source for itselfvoid
close()
Closes this formatter.d
(JDeclaration d) Cause the JDeclaration to generate source for itselfg
(JGenerable g) Cause the JGenerable object to generate source for iteselfg
(Collection<? extends JGenerable> list) ProducesJGenerable
s separated by ','i()
Increment the indentation level.Print an identifierboolean
Returns true if we are in the printing mode, where we actually produce text.nl()
Print a new line into the streamo()
Decrement the indentation level.p
(char c) Print a char into the streamPrint a String into the streams
(JStatement s) Cause the JStatement to generate source for itselfPrint a type name.
-
Constructor Details
-
JFormatter
Creates a JFormatter.- Parameters:
s
- PrintWriter to JFormatter to use.space
- Incremental indentation string, similar to tab value.
-
JFormatter
Creates a JFormatter.- Parameters:
s
- PrintWriter to JFormatter to use.space
- Incremental indentation string, similar to tab value.classNameReplacer
- Class names to replace.
-
JFormatter
Creates a formatter with default incremental indentations of four spaces. -
JFormatter
Creates a formatter with default incremental indentations of four spaces and replaces the class names in classNameReplacer. -
JFormatter
Creates a formatter with default incremental indentations of four spaces.
-
-
Method Details
-
close
public void close()Closes this formatter. -
isPrinting
public boolean isPrinting()Returns true if we are in the printing mode, where we actually produce text. The other mode is the "collecting mode' -
o
Decrement the indentation level. -
i
Increment the indentation level. -
p
Print a char into the stream- Parameters:
c
- the char
-
p
Print a String into the stream- Parameters:
s
- the String
-
t
-
t
Print a type name.In the collecting mode we use this information to decide what types to import and what not to.
-
id
Print an identifier -
nl
Print a new line into the stream -
g
Cause the JGenerable object to generate source for iteself- Parameters:
g
- the JGenerable object
-
g
ProducesJGenerable
s separated by ',' -
d
Cause the JDeclaration to generate source for itself- Parameters:
d
- the JDeclaration object
-
s
Cause the JStatement to generate source for itself- Parameters:
s
- the JStatement object
-
b
Cause the JVar to generate source for itself- Parameters:
v
- the JVar object
-