com.extjs.gxt.ui.client.widget.form
Class NumberPropertyEditor

java.lang.Object
  extended by com.extjs.gxt.ui.client.widget.form.NumberPropertyEditor
All Implemented Interfaces:
PropertyEditor<java.lang.Number>

public class NumberPropertyEditor
extends java.lang.Object
implements PropertyEditor<java.lang.Number>

PropertyEditory that uses a NumberFormat. When converting a Number to a String, if a format has not been specified, toString will be called on the passed Number. When converting from a String to a Number, the number type (setType(Class) will be used to determine the new number instance type.


 NumberPropertyEditor editor = new NumberPropertyEditor(Integer.class);
 

See Also:
NumberFormat

Field Summary
protected  java.lang.String alpahRegex
           
protected  java.lang.String currencySymbolRegex
           
protected  com.google.gwt.i18n.client.NumberFormat format
           
protected  java.lang.String groupSeparator
           
protected  com.google.gwt.i18n.client.constants.NumberConstants numbers
           
protected  java.lang.Class<?> type
           
 
Fields inherited from interface com.extjs.gxt.ui.client.widget.form.PropertyEditor
DEFAULT
 
Constructor Summary
NumberPropertyEditor()
          Creates a new number property editor with the default number type (Double).
NumberPropertyEditor(java.lang.Class<?> type)
          Creates a new number property editor.
NumberPropertyEditor(com.google.gwt.i18n.client.NumberFormat format)
          Creates a new number property editor.
NumberPropertyEditor(java.lang.String pattern)
          Creates a new number property editor.
 
Method Summary
 java.lang.Number convertStringValue(java.lang.String value)
          Converts a string to the typed value.
 com.google.gwt.i18n.client.NumberFormat getFormat()
          Returns the editor's format.
 java.lang.String getStringValue(java.lang.Number value)
          Returns the data as a string.
 java.lang.Class<?> getType()
          Returns the number class.
 boolean isStripAlphas()
          Returns true if alpha characters are being removed.
 boolean isStripCurrencySymbol()
          Returns true if the currency symbol is being removed.
 boolean isStripGroupSeparator()
          Returns true if the group separator is being removed before parsing a string value.
protected  java.lang.Number returnTypedValue(java.lang.Number number)
           
 void setFormat(com.google.gwt.i18n.client.NumberFormat format)
          Sets the editor's format.
 void setStripAlphas(boolean stripAlphas)
          True to remove alpha characters when parsing a string value (defaults to false).
 void setStripCurrencySymbol(boolean stripCurrencySymbol)
          True to remove the currency symbol when parsing a string value (defaults to false).
 void setStripGroupSeparator(boolean stripGroupSeparator)
          True to remove the group separator, as defined by GWT NumberConstants, when parsing a string value (defaults to false).
 void setType(java.lang.Class<?> type)
          Sets the number type used when converting a string to a number.
protected  java.lang.String stripValue(java.lang.String value)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

numbers

protected com.google.gwt.i18n.client.constants.NumberConstants numbers

format

protected com.google.gwt.i18n.client.NumberFormat format

alpahRegex

protected java.lang.String alpahRegex

currencySymbolRegex

protected java.lang.String currencySymbolRegex

groupSeparator

protected java.lang.String groupSeparator

type

protected java.lang.Class<?> type
Constructor Detail

NumberPropertyEditor

public NumberPropertyEditor()
Creates a new number property editor with the default number type (Double).


NumberPropertyEditor

public NumberPropertyEditor(java.lang.Class<?> type)
Creates a new number property editor.

Parameters:
type - the number class (Short, Integer, Long, Float, Double)

NumberPropertyEditor

public NumberPropertyEditor(com.google.gwt.i18n.client.NumberFormat format)
Creates a new number property editor.

Parameters:
format - the number format

NumberPropertyEditor

public NumberPropertyEditor(java.lang.String pattern)
Creates a new number property editor.

Parameters:
pattern - the number format pattern
Method Detail

convertStringValue

public java.lang.Number convertStringValue(java.lang.String value)
Description copied from interface: PropertyEditor
Converts a string to the typed value.

Specified by:
convertStringValue in interface PropertyEditor<java.lang.Number>
Parameters:
value - the string value
Returns:
the type value or null if value cannot be converted

getFormat

public com.google.gwt.i18n.client.NumberFormat getFormat()
Returns the editor's format.

Returns:
the number format

getStringValue

public java.lang.String getStringValue(java.lang.Number value)
Description copied from interface: PropertyEditor
Returns the data as a string.

Specified by:
getStringValue in interface PropertyEditor<java.lang.Number>
Parameters:
value - the typed value
Returns:
the value as a string

getType

public java.lang.Class<?> getType()
Returns the number class.

Returns:
the number class

isStripAlphas

public boolean isStripAlphas()
Returns true if alpha characters are being removed.

Returns:
true if alpha characters are being removed

isStripCurrencySymbol

public boolean isStripCurrencySymbol()
Returns true if the currency symbol is being removed.

Returns:
true if currency symbol is being removed

isStripGroupSeparator

public boolean isStripGroupSeparator()
Returns true if the group separator is being removed before parsing a string value.

Returns:
true if the group separator is being removed

setFormat

public void setFormat(com.google.gwt.i18n.client.NumberFormat format)
Sets the editor's format.

Parameters:
format - the format

setStripAlphas

public void setStripAlphas(boolean stripAlphas)
True to remove alpha characters when parsing a string value (defaults to false).

Parameters:
stripAlphas - true to remove all alpha characters

setStripCurrencySymbol

public void setStripCurrencySymbol(boolean stripCurrencySymbol)
True to remove the currency symbol when parsing a string value (defaults to false).

Parameters:
stripCurrencySymbol - true to the currency symbol

setStripGroupSeparator

public void setStripGroupSeparator(boolean stripGroupSeparator)
True to remove the group separator, as defined by GWT NumberConstants, when parsing a string value (defaults to false).

Parameters:
stripGroupSeparator - true to remove the group separator

setType

public void setType(java.lang.Class<?> type)
Sets the number type used when converting a string to a number.

Parameters:
type - the type (Short, Integer, Long, Float, Double)

returnTypedValue

protected java.lang.Number returnTypedValue(java.lang.Number number)

stripValue

protected java.lang.String stripValue(java.lang.String value)