|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectlp.struct.util.LpBuffer
public class LpBuffer
A convenience class that makes it possible to work with classes inheriting
from a LpPrinter for writing into a string buffer instead of a
writer. The contents of the buffer are available through the methods of this
character sequence.
LpPrinter,
LpPrettyPrinter.getBuffer(),
EvolpPrettyPrinter.getBuffer(),
LpHtmlPrinter.getBuffer(),
LpEncoder.getBuffer()| Field Summary | |
|---|---|
private StringBuffer |
buffer
The delegate for manipulating a mutable string. |
private LpPrinter<StringWriter> |
printer
The LpPrinter used to append LpStructureUnits to
buffer. |
| Constructor Summary | |
|---|---|
LpBuffer(LpPrinter<StringWriter> printer)
Creates a new instance of LpBuffer that uses printer to
append usual objects and also LpStructureUnits to a string
buffer. |
|
| Method Summary | |
|---|---|
LpBuffer |
append(char c)
Appends the specified character to this LpBuffer. |
LpBuffer |
append(CharSequence csq)
Appends the specified character sequence to this LpBuffer. |
LpBuffer |
append(CharSequence csq,
int start,
int end)
Appends a subsequence of the specified character sequence to this LpBuffer. |
LpBuffer |
append(LpStructureUnit unit)
Appends a textual representation of unit to this
LpBuffer. |
String |
asString(LpStructureUnit unit)
The call to this method is identical to calling reset(); append(unit); return toString(); |
char |
charAt(int index)
Returns the char value in this sequence at the specified index. |
int |
length()
Returns the length (character count) of this character sequence. |
void |
reset()
Deletes all characters in this sequence. |
CharSequence |
subSequence(int start,
int end)
Returns a subsequence of the character sequence represented by this object. |
String |
toString()
Returns the contents of this character sequence as a string. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
private final LpPrinter<StringWriter> printer
LpPrinter used to append LpStructureUnits to
buffer.
private final StringBuffer buffer
| Constructor Detail |
|---|
public LpBuffer(LpPrinter<StringWriter> printer)
LpBuffer that uses printer to
append usual objects and also LpStructureUnits to a string
buffer.
printer - will be used to append usual objects and also
LpStructureUnits to a string buffer. Shouldn't be manipulated by
any other object.| Method Detail |
|---|
public LpBuffer append(CharSequence csq)
LpBuffer.
append in interface Appendablecsq - the CharSequence that should be appended to this
LpBuffer
public LpBuffer append(CharSequence csq,
int start,
int end)
LpBuffer.
append in interface Appendablecsq - the character sequence from which a subsequence will be
appended. If csq is null, then characters
will be appended as if csq contained the four
characters "null".start - the index of the first character in the subsequenceend - the index of the character following the last character in the
subsequence
public LpBuffer append(char c)
LpBuffer.
append in interface Appendablec - the character to append
public int length()
length in interface CharSequenceCharSequence.length()public char charAt(int index)
char value in this sequence at the specified index.
charAt in interface CharSequenceindex - the index of the character that should be returned. Indexing
starts at 0, highest allowed value is length() - 1
IndexOutOfBoundsException - if index if negative or greater
or equal to length()length(),
CharSequence.charAt(int)
public CharSequence subSequence(int start,
int end)
subSequence in interface CharSequencestart - the start index (inclusive)end - the end index (exclusive)
IndexOutOfBoundsException - if either of the indexes is negative,
or end is greater than length(), or start is
greater than endCharSequence.subSequence(int, int)public void reset()
public LpBuffer append(LpStructureUnit unit)
unit to this
LpBuffer. The string is constructed in the #visit()
methods of this class. If unit is null, the string "null"
is appended.
unit - the LpStructureUnit that should be represented
as a string and appended to this character sequence
public String asString(LpStructureUnit unit)
reset(); append(unit); return toString();
unit - the LpStructureUnit that should be represented
as a string and appended to this character sequencepublic String toString()
toString in interface CharSequencetoString in class Object
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||