org.glassfish.gmbal.generic
Class Printer

java.lang.Object
  extended by org.glassfish.gmbal.generic.Printer

public class Printer
extends Object

Manages printing of indented source code. Line numbers start at 1 and increase by 1 every time nl() is called. Note that the proper use of this class requires calling nl() at the START of every line (thanks, Harold!), which make indentation much easier to manage. For example, an if statement can be printed as nl().p( "if (expr) {" ).in() ; nl().p( "stmt" ).out() ; nl().p( "} else {" ).in() ; nl().p( "stmt" ).out() ;


Field Summary
static int DEFAULT_INCREMENT
           
 
Constructor Summary
Printer(PrintStream ps)
           
Printer(PrintStream ps, int increment, char padChar)
           
 
Method Summary
 Printer in()
           
 int indent()
           
 Printer nl()
           
 Printer out()
           
 Printer p(Object... args)
           
 Printer p(Object obj)
           
 Printer p(String str)
           
 Printer printBuffer(byte[] buffer)
           
 Printer rj(int size)
          Right-Justify the next call to p so that the total number of characters is at least size.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_INCREMENT

public static final int DEFAULT_INCREMENT
See Also:
Constant Field Values
Constructor Detail

Printer

public Printer(PrintStream ps)

Printer

public Printer(PrintStream ps,
               int increment,
               char padChar)
Method Detail

rj

public Printer rj(int size)
Right-Justify the next call to p so that the total number of characters is at least size. Use leading spaces if necessary to ensure this.


p

public Printer p(String str)

p

public Printer p(Object... args)

p

public Printer p(Object obj)

in

public Printer in()

out

public Printer out()

indent

public int indent()

nl

public Printer nl()

printBuffer

public Printer printBuffer(byte[] buffer)


Copyright © 2005-2015 Oracle Corporation. All Rights Reserved.