Class StrictNumberFormatter

All Implemented Interfaces:
Serializable, Cloneable

public class StrictNumberFormatter extends NumberFormatter
Experiment to work around Issue #1183-swingx: NumberEditorExt throws exception on getCellValue. Remaining issue: no visual error feedback if the expected number type exceeds its range.
See Also:
  • Field Details

  • Constructor Details

    • StrictNumberFormatter

      public StrictNumberFormatter(NumberFormat format)
      Parameters:
      format -
  • Method Details

    • setValueClass

      public void setValueClass(Class<?> valueClass)

      Overridden to automatically set the minimum/maximum to the boundaries of the Number type if it corresponds to a raw type, or null if not.

      Overrides:
      setValueClass in class DefaultFormatter
    • updateMinMax

      private void updateMinMax()
    • setMaximum

      public void setMaximum(Comparable max)
      Overrides:
      setMaximum in class InternationalFormatter
    • setMinimum

      public void setMinimum(Comparable minimum)
      Overrides:
      setMinimum in class InternationalFormatter
    • stringToValue

      public Object stringToValue(String text) throws ParseException
      Returns the Object representation of the String text, may be null.
      Overrides:
      stringToValue in class InternationalFormatter
      Parameters:
      text - String to convert
      Returns:
      Object representation of text
      Throws:
      ParseException - if there is an error in the conversion
    • convertValueToValueClass

      private Object convertValueToValueClass(Object value, Class<?> valueClass)
      Converts the passed in value to the passed in class. This only works if valueClass is one of Integer, Long, Float, Double, Byte or Short and value is an instanceof Number.
    • getParsedValue

      private Object getParsedValue(String text, Format f) throws ParseException
      Invokes parseObject on f, returning its value.
      Throws:
      ParseException
    • isValueInRange

      private boolean isValueInRange(Object orgValue, boolean wantsCCE)
      Returns true if value is between the min/max.
      Parameters:
      wantsCCE - If false, and a ClassCastException is thrown in comparing the values, the exception is consumed and false is returned.
    • getMinimumAsBig

      private Comparable<BigDecimal> getMinimumAsBig()
    • getMaximumAsBig

      private Comparable<BigDecimal> getMaximumAsBig()