|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.ibm.are.common.AlignableString
public class AlignableString
The AlignableString
class is a simple way to create a Java String that can be left, center,
or right aligned. Alignment is achieved by specifying a fixed size for the string, and a character to
use to pad the string if its length is less than the specified fixed size.. The default pad character
is a space. This class is very useful for creating tables of strings where each column has a fixed
width, but the length of the strings within the columns may vary.
Field Summary | |
---|---|
protected java.lang.String |
alignedString
The aligned string |
static int |
CENTER_ALIGN
Center align the string |
static java.lang.String |
COPYRIGHT
Copyright for class bytecode |
static int |
LEFT_ALIGN
Left align the string |
static int |
RIGHT_ALIGN
Right align the string |
Constructor Summary | |
---|---|
AlignableString(java.lang.String str,
int totalSize,
int alignment)
Constructs an AlignableString object with the specified string
text, total size, and alignment. |
|
AlignableString(java.lang.String str,
int totalSize,
int alignment,
char padChar)
Constructs an AlignableString object with the specified string
text, total size, alignment, and pad character. |
Method Summary | |
---|---|
java.lang.String |
getString()
Retrieves the aligned string |
int |
length()
Retrieves the length, in characters, of the aligned string. |
java.lang.String |
toString()
Retrieves the aligned string. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String COPYRIGHT
public static final int LEFT_ALIGN
public static final int RIGHT_ALIGN
public static final int CENTER_ALIGN
protected java.lang.String alignedString
Constructor Detail |
---|
public AlignableString(java.lang.String str, int totalSize, int alignment)
AlignableString
object with the specified string
text, total size, and alignment. The pad character will default to the space character.
str
- The text string to aligntotalSize
- The total number of characters, i.e. length, of the alignable stringalignment
- How to align the string. Must be LEFT_ALIGN
, CENTER_ALIGN
, or RIGHT_ALIGN
public AlignableString(java.lang.String str, int totalSize, int alignment, char padChar)
AlignableString
object with the specified string
text, total size, alignment, and pad character.
str
- The text string to aligntotalSize
- The total number of characters, i.e. length, of the alignable stringalignment
- How to align the string. Must be LEFT_ALIGN
, CENTER_ALIGN
, or RIGHT_ALIGN
padChar
- The character used to pad the string so that its length equals totalSize
Method Detail |
---|
public java.lang.String getString()
public int length()
public java.lang.String toString()
getString()
method.
toString
in class java.lang.Object
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |