org.mule.devkit.model.code
Class Formatter

java.lang.Object
  extended by org.mule.devkit.model.code.Formatter

public final class Formatter
extends Object

This is a utility class for managing indentation and other basic formatting for PrintWriter.


Constructor Summary
Formatter(PrintWriter s)
          Creates a formatter with default incremental indentations of four spaces.
Formatter(PrintWriter s, String space)
          Creates a Formatter.
Formatter(Writer w)
          Creates a formatter with default incremental indentations of four spaces.
 
Method Summary
 Formatter b(GeneratedVariable v)
          Cause the Variable to generate source for itself
 void close()
          Closes this formatter.
 Formatter d(Declaration d)
          Cause the Declaration to generate source for itself
 Formatter g(Collection<? extends Generable> list)
          Produces Generables separated by ','
 Formatter g(Generable g)
          Cause the Generable object to generate source for iteself
 Formatter i()
          Increment the indentation level.
 Formatter id(String id)
          Print an identifier
 boolean isPrinting()
          Returns true if we are in the printing mode, where we actually produce text.
 Formatter nl()
          Print a new line into the stream
 Formatter o()
          Decrement the indentation level.
 Formatter p(char c)
          Print a char into the stream
 Formatter p(String s)
          Print a String into the stream
 Formatter s(Statement s)
          Cause the Statement to generate source for itself
 Formatter t(Type type)
           
 Formatter t(TypeReference type)
          Print a type name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Formatter

public Formatter(PrintWriter s,
                 String space)
Creates a Formatter.

Parameters:
s - PrintWriter to Formatter to use.
space - Incremental indentation string, similar to tab value.

Formatter

public Formatter(PrintWriter s)
Creates a formatter with default incremental indentations of four spaces.


Formatter

public Formatter(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 Formatter o()
Decrement the indentation level.


i

public Formatter i()
Increment the indentation level.


p

public Formatter p(char c)
Print a char into the stream

Parameters:
c - the char

p

public Formatter p(String s)
Print a String into the stream

Parameters:
s - the String

t

public Formatter t(Type type)

t

public Formatter t(TypeReference 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 Formatter id(String id)
Print an identifier


nl

public Formatter nl()
Print a new line into the stream


g

public Formatter g(Generable g)
Cause the Generable object to generate source for iteself

Parameters:
g - the Generable object

g

public Formatter g(Collection<? extends Generable> list)
Produces Generables separated by ','


d

public Formatter d(Declaration d)
Cause the Declaration to generate source for itself

Parameters:
d - the Declaration object

s

public Formatter s(Statement s)
Cause the Statement to generate source for itself

Parameters:
s - the Statement object

b

public Formatter b(GeneratedVariable v)
Cause the Variable to generate source for itself

Parameters:
v - the Variable object


Copyright © 2010-2013 MuleSoft, Inc.. All Rights Reserved.