- java.lang.Object
-
- com.sun.codemodel.JFormatter
-
public final class JFormatter extends Object
This is a utility class for managing indentation and other basic formatting for PrintWriter.
-
-
Constructor Summary
Constructors Constructor Description JFormatter(PrintWriter s)
Creates 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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description JFormatter
b(JVar v)
Cause the JVar to generate source for itselfvoid
close()
Closes this formatter.JFormatter
d(JDeclaration d)
Cause the JDeclaration to generate source for itselfJFormatter
g(JGenerable g)
Cause the JGenerable object to generate source for iteselfJFormatter
g(Collection<? extends JGenerable> list)
ProducesJGenerable
s separated by ','JFormatter
i()
Increment the indentation level.JFormatter
id(String id)
Print an identifierboolean
isPrinting()
Returns true if we are in the printing mode, where we actually produce text.JFormatter
nl()
Print a new line into the streamJFormatter
o()
Decrement the indentation level.JFormatter
p(char c)
Print a char into the streamJFormatter
p(String s)
Print a String into the streamJFormatter
s(JStatement s)
Cause the JStatement to generate source for itselfJFormatter
t(JClass type)
Print a type name.JFormatter
t(JType type)
-
-
-
Constructor Detail
-
JFormatter
public JFormatter(PrintWriter s, String space)
Creates a JFormatter.- Parameters:
s
- PrintWriter to JFormatter to use.space
- Incremental indentation string, similar to tab value.
-
JFormatter
public JFormatter(PrintWriter s, String space, Map<String,String> classNameReplacer)
Creates a JFormatter.- Parameters:
s
- PrintWriter to JFormatter to use.space
- Incremental indentation string, similar to tab value.classNameReplacer
- Class names to replace.
-
JFormatter
public JFormatter(PrintWriter s)
Creates a formatter with default incremental indentations of four spaces.
-
JFormatter
public 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
public JFormatter(Writer w)
Creates a formatter with default incremental indentations of four spaces.
-
-
Method Detail
-
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
public JFormatter o()
Decrement the indentation level.
-
i
public JFormatter i()
Increment the indentation level.
-
p
public JFormatter p(char c)
Print a char into the stream- Parameters:
c
- the char
-
p
public JFormatter p(String s)
Print a String into the stream- Parameters:
s
- the String
-
t
public JFormatter t(JType type)
-
t
public JFormatter t(JClass type)
Print a type name.In the collecting mode we use this information to decide what types to import and what not to.
-
id
public JFormatter id(String id)
Print an identifier
-
nl
public JFormatter nl()
Print a new line into the stream
-
g
public JFormatter g(JGenerable g)
Cause the JGenerable object to generate source for iteself- Parameters:
g
- the JGenerable object
-
g
public JFormatter g(Collection<? extends JGenerable> list)
ProducesJGenerable
s separated by ','
-
d
public JFormatter d(JDeclaration d)
Cause the JDeclaration to generate source for itself- Parameters:
d
- the JDeclaration object
-
s
public JFormatter s(JStatement s)
Cause the JStatement to generate source for itself- Parameters:
s
- the JStatement object
-
b
public JFormatter b(JVar v)
Cause the JVar to generate source for itself- Parameters:
v
- the JVar object
-
-