Class FormattedNumber

java.lang.Object
java.lang.Number
xal.tools.text.FormattedNumber
All Implemented Interfaces:
Serializable, Comparable<FormattedNumber>

public class FormattedNumber extends Number implements 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 Details

    • DEFAULT_NUMBER_FORMAT

      protected static final NumberFormat DEFAULT_NUMBER_FORMAT
      default number format when none is specified
    • number

      protected final Number number
      the number
    • format

      protected final NumberFormat format
      the format for displaying the number
  • Constructor Details

    • FormattedNumber

      public FormattedNumber(NumberFormat format, Number value)
      Primary Constructor
      Parameters:
      format - the number format for display
      value - the value to represent
    • FormattedNumber

      public FormattedNumber(String pattern, Number value)
      Constructor
      Parameters:
      pattern - decimal format pattern
      value - the value to represent
    • FormattedNumber

      public FormattedNumber(Number value)
      Constructor with the default pattern of "0.0000E###"
      Parameters:
      value - the value to represent
    • FormattedNumber

      public FormattedNumber(String valueString)
      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

      public NumberFormat getFormat()
      Get the format.
      Returns:
      the format
    • byteValue

      public byte byteValue()
      Get the value as a byte.
      Overrides:
      byteValue in class Number
      Returns:
      the value as a byte
    • doubleValue

      public double doubleValue()
      Get the value as a double.
      Specified by:
      doubleValue in class Number
      Returns:
      the value as a double
    • floatValue

      public float floatValue()
      Get the value as a float.
      Specified by:
      floatValue in class Number
      Returns:
      the value as a float
    • intValue

      public int intValue()
      Get the value as an integer.
      Specified by:
      intValue in class Number
      Returns:
      the value as an integer
    • shortValue

      public short shortValue()
      Get the value as a short.
      Overrides:
      shortValue in class Number
      Returns:
      the value as a short
    • longValue

      public long longValue()
      Get the value as a long.
      Specified by:
      longValue in class Number
      Returns:
      the value as a long
    • toString

      public String toString()
      Use the number format to provide the number's display representation.
      Overrides:
      toString in class Object
      Returns:
      the display representation
    • compareTo

      public int compareTo(FormattedNumber other)
      compare this number with the specified other number
      Specified by:
      compareTo in interface Comparable<FormattedNumber>