@NotThreadSafe public class JFormatter extends Object implements Closeable
| Modifier and Type | Field and Description |
|---|---|
static String |
DEFAULT_INDENT_SPACE |
| Constructor and Description |
|---|
JFormatter(PrintWriter aPW)
Creates a formatter with default incremental indentations of four spaces.
|
JFormatter(PrintWriter aPW,
String sIndentSpace)
Creates a JFormatter.
|
JFormatter(Writer aWriter)
Creates a formatter with default incremental indentations of four spaces.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes this formatter.
|
static boolean |
containsErrorTypes(JDefinedClass c) |
JFormatter |
declaration(IJDeclaration d)
Cause the JDeclaration to generate source for itself
|
JFormatter |
generable(Collection<? extends IJGenerable> list)
Produces
IJGenerables separated by ',' |
JFormatter |
generable(IJGenerable g)
Cause the JGenerable object to generate source for iteself
|
JFormatter |
id(String id)
Print an identifier
|
JFormatter |
indent()
Increment the indentation level.
|
boolean |
isPrinting() |
JFormatter |
newline()
Print a new line into the stream
|
JFormatter |
outdent()
Decrement the indentation level.
|
JFormatter |
print(char c)
Print a char into the stream
|
JFormatter |
print(String s)
Print a String into the stream
|
JFormatter |
statement(IJStatement s)
Cause the JStatement to generate source for itself
|
JFormatter |
type(AbstractJClass aType)
Print a type name.
|
JFormatter |
type(AbstractJType aType) |
JFormatter |
var(JVar v)
Cause the
JVar to generate source for itself |
public static final String DEFAULT_INDENT_SPACE
public JFormatter(@Nonnull PrintWriter aPW, @Nonnull String sIndentSpace)
aPW - PrintWriter to JFormatter to use. May not be
null.sIndentSpace - Incremental indentation string, similar to tab value. May not be
null.public JFormatter(@Nonnull PrintWriter aPW)
aPW - The PrintWriter to usepublic JFormatter(@Nonnull Writer aWriter)
aWriter - The Writer to be wrapped in a PrintWriterpublic void close()
close in interface Closeableclose in interface AutoCloseablepublic boolean isPrinting()
true if we are in the printing mode, where we actually
produce text. The other mode is the "collecting mode'@Nonnull public JFormatter outdent()
@Nonnull public JFormatter indent()
@Nonnull public JFormatter print(char c)
c - the char@Nonnull public JFormatter print(@Nonnull String s)
s - the String@Nonnull public JFormatter type(@Nonnull AbstractJType aType)
@Nonnull public JFormatter type(@Nonnull AbstractJClass aType)
In the collecting mode we use this information to decide what types to import and what not to.
aType - Type to be emitted@Nonnull public JFormatter id(@Nonnull String id)
id - identifier@Nonnull public JFormatter newline()
@Nonnull public JFormatter generable(@Nonnull IJGenerable g)
g - the JGenerable object@Nonnull public JFormatter generable(@Nonnull Collection<? extends IJGenerable> list)
IJGenerables separated by ','list - List of IJGenerable objects that will be separated by a
comma@Nonnull public JFormatter declaration(@Nonnull IJDeclaration d)
d - the JDeclaration object@Nonnull public JFormatter statement(@Nonnull IJStatement s)
s - the JStatement object@Nonnull public JFormatter var(@Nonnull JVar v)
JVar to generate source for itselfv - the JVar objectpublic static boolean containsErrorTypes(@Nonnull JDefinedClass c)
Copyright © 2013–2015 Philip Helger. All rights reserved.