| Modifier and Type | Class and Description |
|---|---|
| private static enum | |
| pack-priv class | JFormatter.
Used during the optimization of class imports. |
| Modifier and Type | Field and Description |
|---|---|
| private boolean | |
| private final Map | |
| pack-priv static final char | CLOSE_TYPE_ARGS
Special character token we use to differentiate '>' as an operator and '>' as the end of the type arguments. |
| private HashMap | |
| private HashSet | importedClasses
set of imported types (including package java types, eventhough we won't generate imports for them) |
| private int | indentLevel
Current number of indentation strings to print |
| private final String | indentSpace
String to be used for each indentation. |
| private JPackage | |
| private char | |
| private JFormatter. | mode
The current running mode. |
| private final PrintWriter | pw
Stream associated with this JFormatter |
| Access | Constructor and Description |
|---|---|
| public | JFormatter(PrintWriter
PrintWriter to JFormatter to use. s, String Incremental indentation string, similar to tab value. space)Creates a JFormatter. |
| public | JFormatter(PrintWriter
PrintWriter to JFormatter to use. s, String Incremental indentation string, similar to tab value. space, Map<String, String> Class names to replace. classNameReplacer)Creates a JFormatter. |
| public | |
| 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. |
| public |
| Modifier and Type | Method and Description |
|---|---|
| public JFormatter | |
| public void | |
| public JFormatter | |
| public JFormatter | |
| public JFormatter | |
| public JFormatter | |
| public JFormatter | |
| public boolean | |
| private boolean | |
| public JFormatter | |
| public JFormatter | |
| public JFormatter | |
| public JFormatter | |
| private String | |
| public JFormatter | |
| private void | |
| private boolean | Returns: true if an import statement should be suppressed, false otherwiseJType that may or may not have an import clazz, JClass JType that is the current class being processed c)determine if an import statement should be supressed |
| public JFormatter | |
| public JFormatter | |
| pack-priv void |
| atBeginningOfLine | back to summary |
|---|---|
| private boolean atBeginningOfLine | |
| classNameReplacer | back to summary |
|---|---|
| private final Map<String, String> classNameReplacer | |
| CLOSE_TYPE_ARGS | back to summary |
|---|---|
| pack-priv static final char CLOSE_TYPE_ARGS Special character token we use to differentiate '>' as an operator and '>' as the end of the type arguments. The former uses '>' and it requires a preceding whitespace. The latter uses this, and it does not have a preceding whitespace. | |
| collectedReferences | back to summary |
|---|---|
| private HashMap<String, JFormatter. | |
| importedClasses | back to summary |
|---|---|
| private HashSet<JClass> importedClasses set of imported types (including package java types, eventhough we won't generate imports for them) | |
| indentLevel | back to summary |
|---|---|
| private int indentLevel Current number of indentation strings to print | |
| indentSpace | back to summary |
|---|---|
| private final String indentSpace String to be used for each indentation. Defaults to four spaces. | |
| javaLang | back to summary |
|---|---|
| private JPackage javaLang | |
| lastChar | back to summary |
|---|---|
| private char lastChar | |
| mode | back to summary |
|---|---|
| private JFormatter. The current running mode. Set to PRINTING so that a casual client can use a formatter just like before. | |
| pw | back to summary |
|---|---|
| private final PrintWriter pw Stream associated with this JFormatter | |
| JFormatter | back to summary |
|---|---|
| public JFormatter(PrintWriter s, String space) Creates a JFormatter.
| |
| JFormatter | back to summary |
|---|---|
| public JFormatter(PrintWriter s, String space, Map<String, String> classNameReplacer) Creates a JFormatter.
| |
| JFormatter | back to summary |
|---|---|
| public JFormatter(PrintWriter s) Creates a formatter with default incremental indentations of four spaces. | |
| JFormatter | back to summary |
|---|---|
| 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 | back to summary |
|---|---|
| public JFormatter(Writer w) Creates a formatter with default incremental indentations of four spaces. | |
| b | back to summary |
|---|---|
| public JFormatter b(JVar v) Cause the JVar to generate source for itself
| |
| close | back to summary |
|---|---|
| public void close() Closes this formatter. | |
| d | back to summary |
|---|---|
| public JFormatter d(JDeclaration d) Cause the JDeclaration to generate source for itself
| |
| g | back to summary |
|---|---|
| public JFormatter g(JGenerable g) Cause the JGenerable object to generate source for iteself
| |
| g | back to summary |
|---|---|
| public JFormatter g(Collection<? extends JGenerable> list) Produces | |
| i | back to summary |
|---|---|
| public JFormatter i() Increment the indentation level. | |
| id | back to summary |
|---|---|
| public JFormatter id(String id) Print an identifier | |
| isPrinting | back to summary |
|---|---|
| public boolean isPrinting() Returns true if we are in the printing mode, where we actually produce text. The other mode is the "collecting mode' | |
| needSpace | back to summary |
|---|---|
| private boolean needSpace(char c1, char c2) | |
| nl | back to summary |
|---|---|
| public JFormatter nl() Print a new line into the stream | |
| o | back to summary |
|---|---|
| public JFormatter o() Decrement the indentation level. | |
| p | back to summary |
|---|---|
| public JFormatter p(char c) Print a char into the stream
| |
| p | back to summary |
|---|---|
| public JFormatter p(String s) Print a String into the stream
| |
| renameClassName | back to summary |
|---|---|
| private String renameClassName(String fullName) | |
| s | back to summary |
|---|---|
| public JFormatter s(JStatement s) Cause the JStatement to generate source for itself
| |
| spaceIfNeeded | back to summary |
|---|---|
| private void spaceIfNeeded(char c) | |
| supressImport | back to summary |
|---|---|
| private boolean supressImport(JClass clazz, JClass c) determine if an import statement should be supressed | |
| t | back to summary |
|---|---|
| public JFormatter t(JType type) | |
| t | back to summary |
|---|---|
| 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. | |
| write | back to summary |
|---|---|
| pack-priv void write(JDefinedClass c) Generates the whole source code out of the specified class. | |
| Modifier and Type | Field and Description |
|---|---|
| public static final JFormatter. | COLLECTING
Collect all the type names and identifiers. |
| public static final JFormatter. | PRINTING
Print the actual source code. |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static JFormatter. | |
| public static JFormatter. |
| COLLECTING | back to summary |
|---|---|
| public static final JFormatter. Collect all the type names and identifiers. In this mode we don't actually generate anything. | |
| PRINTING | back to summary |
|---|---|
| public static final JFormatter. Print the actual source code. | |
| Mode | back to summary |
|---|---|
| private Mode() | |
| valueOf | back to summary |
|---|---|
| public static JFormatter. | |
| values | back to summary |
|---|---|
| public static JFormatter. | |
JClasses whose short name is the same.
| Modifier and Type | Field and Description |
|---|---|
| private final ArrayList | |
| private boolean | id
true if this name is used as an identifier (like a variable name.) |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public boolean | collisions(JDefinedClass enclosingClass)
Returns true if the symbol represented by the short name is "importable". |
| public List | |
| public boolean | |
| public void |
| classes | back to summary |
|---|---|
| private final ArrayList<JClass> classes | |
| id | back to summary |
|---|---|
| private boolean id true if this name is used as an identifier (like a variable name.) | |
| ReferenceList | back to summary |
|---|---|
| pack-priv ReferenceList() | |
| add | back to summary |
|---|---|
| public void add(JClass clazz) | |
| collisions | back to summary |
|---|---|
| public boolean collisions(JDefinedClass enclosingClass) Returns true if the symbol represented by the short name is "importable". | |
| getClasses | back to summary |
|---|---|
| public List | |
| isId | back to summary |
|---|---|
| public boolean isId() Return true iff this is strictly an id, meaning that there are no collisions with type names. | |
| setId | back to summary |
|---|---|
| public void setId(boolean value) | |