|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.claritysys.util.FixedWidthStringBuffer
public final class FixedWidthStringBuffer
A StringBuffer which provides for appending fixed-width fields. The underlying StringBuffer can be accessed directly via getStringBuffer () if desired.
If you look into the mechanics of the java.lang.String and java.lang.StringBuffer class, you will understand why it is better to create a new one of these each time you need it as opposed to performing a StringBuffer.setLength (0), which forces re-allocation of the char[].
FixedWidthStringBuffer buf = new FixedWidthStringBuffer (100); buf.append (lastName, 25); buf.append (firstName, 25); System.out.println (buf.toString ()); buf = new FixedWidthStringBuffer (100); ...
String
,
StringBuffer
Constructor Summary | |
---|---|
FixedWidthStringBuffer()
Create a new FixedWidthStringBuffer with an initial size of 64 characters. |
|
FixedWidthStringBuffer(int initialSize)
Create a new FixedWidthStringBuffer with an initial size of 64 characters. |
Method Summary | |
---|---|
void |
append(char ch)
Several accessor methods which delegate directly to the StringBuffer. |
void |
append(java.lang.String s)
Several accessor methods which delegate directly to the StringBuffer. |
void |
append(java.lang.String s,
int width)
Append the given String to the buffer, ensuring it occupies the given width. |
char |
charAt(int pos)
Several accessor methods which delegate directly to the StringBuffer. |
java.lang.StringBuffer |
getStringBuffer()
Retrive the underlying StringBuffer. |
int |
length()
Several accessor methods which delegate directly to the StringBuffer. |
void |
setCharAt(int pos,
char ch)
Set the character at the specified position to ch. |
java.lang.String |
toString()
Return the string from the buffer. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public FixedWidthStringBuffer()
public FixedWidthStringBuffer(int initialSize)
initialSize
- The initial size of the underlying StringBuffer.Method Detail |
---|
public void append(java.lang.String s, int width)
s
- The String to append.width
- The field width.public java.lang.StringBuffer getStringBuffer()
public void append(java.lang.String s)
s
- the string to append.public void append(char ch)
ch
- the char to append.public int length()
public char charAt(int pos)
pos
-
public void setCharAt(int pos, char ch)
pos
- The position in the buffer at which to place the character.ch
- The character to place in the buffer.public java.lang.String toString()
toString
in class java.lang.Object
String
,
StringBuffer
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |