org.softsmithy.lib.swing.text
Class AbstractXNumberFormatter

java.lang.Object
  extended by javax.swing.JFormattedTextField.AbstractFormatter
      extended by javax.swing.text.DefaultFormatter
          extended by javax.swing.text.InternationalFormatter
              extended by javax.swing.text.NumberFormatter
                  extended by org.softsmithy.lib.swing.text.AbstractXNumberFormatter
All Implemented Interfaces:
Serializable, Cloneable
Direct Known Subclasses:
RealNumberFormatter, WholeNumberFormatter

public abstract class AbstractXNumberFormatter
extends NumberFormatter

The base class of the number formatters.

Author:
puce
See Also:
Serialized Form

Constructor Summary
AbstractXNumberFormatter()
          Creates a new instance of this class.
AbstractXNumberFormatter(NumberFormat format)
          Creates a new instance of this class.
AbstractXNumberFormatter(NumberFormat format, Number minValue, Number maxValue)
          Creates a new instance of this class.
AbstractXNumberFormatter(Number minValue, Number maxValue)
          Creates a new instance of this class.
 
Method Summary
protected  Number getMaximumMaximumValue()
          Getter for property maximumMaximumValue.
 Number getMaximumNumberValue()
          Getter for property maximumBigDecimalValue.
protected  Number getMinimumMinimumValue()
          Getter for property minimumMinimumValue.
 Number getMinimumNumberValue()
          Getter for property minimumBigDecimalValue.
 NumberFormat getNumberFormat()
           
 void setFormat(Format format)
           
 void setMaximum(Comparable max)
          Sets the maximum value.
protected  void setMaximumMaximumValue(Number maximumMaximumValue)
          The maximum value for the maximum value.
 void setMaximumNumberValue(Number maximumValue)
          Setter for property maximumBigDecimalValue.
 void setMinimum(Comparable minimum)
          Sets the minimum value.
protected  void setMinimumMinimumValue(Number minimumMinimumValue)
          The minimum value for the minimum value.
 void setMinimumNumberValue(Number minimumValue)
          Setter for property minimumBigDecimalValue.
 void setNumberFormat(NumberFormat format)
           
 void setValueClass(Class valueClass)
           
protected abstract  Number stringToNumber(String text)
          Returns the Number representation of the String text.
 Object stringToValue(String text)
          Returns the Number representation of the String text.
 Number valueToRange(Number value)
           
 
Methods inherited from class javax.swing.text.InternationalFormatter
clone, getActions, getFields, getFormat, getMaximum, getMinimum, install, valueToString
 
Methods inherited from class javax.swing.text.DefaultFormatter
getAllowsInvalid, getCommitsOnValidEdit, getDocumentFilter, getNavigationFilter, getOverwriteMode, getValueClass, setAllowsInvalid, setCommitsOnValidEdit, setOverwriteMode
 
Methods inherited from class javax.swing.JFormattedTextField.AbstractFormatter
getFormattedTextField, invalidEdit, setEditValid, uninstall
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractXNumberFormatter

public AbstractXNumberFormatter()
Creates a new instance of this class.


AbstractXNumberFormatter

public AbstractXNumberFormatter(NumberFormat format)
Creates a new instance of this class.

Parameters:
format - the number format

AbstractXNumberFormatter

public AbstractXNumberFormatter(Number minValue,
                                Number maxValue)
Creates a new instance of this class.

Parameters:
minValue - the minimum value
maxValue - the maximum value

AbstractXNumberFormatter

public AbstractXNumberFormatter(NumberFormat format,
                                Number minValue,
                                Number maxValue)
Creates a new instance of this class.

Parameters:
format - the number format
minValue - the minimum value
maxValue - the maximum value
Method Detail

setMaximum

public void setMaximum(Comparable max)
Sets the maximum value. It must be an instance of Number or null. It mustn't be smaller than the minimum value. It ensures that the maximum value is in the range of the maximum maximum value and the minimum minimum value.

Overrides:
setMaximum in class InternationalFormatter
Parameters:
max - the maximum number value

setMinimum

public void setMinimum(Comparable minimum)
Sets the minimum value. It must be an instance of Number or null. It mustn't be bigger than the maximum value. It ensures that the minimum value is in the range of the maximum maximum value and the minimum minimum value.

Overrides:
setMinimum in class InternationalFormatter
Parameters:
minimum - the minimum number value

stringToValue

public Object stringToValue(String text)
                     throws ParseException
Returns the Number representation of the String text.

Overrides:
stringToValue in class InternationalFormatter
Parameters:
text - String to convert
Returns:
Number representation of text
Throws:
ParseException - if there is an error in the conversion

stringToNumber

protected abstract Number stringToNumber(String text)
                                  throws NumberFormatException
Returns the Number representation of the String text.

Parameters:
text - String to convert
Returns:
Number representation of text
Throws:
NumberFormatException - if there is an error in the conversion

valueToRange

public Number valueToRange(Number value)

getMaximumMaximumValue

protected Number getMaximumMaximumValue()
Getter for property maximumMaximumValue.

Returns:
Value of property maximumMaximumValue.

setMaximumMaximumValue

protected void setMaximumMaximumValue(Number maximumMaximumValue)
The maximum value for the maximum value. It must be an instance of Comparable or null, if there is no maximum maximum value. And it mustn't be smaller than the minimum minimum value, if both are not null. If the maximum or the minimum value are greater than the maximum maximum value, they will be set to the maximum maximum value instead.

Parameters:
maximumMaximumValue - the maximum value for the maximum value

getMinimumMinimumValue

protected Number getMinimumMinimumValue()
Getter for property minimumMinimumValue.

Returns:
Value of property minimumMinimumValue.

setMinimumMinimumValue

protected void setMinimumMinimumValue(Number minimumMinimumValue)
The minimum value for the minimum value.


getMaximumNumberValue

public Number getMaximumNumberValue()
Getter for property maximumBigDecimalValue.

Returns:
Value of property maximumBigDecimalValue.

setMaximumNumberValue

public void setMaximumNumberValue(Number maximumValue)
Setter for property maximumBigDecimalValue.

Parameters:
maximumBigDecimalValue - New value of property maximumBigDecimalValue.

getMinimumNumberValue

public Number getMinimumNumberValue()
Getter for property minimumBigDecimalValue.

Returns:
Value of property minimumBigDecimalValue.

setMinimumNumberValue

public void setMinimumNumberValue(Number minimumValue)
Setter for property minimumBigDecimalValue.

Parameters:
minimumBigDecimalValue - New value of property minimumBigDecimalValue.

setValueClass

public void setValueClass(Class valueClass)
Overrides:
setValueClass in class DefaultFormatter

setFormat

public void setFormat(Format format)
Overrides:
setFormat in class NumberFormatter

getNumberFormat

public NumberFormat getNumberFormat()

setNumberFormat

public void setNumberFormat(NumberFormat format)


Copyright © 2002-2011 SoftSmithy. All Rights Reserved.