public class Printer extends Utility
\n' or
'\r') but always by calling the appropriate method.| Modifier and Type | Field and Description |
|---|---|
protected java.text.BreakIterator |
breaks
The break iterator, if any.
|
protected java.io.StringWriter |
bufferedOut
The string writer, if output is currently being buffered.
|
protected int |
buffering
The number of outstanding invocations to
buffer(). |
protected int |
column
The current column.
|
protected java.io.PrintWriter |
directOut
The original print writer.
|
protected int |
indent
The current indentation level.
|
protected long |
line
The current line.
|
protected java.io.PrintWriter |
out
The current print writer to print to.
|
| Constructor and Description |
|---|
Printer(java.io.OutputStream out)
Create a new printer with the specified output stream.
|
Printer(java.io.PrintWriter out)
Create a new printer with the specified print writer.
|
Printer(java.io.Writer out)
Create a new printer with the specified writer.
|
| Modifier and Type | Method and Description |
|---|---|
Printer |
align(int alignment)
Print whitespace to align the output.
|
Printer |
buffer()
Start buffering the output.
|
void |
close()
Close this printer.
|
int |
column()
Get the current column number.
|
Printer |
column(int column)
Set the current column to the specified number.
|
Printer |
decr()
Decrease the current indentation level.
|
Printer |
escape(char c)
Print the specified character using C escapes.
|
Printer |
escape(char c,
int flags)
Print the specified character with the specified escape sequences.
|
Printer |
escape(java.lang.String s)
Print the specified string using C escapes.
|
Printer |
escape(java.lang.String s,
int flags)
Print the specified string with the specified escape sequences.
|
Printer |
fit()
Ensure that the buffer contents fit onto the current line.
|
Printer |
fit(int align)
Ensure that the buffer contents fit onto the current line.
|
Printer |
fit(java.lang.String prefix)
Ensure that the buffer contents fit onto the current line.
|
Printer |
fitMore()
Ensure that the buffer contents fit onto the current line.
|
Printer |
flush()
Flush the underlying print writer.
|
Printer |
format(Node n)
Format the specified node.
|
Printer |
format(Node n,
boolean locate)
Format the specified node.
|
Printer |
incr()
Increase the current indentation level.
|
Printer |
indent()
Indent.
|
Printer |
indentLess()
Indent one tab stop less than the current indentation level.
|
Printer |
indentMore()
Indent one tab stop more than the current indentation level.
|
int |
level()
Get the current indentation level.
|
long |
line()
Get the current line number.
|
Printer |
line(long line)
Set the current line to the specified number.
|
Printer |
lineUp(Locatable locatable)
Line this printer up at the specified locatable object's
location.
|
Printer |
lineUp(Locatable locatable,
int before)
Line this printer up at the specified number of characters before
the specified locatable object's location,
|
Printer |
loc(Locatable locatable)
Print the location for the specified locatable object.
|
Printer |
p(Attribute attribute)
Print the specified attribute.
|
Printer |
p(char c)
Print the specified character.
|
Printer |
p(Comment comment)
Print the specified comment.
|
Printer |
p(double d)
Print the specified double.
|
Printer |
p(int i)
Print the specified integer.
|
Printer |
p(long l)
Print the specified long.
|
Printer |
p(Node node)
Print the specified node.
|
Printer |
p(java.lang.String s)
Print the specified string.
|
Printer |
pad(long l,
int width)
Print the specified long while also padding it to the specified
width with leading spaces.
|
Printer |
pln()
Print a newline.
|
Printer |
pln(char c)
Print the specified character followed by a newline.
|
Printer |
pln(double d)
Print the specified double followed by a newline.
|
Printer |
pln(int i)
Print the specified integer followed by a newline.
|
Printer |
pln(long l)
Print the specified long followed by a newline.
|
Printer |
pln(java.lang.String s)
Print the specified string followed by a newline.
|
Printer |
reset()
Reset this printer.
|
Printer |
sep()
Print an indented separation comment.
|
Printer |
setLevel(int level)
Set the current indentation level.
|
protected java.lang.String |
stopBuffering()
Reset any buffering.
|
Printer |
unbuffer()
Stop buffering the output.
|
Printer |
wrap(int alignment,
java.lang.String text)
Print the specified text.
|
protected java.text.BreakIterator breaks
protected java.io.PrintWriter out
protected java.io.PrintWriter directOut
protected java.io.StringWriter bufferedOut
protected int buffering
buffer().protected int indent
protected int column
protected long line
public Printer(java.io.OutputStream out)
out - The output stream.public Printer(java.io.Writer out)
out - The writer.public Printer(java.io.PrintWriter out)
out - The print writer to output to.public Printer reset()
public int column()
public Printer column(int column)
column - The new column number.public long line()
public Printer line(long line)
line - The new line number.public Printer buffer()
fit(), fit(String), or fitMore() can ensure
that the output fits onto the current line.
Note that invocations to this method are matched with
invocations to the fit() and fitMore()
methods. In other words, the fit() and
fitMore() methods only have an effect, if they
correspond to the first invocation of this method after (1) this
printer has been created, (2) the last invocation of reset(), (3) the last invocation of unbuffer(), or (4)
the last invocation of any methods printing a newline.protected java.lang.String stopBuffering()
public Printer fit()
buffer()public Printer fit(int align)
align - The alignment.buffer()public Printer fit(java.lang.String prefix)
prefix - The prefix.buffer()public Printer fitMore()
buffer()public Printer unbuffer()
public Printer align(int alignment)
alignment - The number of characters to align at.public int level()
public Printer setLevel(int level)
level - The new indentation level.java.lang.IllegalArgumentException - Signals that the specified level is negative.public Printer incr()
public Printer decr()
public Printer indent()
public Printer indentLess()
public Printer indentMore()
public Printer p(char c)
c - The character to print.public Printer p(int i)
i - The integer to print.public Printer p(long l)
l - The long to print.public Printer p(double d)
d - The double to print.public Printer p(java.lang.String s)
s - The string to print.public Printer pln(char c)
c - The character to print.public Printer pln(int i)
i - The integer to print.public Printer pln(long l)
l - The long to print.public Printer pln(double d)
d - The double to print.public Printer pln(java.lang.String s)
s - The string to print.public Printer pln()
public Printer escape(char c)
c - The character to print.public Printer escape(char c, int flags)
c - The character to print.flags - The escape flags.Utilitiespublic Printer escape(java.lang.String s)
s - The string to print.public Printer escape(java.lang.String s, int flags)
s - The string to print.flags - The escape flags.Utilitiespublic Printer pad(long l, int width)
l - The long to print.width - The width.public Printer sep()
public Printer wrap(int alignment, java.lang.String text)
alignment - The per-line alignment.text - The text.public Printer p(Node node)
null, nothing is printed.node - The node to print.public Printer p(Attribute attribute)
attribute - The attribute.public Printer p(Comment comment)
comment - The comment to print.public Printer format(Node n)
n - The node.public Printer format(Node n, boolean locate)
n - The node.locate - The flag for printing a node's location.public Printer loc(Locatable locatable)
Constants.ORIGINAL
property, that property's locatable value replaces the specified
locatable object. Second, if the actual locatable has a
location, this method prints the file name, a colon, the line
number, another colon, and the column number. If the actual
locatable does not have a location, nothing is printed.locatable - The locatable object.public Printer lineUp(Locatable locatable)
locatable - The locatable object.public Printer lineUp(Locatable locatable, int before)
locatable - The locatable object.before - The number of characters before the object.public Printer flush()
public void close()
Copyright © 2014. All Rights Reserved.