Package xal.tools.text
Class FormattedNumber
java.lang.Object
java.lang.Number
xal.tools.text.FormattedNumber
- All Implemented Interfaces:
Serializable
,Comparable<FormattedNumber>
Provides a number with a format which facilitates easy table display with
proper number justification.
- Since:
- 2/22/06
- Author:
- Thomas Pelaia
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final NumberFormat
default number format when none is specifiedprotected final NumberFormat
the format for displaying the numberprotected final Number
the number -
Constructor Summary
ConstructorsConstructorDescriptionFormattedNumber
(Number value) Constructor with the default pattern of "0.0000E###"FormattedNumber
(String valueString) Constructor with the default pattern of "0.0000E###".FormattedNumber
(String pattern, Number value) ConstructorFormattedNumber
(NumberFormat format, Number value) Primary Constructor -
Method Summary
Modifier and TypeMethodDescriptionbyte
Get the value as a byte.int
compareTo
(FormattedNumber other) compare this number with the specified other numberdouble
Get the value as a double.float
Get the value as a float.Get the format.int
intValue()
Get the value as an integer.long
Get the value as a long.short
Get the value as a short.toString()
Use the number format to provide the number's display representation.
-
Field Details
-
DEFAULT_NUMBER_FORMAT
default number format when none is specified -
number
the number -
format
the format for displaying the number
-
-
Constructor Details
-
FormattedNumber
Primary Constructor- Parameters:
format
- the number format for displayvalue
- the value to represent
-
FormattedNumber
Constructor- Parameters:
pattern
- decimal format patternvalue
- the value to represent
-
FormattedNumber
Constructor with the default pattern of "0.0000E###"- Parameters:
value
- the value to represent
-
FormattedNumber
Constructor with the default pattern of "0.0000E###". This constructor is necessary to support javax.swing.text.DefaultFormatter- Parameters:
valueString
- the string to parse as a number
-
-
Method Details
-
getFormat
Get the format.- Returns:
- the format
-
byteValue
public byte byteValue()Get the value as a byte. -
doubleValue
public double doubleValue()Get the value as a double.- Specified by:
doubleValue
in classNumber
- Returns:
- the value as a double
-
floatValue
public float floatValue()Get the value as a float.- Specified by:
floatValue
in classNumber
- Returns:
- the value as a float
-
intValue
public int intValue()Get the value as an integer. -
shortValue
public short shortValue()Get the value as a short.- Overrides:
shortValue
in classNumber
- Returns:
- the value as a short
-
longValue
public long longValue()Get the value as a long. -
toString
Use the number format to provide the number's display representation. -
compareTo
compare this number with the specified other number- Specified by:
compareTo
in interfaceComparable<FormattedNumber>
-