T - public abstract class ColumnFormatter<T> extends Object
ColumnFormatter class represents a certain format of
an logical column in a table. For example, the format can be percentage,
currency, plain text, ect.| Modifier and Type | Field and Description |
|---|---|
protected Alignment |
al |
protected int |
width |
| Modifier | Constructor and Description |
|---|---|
protected |
ColumnFormatter() |
protected |
ColumnFormatter(Alignment al,
int width) |
| Modifier and Type | Method and Description |
|---|---|
static ColumnFormatter<Number> |
currency(Alignment al,
int width,
Precision p,
String symbol)
Get a built-in ColumnFormatter for currency values.
|
static ColumnFormatter<Date> |
dateTime(Alignment al,
int width,
DateFormat df)
Get a built-in ColumnFormatter for date and time
|
abstract String |
format(T t)
Format an object of T type into a String
|
protected String |
formatString(String s,
int width) |
static <T> String |
formatText(ColumnFormatter<T> cf,
String s)
Format a string using the Alignment and width of an existing ColumnFormatter for any type
|
Alignment |
getAlignment() |
int |
getWidth() |
static ColumnFormatter<Number> |
number(Alignment al,
int width,
Precision p)
Get a built-in ColumnFormatter for plain numbers
|
static ColumnFormatter<Number> |
percentage(Alignment al,
int width,
Precision p)
Get a built-in ColumnFormatter for percentage values
|
static ColumnFormatter<String> |
text(Alignment al,
int width)
Get a built-in ColumnFormatter for plain texts
|
static <T> ColumnFormatter<String> |
text(ColumnFormatter<T> cf)
Get a ColumnFormatter object using the Alignment and width of an existing ColumnFormatter of any type
|
protected Alignment al
protected int width
protected ColumnFormatter()
protected ColumnFormatter(Alignment al, int width)
public static ColumnFormatter<Number> currency(Alignment al, int width, Precision p, String symbol)
al - See enum Alignmentwidth - An integer as the width of the columnp - See enum Precisionsymbol - A string as the currency symbol.
If the symbol length is greater than 1, there will be a space between the symbol and the number.public static ColumnFormatter<Date> dateTime(Alignment al, int width, DateFormat df)
al - See enum Alignmentwidth - An integer as the width of the columndf - See java.text.DateFormatpublic static <T> String formatText(ColumnFormatter<T> cf, String s)
T - the class of the objects in the columncf - An existing ColumnFormatter of any types - The input String to be formattedpublic static ColumnFormatter<Number> number(Alignment al, int width, Precision p)
al - See enum Alignmentwidth - An integer as the width of the columnp - See enum Precisionpublic static ColumnFormatter<Number> percentage(Alignment al, int width, Precision p)
al - See enum Alignmentwidth - An integer as the width of the columnp - See enum Precisionpublic static ColumnFormatter<String> text(Alignment al, int width)
al - See enum Alignmentwidth - An integer as the width of the columnpublic static <T> ColumnFormatter<String> text(ColumnFormatter<T> cf)
T - the class of the column objectscf - An existing ColumnFormatterpublic abstract String format(T t)
t - An object of T typepublic final Alignment getAlignment()
public final int getWidth()
Copyright © 2016. All rights reserved.