org.salespointframework.core.data
Class AbstractCurrency
java.lang.Object
org.salespointframework.core.data.AbstractNameable
org.salespointframework.core.data.CatalogItemImpl
org.salespointframework.core.data.CatalogImpl<CurrencyItemImpl>
org.salespointframework.core.data.AbstractCurrency
- All Implemented Interfaces:
- java.lang.Cloneable, java.lang.Comparable<java.lang.Object>, java.lang.Iterable<CurrencyItemImpl>, Recoverable, DatasourceChangeListener, ExternalModificationListener, Catalog<CurrencyItemImpl>, CatalogItem, Currency<CurrencyItemImpl>, DataBasketEntryDestination, DataBasketEntrySource, DataBasketKeys, ListenableCatalog<CurrencyItemImpl>, Nameable, NameContext, SpAggregate, SpItem, SelfManagingDBEDestination<CurrencyItemImpl>, SelfManagingDBESource<CurrencyItemImpl>
- Direct Known Subclasses:
- EUROCurrencyImpl
public abstract class AbstractCurrency
- extends CatalogImpl<CurrencyItemImpl>
- implements Currency<CurrencyItemImpl>
Abstract Java implementation of the Currency
interface.
- Version:
- 3.0
- Author:
- Thomas Medack
Field Summary |
private java.text.NumberFormat |
m_nfFormatter
Tool used to format and parse currency values. |
Constructor Summary |
AbstractCurrency(java.lang.String sName)
Create a new AbstractCurrency with a default locale of Locale.GERMANY and fill it. |
AbstractCurrency(java.lang.String sName,
java.util.Locale l)
Create a new, initially empty AbstractCurrency for the given locale. |
Method Summary |
static java.lang.String |
format(java.text.NumberFormat formatter,
NumberValue nv)
Convert the given value into a String representation according to the currency format of the
specific currency. |
protected abstract AbstractCurrency.CurrencyItemData[] |
getCurrencyItemData()
This abstract method allows the programmer to choose the names and values of the
CurrencyItems (EURO, DM, ...). |
void |
initCurrencyItems()
Initializes all CurrencyItems in this container with names and values. |
NumberValue |
parse(java.lang.String s)
Try to interpret the given String according to the currency format of the specific currency. |
java.lang.String |
toString(NumberValue nv)
Convert the given value into a String representation according to the currency format of the
specific currency. |
Methods inherited from class org.salespointframework.core.data.CatalogImpl |
add, addCatalogChangeListener, checkNameChange, commitAdd, commitRemove, contains, createPeer, DatasourceChanged, externalModificationOccurred, fireCanEditCatalogItem, fireCanRemoveCatalogItem, fireCatalogItemAddCommit, fireCatalogItemAdded, fireCatalogItemAddRollback, fireCatalogItemDataChanged, fireCatalogItemRemoveCommit, fireCatalogItemRemoved, fireCatalogItemRemoveRollback, fireCommitEditCatalogItem, fireEditingCatalogItem, fireRollbackEditCatalogItem, get, getEditableCopy, getEditingItemsContainer, getItemsContainer, getItemsLock, getNCMonitor, getShallowClone, getTemporaryAddedItemsContainer, getTemporaryRemovedItemsContainer, isPersistent, iterator, iterator, keySet, nameHasChanged, remove, remove, removeCatalogChangeListener, rollbackAdd, rollbackRemove, setCatalog, size, toString |
Methods inherited from class org.salespointframework.core.data.CatalogItemImpl |
addValueListener, compareTo, equals, firePropertyChanged, getCatalog, getImage, getImageBytes, getInternalShallowClone, getValue, isEditable, recover, removeValueListener, setImage, setImageBytes, setValue |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.lang.Comparable |
compareTo |
Methods inherited from interface org.salespointframework.core.data.interfaces.SpItem |
getName |
Methods inherited from interface java.lang.Iterable |
iterator |
m_nfFormatter
private java.text.NumberFormat m_nfFormatter
- Tool used to format and parse currency values.
AbstractCurrency
public AbstractCurrency(java.lang.String sName,
java.util.Locale l)
- Create a new, initially empty AbstractCurrency for the given locale.
- Parameters:
sName
- the name of the currency to create.l
- the locale that determines how currency values will be formatted.
AbstractCurrency
public AbstractCurrency(java.lang.String sName)
- Create a new AbstractCurrency with a default locale of
Locale.GERMANY
and fill it.
- Parameters:
sName
- the name of the new currency.
initCurrencyItems
public void initCurrencyItems()
- Initializes all CurrencyItems in this container with names and values.
parse
public NumberValue parse(java.lang.String s)
throws java.text.ParseException
- Try to interpret the given
String
according to the currency format of the specific currency.
- Specified by:
parse
in interface Currency<CurrencyItemImpl>
- Parameters:
s
- the text to be parsed
- Returns:
- the interpreted value in the smallest unit of the currency.
- Throws:
java.text.ParseException
- if the input could not be parsed.
toString
public java.lang.String toString(NumberValue nv)
- Convert the given value into a
String
representation according to the currency format of the
specific currency. nv
must be given in the smallest unit of the currency, i.e. if you want
to specify 5,05 DM nv
should be 505.
- Specified by:
toString
in interface Currency<CurrencyItemImpl>
- Parameters:
nv
- the value to be converted
- Returns:
- formatted String.
format
public static java.lang.String format(java.text.NumberFormat formatter,
NumberValue nv)
- Convert the given value into a
String
representation according to the currency format of the
specific currency. nv
must be given in the smallest unit of the currency, i.e. if you want
to specify 5,05 DM nv
should be 505.
- Parameters:
formatter
- the formatter used for conversionnv
- the value to be converted
- Returns:
- formatted String.
getCurrencyItemData
protected abstract AbstractCurrency.CurrencyItemData[] getCurrencyItemData()
- This abstract method allows the programmer to choose the names and values of the
CurrencyItems (EURO, DM, ...).
A complete list of data containers, which always contain pairs of name and value, has to be returned.
The single CurrencyItems can be found in the Catalog (Currency) with those names.
- Returns:
- an Array of data containers that contain names and values of CurrencyItems to be added.