|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.globalmentor.beans.BoundPropertyObject
com.guiseframework.event.GuiseBoundPropertyObject
com.guiseframework.converter.AbstractConverter<V,java.lang.String>
com.guiseframework.converter.AbstractNumberStringLiteralConverter<V>
V - The value type this converter supports.public abstract class AbstractNumberStringLiteralConverter<V extends java.lang.Number>
An abstract implementation an object that can convert a number from and to a string.
If the currency style is chosen, care should be taken to indicate a specific constant currency unless it is desired that the currency type change whenever the locale changes.
This implementation caches a number format and only creates a new one if the locale has changed.
Child classes should override createNumberFormat(Locale) if custom number formats are desired.
This implementation synchronizes all conversions on the NumberFormat object.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface com.guiseframework.converter.NumberStringLiteralConverter |
|---|
NumberStringLiteralConverter.Style |
| Field Summary |
|---|
| Fields inherited from class com.globalmentor.beans.BoundPropertyObject |
|---|
NO_PROPERTY_CHANGE_LISTENERS, NO_VETOABLE_CHANGE_LISTENERS |
| Fields inherited from interface com.guiseframework.converter.NumberStringLiteralConverter |
|---|
EUR_CURRENCY, USD_CURRENCY |
| Fields inherited from interface com.guiseframework.converter.Converter |
|---|
INVALID_VALUE_MESSAGE_PROPERTY |
| Constructor Summary | |
|---|---|
AbstractNumberStringLiteralConverter(NumberStringLiteralConverter.Style style,
java.util.Currency currency)
Style and currency constructor. |
|
| Method Summary | |
|---|---|
java.lang.String |
convertValue(V value)
Converts a value from the value space to a literal value in the lexical space. |
protected java.text.NumberFormat |
createNumberFormat(java.util.Locale locale)
Creates a new number format object for the indicated locale. |
java.util.Currency |
getCurrency()
|
protected java.text.NumberFormat |
getNumberFormat()
|
NumberStringLiteralConverter.Style |
getStyle()
|
protected java.lang.Number |
parseNumber(java.lang.String literal)
Converts a literal representation of a value from the lexical space into a number. |
| Methods inherited from class com.guiseframework.converter.AbstractConverter |
|---|
getInvalidValueMessage, isEquivalent, isValidLiteral, setInvalidValueMessage |
| Methods inherited from class com.guiseframework.event.GuiseBoundPropertyObject |
|---|
getSession |
| Methods inherited from class com.globalmentor.beans.BoundPropertyObject |
|---|
addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, addVetoableChangeListener, createPostponedPropertyChangeEvent, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, getForwardPropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, getPropertyChangeSupport, getRepeatPropertyChangeListener, getRepeatVetoableChangeListener, getVetoableChangeListeners, getVetoableChangeListeners, getVetoableChangeSupport, hasPropertyChangeListeners, hasVetoableChangeListeners, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, removeVetoableChangeListener |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface com.guiseframework.converter.Converter |
|---|
convertLiteral, getInvalidValueMessage, getSession, isEquivalent, isValidLiteral, setInvalidValueMessage |
| Methods inherited from interface com.globalmentor.beans.PropertyBindable |
|---|
addPropertyChangeListener, addPropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, hasPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener |
| Constructor Detail |
|---|
public AbstractNumberStringLiteralConverter(NumberStringLiteralConverter.Style style,
java.util.Currency currency)
style - The representation style.currency - The constant currency type to use, or null if currency representation is not requested or the currency should be dynamically determined by the locale.
java.lang.NullPointerException - if the given style is null.
java.lang.IllegalArgumentException - if a currency is provided for a style other than Style#CURRENCY.| Method Detail |
|---|
public NumberStringLiteralConverter.Style getStyle()
public java.util.Currency getCurrency()
null if currency representation is not requested or the currency should be dynamically determined by the locale.protected java.text.NumberFormat getNumberFormat()
protected java.text.NumberFormat createNumberFormat(java.util.Locale locale)
locale - The locale for which a number format should be created.
getStyle()
public java.lang.String convertValue(V value)
throws ConversionException
NumberFormat instance.
convertValue in interface Converter<V extends java.lang.Number,java.lang.String>value - The value in the value space to convert.
null if the given literal is null.
ConversionException - if the value cannot be converted.getNumberFormat()
protected java.lang.Number parseNumber(java.lang.String literal)
throws ConversionException
null value.
This implementation adds any appropriate symbols, such as a percent sign or currency symbol, if needed.
literal - The literal value in the lexical space to convert.
Long or Double form, or null if the given literal is null or the empty string.
ConversionException - if the literal value cannot be converted.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||