|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectAlign
public final class Align
A class to right-align, center-align, or left-align an expression in a field of a specified width. The expression may be a String, int or double, The expression is converted to a String (if not already a String) and padded with the correct number of spaces to make its length equal to the specified width. Note: If the width specified is too small to accomodate the entire expression, then the width is ignored and the expression is neither padded nor truncated.
Constructor Summary | |
---|---|
Align()
|
Method Summary | |
---|---|
static java.lang.String |
center(double number,
int width)
Center-align a double expression in a field of a specified width |
static java.lang.String |
center(double number,
int width,
int places)
Round a double to a specified number of decimal places and center it in a field of a specified width. |
static java.lang.String |
center(int number,
int width)
Center-align an int in a field of a specified width |
static java.lang.String |
center(java.lang.String aString,
int width)
Center-align a string in a field of a specified width |
static java.lang.String |
currency(double number,
int width)
Formats a double expression as US currency and right-aligns it in a field of a specified width. |
static java.lang.String |
left(double number,
int width)
Left-align a double expression in a field of a specified width |
static java.lang.String |
left(double number,
int width,
int places)
Round a double to a specified number of decimal places and left-align it in a field of a specified width. |
static java.lang.String |
left(int number,
int width)
Left-align an int in a field of a specified width |
static java.lang.String |
left(java.lang.String aString,
int width)
Left-align a string in a field of a specified width |
static java.lang.String |
right(double number,
int width)
Right-align a double expression in a field of a specified width |
static java.lang.String |
right(double number,
int width,
int places)
Round a double to a specified number of decimal places and right-align it in a field of a specified width. |
static java.lang.String |
right(int number,
int width)
Right-align an int in a field of a specified width |
static java.lang.String |
right(java.lang.String aString,
int width)
Right-align a string in a field of a specified width |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Align()
Method Detail |
---|
public static java.lang.String right(java.lang.String aString, int width)
aString
- the string to be alignedwidth
- the width (number of spaces) of the field
public static java.lang.String left(java.lang.String aString, int width)
aString
- the string to be alignedwidth
- the width (number of spaces) of the field
public static java.lang.String center(java.lang.String aString, int width)
aString
- the string to be alignedwidth
- the width (number of spaces) of the field
public static java.lang.String right(int number, int width)
number
- the int to be alignedwidth
- the width (number of spaces) of the field
public static java.lang.String left(int number, int width)
number
- the int to be alignedwidth
- the width (number of spaces) of the field
public static java.lang.String center(int number, int width)
number
- the int to be alignedwidth
- the width (number of spaces) of the field
public static java.lang.String right(double number, int width)
number
- the double to be rounded and alignedwidth
- the width (number of spaces) of the field
public static java.lang.String currency(double number, int width)
number
- the value to be expressed as currencywidth
- the width (number of spaces) of the field
public static java.lang.String left(double number, int width)
number
- the double to be rounded and alignedwidth
- the width (number of spaces) of the field
public static java.lang.String center(double number, int width)
number
- the double to be rounded and alignedwidth
- the width (number of spaces) of the field
public static java.lang.String right(double number, int width, int places)
number
- the double to be rounded and alignedwidth
- the width (number of spaces) of the fieldplaces
- the number of decimal places to which number is rounded
public static java.lang.String left(double number, int width, int places)
number
- the double to be rounded and alignedwidth
- the width (number of spaces) of the fieldplaces
- the number of decimal places to which number is rounded
public static java.lang.String center(double number, int width, int places)
number
- the double to be rounded and alignedwidth
- the width (number of spaces) of the fieldplaces
- the number of decimal places to which number is rounded
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |