All Packages Class Hierarchy This Package Previous Next Index
Class com.roguewave.money.currency.v1_0.ExchangeFactory
java.lang.Object
|
+----com.roguewave.money.currency.v1_0.ExchangeFactory
- public class ExchangeFactory
- extends Object
Money.h++ provides a factory class, ExchangeFactory
that creates currency
exchange objects. The currency exchange factory is essentially a list of
ExchangeGroups
. When the factory receives a request for a currency
exchange, it finds the first currency exchange group that can create an
Exchange
object and returns the object it found. By default, upon
construction, the ExchangeFactory
class always contains one currency
exchange group: MultiplicationGroup
.
The MultiplicationGroup
group is the default exchange group, and, initially,
is always available in the factory’s list of currency groups. When presented with a
source/target currency pair and exchange rate table, the default exchange group looks
for an exchange rate in the table for the pair and, if found, constructs a
MultiplicationExchange
exchange object.
- Author:
- Trevor Misfeldt
- See Also:
- Exchange, BilateralExchange, MultiplicationExchange, DivisionExchange, TriangularExchange, ExchangeRateTable, ExchangeGroup, MultiplicationGroup, DivisionGroup, EuroGroup, MoneyCalculatorExample, FactoryExample, GroupExample
-
NOT_FOUND
- Index returned when an exchange group cannot be found.
-
ExchangeFactory()
- Creates an exchange factory with the default bilateral multiplication group and
an empty exchange rate table.
-
ExchangeFactory(ExchangeRateTable)
- Creates an exchange factory with the default bilateral multiplication group and
the given exchange rate table.
-
appendExchangeGroup(ExchangeGroup)
- Appends the exchange group to the collection of exchange groups.
-
clearExchangeGroups()
- Removes all exchange groups.
-
containsExchangeGroup(String)
- Searchs the collection for the named exchange group.
-
findExchangeGroup(String)
- Finds the named exchange group and returns it.
-
getExchange(String, String)
- Starting with the first entry in the exchange group collection, the factory
traverses until it finds an exchange group which can create an exchange
object.
-
getExchangeGroupAt(int)
- Returns the exchange group at the specified index.
-
getExchangeGroupIndex(String)
- Finds the named exchange group and returns its position in the collection.
-
getExchangeGroups()
- Returns a vector of exchange groups.
-
getExchangeRateTable()
- Returns the factory's exchange rate table.
-
getFirstExchangeGroup()
- Returns the first exchange group.
-
getLastExchangeGroup()
- Returns the last exchange group.
-
insertExchangeGroupAt(ExchangeGroup, int)
- Inserts the exchange group at the desired position in the collection of
exchange groups.
-
numberOfExchangeGroups()
- Returns the number of exchange groups.
-
prependExchangeGroup(ExchangeGroup)
- Prepends the exchange group to the collection of exchange groups.
-
removeExchangeGroup(String)
- Removes the named exchange group.
-
removeExchangeGroupAt(int)
- Removes the exchange group at the specified position.
-
removeFirstExchangeGroup()
- Removes the first exchange group.
-
removeLastExchangeGroup()
- Removes the last exchange group.
-
setExchangeGroups(Vector)
- Sets the vector of exchange groups.
-
setExchangeRateTable(ExchangeRateTable)
- Sets the factory's exchange rate table.
NOT_FOUND
public static final int NOT_FOUND
- Index returned when an exchange group cannot be found.
ExchangeFactory
public ExchangeFactory()
- Creates an exchange factory with the default bilateral multiplication group and
an empty exchange rate table.
ExchangeFactory
public ExchangeFactory(ExchangeRateTable table)
- Creates an exchange factory with the default bilateral multiplication group and
the given exchange rate table.
- Parameters:
- table - an exchange rate table
- See Also:
- ExchangeRateTable
getExchangeGroups
public Vector getExchangeGroups()
- Returns a vector of exchange groups.
- Returns:
- the exchange groups
- See Also:
- ExchangeGroup, MultiplicationGroup, DivisionGroup, EuroGroup
setExchangeGroups
public void setExchangeGroups(Vector groups)
- Sets the vector of exchange groups. Note: Will clear the current
exchange groups.
- Parameters:
- groups - the new exchange groups
- See Also:
- ExchangeGroup, MultiplicationGroup, DivisionGroup, EuroGroup
getExchange
public Exchange getExchange(String source,
String target)
- Starting with the first entry in the exchange group collection, the factory
traverses until it finds an exchange group which can create an exchange
object.
- Parameters:
- source - original source currency
- target - desired target currency
- Returns:
- A valid exchange object, or, a
null
value.
- See Also:
- Exchange, MultiplicationExchange, DivisionExchange, TriangularExchange
containsExchangeGroup
public boolean containsExchangeGroup(String name)
- Searchs the collection for the named exchange group.
- Parameters:
- name - the name of the exchange group
- Returns:
- whether the named group exists or not
- See Also:
- Exchange, MultiplicationExchange, DivisionExchange, TriangularExchange
findExchangeGroup
public ExchangeGroup findExchangeGroup(String name)
- Finds the named exchange group and returns it. For example, to retrieve
the multiplication group, you can use:
ExchangeGroup multGroup = myFactory.findExchangeGroup(MultiplicationGroup.NAME);
- Parameters:
- name - the name of the desired group.
- Returns:
- the exchange group or, if not found, a
null
value.
- See Also:
- ExchangeGroup, MultiplicationGroup, DivisionGroup, EuroGroup
getExchangeGroupIndex
public int getExchangeGroupIndex(String name)
- Finds the named exchange group and returns its position in the collection. For
example, to retrieve the multiplication group index, you can use:
int multIndex = myFactory.findExchangeGroupIndex(MultiplicationGroup.NAME);
if(multIndex != ExchangeFactory.NOT_FOUND) {
// do something
}
- Parameters:
- name - the name of the desired group.
- Returns:
- The index of the exchange group (starts at zero). If not found, then
NOT_FOUND
is returned.
- See Also:
- ExchangeGroup, MultiplicationGroup, DivisionGroup, EuroGroup, NOT_FOUND
clearExchangeGroups
public void clearExchangeGroups()
- Removes all exchange groups.
- See Also:
- ExchangeGroup, MultiplicationGroup, DivisionGroup, EuroGroup
numberOfExchangeGroups
public int numberOfExchangeGroups()
- Returns the number of exchange groups.
- Returns:
- the number of groups
- See Also:
- ExchangeGroup, MultiplicationGroup, DivisionGroup, EuroGroup
getFirstExchangeGroup
public ExchangeGroup getFirstExchangeGroup()
- Returns the first exchange group.
- Returns:
- the first group
- See Also:
- ExchangeGroup, MultiplicationGroup, DivisionGroup, EuroGroup
getLastExchangeGroup
public ExchangeGroup getLastExchangeGroup()
- Returns the last exchange group.
- Returns:
- the last group
- See Also:
- ExchangeGroup, MultiplicationGroup, DivisionGroup, EuroGroup
getExchangeGroupAt
public ExchangeGroup getExchangeGroupAt(int index)
- Returns the exchange group at the specified index.
- Parameters:
- index - the index of the desired exchange group (starts at zero)
- Returns:
- the exchange group
- See Also:
- ExchangeGroup, MultiplicationGroup, DivisionGroup, EuroGroup
appendExchangeGroup
public synchronized void appendExchangeGroup(ExchangeGroup group)
- Appends the exchange group to the collection of exchange groups.
- Parameters:
- group - the new exchange group
- See Also:
- ExchangeGroup, MultiplicationGroup, DivisionGroup, EuroGroup
insertExchangeGroupAt
public synchronized void insertExchangeGroupAt(ExchangeGroup group,
int index)
- Inserts the exchange group at the desired position in the collection of
exchange groups.
- Parameters:
- group - the new exchange group
- index - the desired position
- See Also:
- ExchangeGroup, MultiplicationGroup, DivisionGroup, EuroGroup
prependExchangeGroup
public synchronized void prependExchangeGroup(ExchangeGroup group)
- Prepends the exchange group to the collection of exchange groups.
- Parameters:
- group - the new exchange group
- See Also:
- ExchangeGroup, MultiplicationGroup, DivisionGroup, EuroGroup
removeExchangeGroup
public synchronized boolean removeExchangeGroup(String name)
- Removes the named exchange group.
- Parameters:
- name - the group to remove
- Returns:
- whether the exchange group was found or not
- See Also:
- ExchangeGroup, MultiplicationGroup, DivisionGroup, EuroGroup
removeExchangeGroupAt
public synchronized ExchangeGroup removeExchangeGroupAt(int index)
- Removes the exchange group at the specified position.
- Parameters:
- index - the position
- Returns:
- the group that was at the specified position.
- See Also:
- ExchangeGroup, MultiplicationGroup, DivisionGroup, EuroGroup
removeFirstExchangeGroup
public synchronized ExchangeGroup removeFirstExchangeGroup()
- Removes the first exchange group.
- Returns:
- the group that was at the first position.
- See Also:
- ExchangeGroup, MultiplicationGroup, DivisionGroup, EuroGroup
removeLastExchangeGroup
public synchronized ExchangeGroup removeLastExchangeGroup()
- Removes the last exchange group.
- Returns:
- the group that was at the last position.
- See Also:
- ExchangeGroup, MultiplicationGroup, DivisionGroup, EuroGroup
getExchangeRateTable
public ExchangeRateTable getExchangeRateTable()
- Returns the factory's exchange rate table.
- Returns:
- the exchange rate table or, if non-existent, the
null
value
- See Also:
- ExchangeRateTable
setExchangeRateTable
public void setExchangeRateTable(ExchangeRateTable table)
- Sets the factory's exchange rate table. Note: Replaces the current
table.
- Parameters:
- table - the new exchange rate table
- See Also:
- ExchangeRateTable
All Packages Class Hierarchy This Package Previous Next Index