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 NumberFormatdefault number format when none is specifiedprotected final NumberFormatthe format for displaying the numberprotected final Numberthe 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 TypeMethodDescriptionbyteGet the value as a byte.intcompareTo(FormattedNumber other) compare this number with the specified other numberdoubleGet the value as a double.floatGet the value as a float.Get the format.intintValue()Get the value as an integer.longGet the value as a long.shortGet 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:
doubleValuein classNumber- Returns:
- the value as a double
-
floatValue
public float floatValue()Get the value as a float.- Specified by:
floatValuein 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:
shortValuein 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:
compareToin interfaceComparable<FormattedNumber>
-