public class StringBackend extends Object implements Backend
Backend
which appends all output to a StringBuffer.
The mark(Object o)
method does nothing in this
implementation. There is a method count()
which returns
the number of characters written by this so far.
The method getString()
gets the output written so far.Modifier and Type | Field and Description |
---|---|
protected int |
initOutLength |
protected int |
lineWidth |
protected StringBuffer |
out |
Constructor and Description |
---|
StringBackend(int lineWidth)
Create a new StringBackend.
|
StringBackend(StringBuffer sb,
int lineWidth)
Create a new StringBackend.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes this backend
|
int |
count()
Returns the number of characters written through this backend.
|
void |
flush()
Flushes any buffered output
|
String |
getString()
Returns the accumulated output
|
int |
lineWidth()
Returns the available space per line
|
void |
mark(Object o)
Gets called to record a
mark() call in the input. |
int |
measure(String s)
Returns the space required to print the String
s |
void |
newLine()
Start a new line.
|
void |
print(String s)
Append a String
s to the output. |
protected StringBuffer out
protected int initOutLength
protected int lineWidth
public StringBackend(StringBuffer sb, int lineWidth)
sb
.public StringBackend(int lineWidth)
public void print(String s) throws IOException
s
to the output. s
contains no newlines.print
in interface Backend
IOException
public void newLine() throws IOException
newLine
in interface Backend
IOException
public void close() throws IOException
close
in interface Backend
IOException
public void flush() throws IOException
flush
in interface Backend
IOException
public void mark(Object o)
mark()
call in the input.public int count()
public int lineWidth()
public int measure(String s)
s
public String getString()