Package org.onosproject.ui.table.cell
Class NumberFormatter
- java.lang.Object
-
- org.onosproject.ui.table.cell.AbstractCellFormatter
-
- org.onosproject.ui.table.cell.NumberFormatter
-
- All Implemented Interfaces:
CellFormatter
public final class NumberFormatter extends AbstractCellFormatter
Formats number using the specified format string.
-
-
Field Summary
Fields Modifier and Type Field Description static CellFormatter
INTEGER
An instance of this class that formats as integers (no decimal places).static CellFormatter
TO_5DP
An instance of this class that formats to 5 decimal places.-
Fields inherited from class org.onosproject.ui.table.cell.AbstractCellFormatter
EMPTY, OX, QUERY, SLASH, SPACE, UNDERSCORE
-
-
Constructor Summary
Constructors Constructor Description NumberFormatter()
Creates a formatter using the default format (no decimal places).NumberFormatter(java.lang.String decimalFormat)
Creates a formatter using aDecimalFormat
configured with the given format string.NumberFormatter(java.text.NumberFormat format)
Creates a formatter using the specifiedNumberFormat
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.lang.String
nonNullFormat(java.lang.Object value)
Formats the specified value into a string appropriate for displaying in a table cell.-
Methods inherited from class org.onosproject.ui.table.cell.AbstractCellFormatter
format
-
-
-
-
Field Detail
-
INTEGER
public static final CellFormatter INTEGER
An instance of this class that formats as integers (no decimal places). For example12345 formatted as "12,345"
-
TO_5DP
public static final CellFormatter TO_5DP
An instance of this class that formats to 5 decimal places. For example12.3 formatted as "12.30000" 1234 formatted as "1,234.00000"
-
-
Constructor Detail
-
NumberFormatter
public NumberFormatter()
Creates a formatter using the default format (no decimal places). For example12345 formatted as "12,345"
-
NumberFormatter
public NumberFormatter(java.lang.String decimalFormat)
Creates a formatter using aDecimalFormat
configured with the given format string.- Parameters:
decimalFormat
- the format string
-
NumberFormatter
public NumberFormatter(java.text.NumberFormat format)
Creates a formatter using the specifiedNumberFormat
.- Parameters:
format
- number format
-
-
Method Detail
-
nonNullFormat
protected java.lang.String nonNullFormat(java.lang.Object value)
Description copied from class:AbstractCellFormatter
Formats the specified value into a string appropriate for displaying in a table cell. Note that value is guaranteed to be non-null.- Specified by:
nonNullFormat
in classAbstractCellFormatter
- Parameters:
value
- the value- Returns:
- the formatted string
-
-