BEA Systems, Inc.

theory.smart.axiom.accounting
Class AccountImpl

java.lang.Object
  |
  +--theory.smart.foundation.EntityImpl
        |
        +--theory.smart.foundation.ConfigurableEntityImpl
              |
              +--theory.smart.axiom.accounting.AccountImpl
Direct Known Subclasses:
InventoryRecordImpl

public class AccountImpl
extends ConfigurableEntityImpl

An Account stores a collection of balances and a transaction history. The balances are stored in terms of a set of named Quantities. A Quantity is described in terms of Units. Because of this an account can be used to describe any thing from cash value to an inventory of items. The transaction history is a list of account entries, Each AccountEntry records an addition or subtraction from that account. Special business logic can be tied to instances of an account using a PostingRule.

 Primary Key = theory.smart.axiom.accounting.AccountPk
 

See Also:
Account, AccountHome, AccountValue, Serialized Form

Field Summary
 com.sun.java.util.collections.LinkedList accountEntries
           accountEntry (List) [Account] <>------> [theory.smart.axiom.accounting.AccountEntry] 0..*
 com.sun.java.util.collections.TreeMap balances
           balance (Map) [Account] <*>------> [theory.smart.axiom.units.Quantity] 0..*
 com.sun.java.util.collections.TreeMap chargeds
           charged (Map) [Account] <*>------> [theory.smart.axiom.units.Quantity] 0..*
 java.lang.String identifier
           identifier [Account] <*>------> [String] (Primary Key)
 
Fields inherited from class theory.smart.foundation.EntityImpl
ctx, isDirty, isLoaded
 
Constructor Summary
AccountImpl()
           
 
Method Summary
 AccountEntry add(Quantity qty)
          This method creates a one sided transaction that increases the quantity in the account.
 boolean addAccountEntries(int index, com.sun.java.util.collections.LinkedList accountEntries)
          Inserts all of the accountEntries in the specified collection into this list, starting at the specified position.
 boolean addAccountEntries(com.sun.java.util.collections.LinkedList accountEntries)
          Appends all of the accountEntries in the specified collection to the end of the accountEntry list, in the order that they are returned by the specified collection's iterator.
 boolean addAccountEntry(AccountEntry accountEntry)
          Appends the specified accountEntry to the end of the accountEntry list.
 void addAccountEntry(int index, AccountEntry accountEntry)
          Inserts the specified accountEntry at the specified position in the accountEntry list.
 void addFirstAccountEntry(AccountEntry accountEntry)
          Inserts the given accountEntry at the beginning of the accountEntry list.
 void addLastAccountEntry(AccountEntry accountEntry)
          Appends the given accountEntry to the end of the accountEntry list.
 void applyDeposit(AccountEntry trans)
          Increase the balance of the account by the quantity and store a reference to this transaction.
 void applyTransaction(AccountEntry trans)
          Apply the quantity to the balance of the account.
 void applyWithdrawal(AccountEntry trans)
          Reduce the balance of the account by the quantity and store a reference to this transaction.
 void charge(PostingRule rule, AccountEntry entry)
           
 void charge(java.lang.String acctEntry)
          Cause the specified AccountEntry to set to charge and update the charged balance.
 boolean containsAccountEntry(AccountEntry accountEntry)
          Returns true if the accountEntry list contains the specified element.
 boolean containsBalanceKey(java.lang.String key)
          Returns true if the balance map contains a balance for the specified key.
 boolean containsBalanceValue(Quantity balance)
          Returns true if the balance map maps one or more keys to the specified balance.
 boolean containsChargedKey(java.lang.String key)
          Returns true if the charged map contains a charged for the specified key.
 boolean containsChargedValue(Quantity charged)
          Returns true if the charged map maps one or more keys to the specified charged.
 AccountEntry deposit(Account from, Quantity qty)
          Create a transaction that increases the quantity of this account.
 void ejbActivate()
          ejbActivate method.
 AccountPk ejbCreate(AccountPk accountPk)
           
 java.util.Enumeration ejbFindAll()
           
 AccountPk ejbFindByPrimaryKey(AccountPk pk)
           
 void ejbLoad()
          ejbLoad method.
 void ejbPassivate()
          ejbPassivate method.
 void ejbPostCreate(AccountPk accountPk)
           
 void ejbRemove()
          ejbRemove method.
 void ejbStore()
          ejbStore method.
 AccountValue getAccountByValue()
          Get all of Account's attributes.
 com.sun.java.util.collections.LinkedList getAccountEntries()
          Returns all of the accountEntries in the accountEntry list.
 com.sun.java.util.collections.LinkedList getAccountEntries(int fromIndex, int toIndex)
          Returns a view of the portion of the accountEntry list between fromIndex, inclusive, and toIndex, exclusive.
 AccountEntry getAccountEntry(int index)
          Returns the accountEntry at the specified position in the accountEntry list.
 Quantity getBalanceByKey(java.lang.String key)
          Returns the balance to which the balance map maps the specified key.
 com.sun.java.util.collections.TreeMap getBalances()
          Returns a copy all of the balances from the specified map to the balance map.
 Quantity getChargedByKey(java.lang.String key)
          Returns the charged to which the charged map maps the specified key.
 com.sun.java.util.collections.TreeMap getChargeds()
          Returns a copy all of the chargeds from the specified map to the charged map.
 AccountEntry getFirstAccountEntry()
          Returns the first accountEntry in the accountEntry list.
 java.lang.String getIdentifier()
           
 AccountEntry getLastAccountEntry()
          Returns the last accountEntry in the accountEntry list.
 int getNumberOfAccountEntries()
          Returns the number of accountEntries in the accountEntry list.
 int getNumberOfBalances()
          Returns the number of key-value mappings in the balance map.
 int getNumberOfChargeds()
          Returns the number of key-value mappings in the charged map.
 int indexOfAccountEntry(AccountEntry accountEntry)
          Returns the index in the accountEntry list of the first occurrence of the specified element, or -1 if the accountEntry list does not contain this element.
 boolean isAccountEntriesEmtpy()
          Returns true if the accountEntry list contains no accountEntries.
 boolean isBalancesEmpty()
          Returns true if the balance map contains no key-value mappings.
 boolean isChargedsEmpty()
          Returns true if the charged map contains no key-value mappings.
 int lastIndexOfAccountEntry(AccountEntry accountEntry)
          Returns the index in the accountEntry list of the last occurrence of the specified element, or -1 if the accountEntry list does not contain this element.
 void post(AccountEntry entry)
          Execute all of the posting rules associated with this account with the specified AccountEntry as a paramter.
 void post(PostingRule rule, AccountEntry entry)
          Executea specific posting rule with the specified AccountEntry as a paramter.
 void putBalance(java.lang.String key, Quantity balance)
          Associates the specified balance with the specified key in the balance map.
 void putBalances(com.sun.java.util.collections.TreeMap balances)
          Copies all of the balances from the specified balance map to this balance map.
 void putCharged(java.lang.String key, Quantity charged)
          Associates the specified charged with the specified key in the charged map.
 void putChargeds(com.sun.java.util.collections.TreeMap chargeds)
          Copies all of the chargeds from the specified charged map to this charged map.
 AccountEntry remove(Quantity qty)
          Create a one sided transaction that reduces the quantity in the account.
 boolean removeAccountEntry(AccountEntry accountEntry)
          Removes the first occurrence of the specified accountEntry in the accountEntry list.
 AccountEntry removeAccountEntry(int index)
          Removes the accountEntry at the specified position in the accountEntry list.
 void removeAllAccountEntries()
          Removes all of the accountEntries from the accountEntry list.
 void removeAllBalances()
          Removes all balances from this balance map.
 void removeAllChargeds()
          Removes all chargeds from this charged map.
 Quantity removeBalanceByKey(java.lang.String key)
          Removes the balance for this key from this balance map if present.
 Quantity removeChargedByKey(java.lang.String key)
          Removes the charged for this key from this charged map if present.
 AccountEntry removeFirstAccountEntry()
          Removes and returns the first accountEntry from the accountEntry list.
 AccountEntry removeLastAccountEntry()
          Removes and returns the last accountEntry from the accountEntry list.
 AccountEntry reverse(AccountEntry trans)
          Create a transaction that reverses the original.
 void setAccountByValue(AccountValue value)
          Set all of Account's attributes to the passed in value.
 AccountEntry setAccountEntry(int index, AccountEntry accountEntry)
          Replaces the accountEntry at the specified position in the accountEntry list with the specified element.
 void setDefaultChargingRule(PostingRule rule)
           
 void setDefaultPostingRule(PostingRule rule)
           
 void setEntityContext(javax.ejb.EntityContext ctx)
          setEntityContext method.
 void unsetEntityContext()
          unsetEntityContext method.
 AccountEntry withdraw(Account to, Quantity qty)
          Create a transaction that decreases the quantity of this account.
 
Methods inherited from class theory.smart.foundation.ConfigurableEntityImpl
addBusinessPolicy, addProperty, ejbCreate, ejbPostCreate, getBusinessPolicy, getProperty, removeBusinessPolicy, removeProperty, setSuccessorAtClassLevel, setSuccessorAtInstanceLevel
 
Methods inherited from class theory.smart.foundation.EntityImpl
getEntityContext, isModified
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

identifier

public java.lang.String identifier
                  identifier
 [Account] <*>------> [String] (Primary Key)

 

chargeds

public com.sun.java.util.collections.TreeMap chargeds
                  charged (Map)
 [Account] <*>------> [theory.smart.axiom.units.Quantity]
                     0..*
 

accountEntries

public com.sun.java.util.collections.LinkedList accountEntries
                  accountEntry (List)
 [Account] <>------> [theory.smart.axiom.accounting.AccountEntry]
                     0..*
 

balances

public com.sun.java.util.collections.TreeMap balances
                  balance (Map)
 [Account] <*>------> [theory.smart.axiom.units.Quantity]
                     0..*
 
Constructor Detail

AccountImpl

public AccountImpl()
            throws javax.ejb.CreateException
Method Detail

getAccountByValue

public AccountValue getAccountByValue()
                               throws java.rmi.RemoteException
Get all of Account's attributes.
Returns:
AccountValue the Account value object

setAccountByValue

public void setAccountByValue(AccountValue value)
                       throws java.rmi.RemoteException
Set all of Account's attributes to the passed in value. Note: Primary key attributes are not set.
Parameters:
AccountValue - the Account value object

ejbCreate

public AccountPk ejbCreate(AccountPk accountPk)
                    throws javax.ejb.CreateException,
                           java.rmi.RemoteException

ejbPostCreate

public void ejbPostCreate(AccountPk accountPk)
                   throws javax.ejb.CreateException,
                          java.rmi.RemoteException

ejbLoad

public void ejbLoad()
             throws java.rmi.RemoteException
Description copied from class: EntityImpl
ejbLoad method.
Overrides:
ejbLoad in class ConfigurableEntityImpl

ejbStore

public void ejbStore()
              throws java.rmi.RemoteException
Description copied from class: EntityImpl
ejbStore method.
Overrides:
ejbStore in class ConfigurableEntityImpl

ejbRemove

public void ejbRemove()
               throws java.rmi.RemoteException,
                      javax.ejb.RemoveException
Description copied from class: EntityImpl
ejbRemove method.
Overrides:
ejbRemove in class ConfigurableEntityImpl

ejbActivate

public void ejbActivate()
                 throws java.rmi.RemoteException
Description copied from class: EntityImpl
ejbActivate method.
Overrides:
ejbActivate in class ConfigurableEntityImpl

ejbPassivate

public void ejbPassivate()
                  throws java.rmi.RemoteException
Description copied from class: EntityImpl
ejbPassivate method.
Overrides:
ejbPassivate in class ConfigurableEntityImpl

setEntityContext

public void setEntityContext(javax.ejb.EntityContext ctx)
                      throws java.rmi.RemoteException
Description copied from class: EntityImpl
setEntityContext method.
Overrides:
setEntityContext in class EntityImpl

unsetEntityContext

public void unsetEntityContext()
                        throws java.rmi.RemoteException
Description copied from class: EntityImpl
unsetEntityContext method.
Overrides:
unsetEntityContext in class EntityImpl

ejbFindByPrimaryKey

public AccountPk ejbFindByPrimaryKey(AccountPk pk)
                              throws javax.ejb.FinderException,
                                     java.rmi.RemoteException

ejbFindAll

public java.util.Enumeration ejbFindAll()
                                 throws javax.ejb.FinderException,
                                        java.rmi.RemoteException

getIdentifier

public java.lang.String getIdentifier()
                               throws java.rmi.RemoteException

containsChargedKey

public boolean containsChargedKey(java.lang.String key)
                           throws java.rmi.RemoteException
Returns true if the charged map contains a charged for the specified key.
Parameters:
key - key whose presence in the charged map is to be tested.
Returns:
true if the charged map contains a charged for the specified key.
Throws:
ClassCastException - if the key cannot be compared with the keys currently in the map.
NullPointerException - key is null and the charged map uses natural ordering, or its comparator does not tolerate null keys.

containsChargedValue

public boolean containsChargedValue(Quantity charged)
                             throws java.rmi.RemoteException
Returns true if the charged map maps one or more keys to the specified charged. This operation will probably require linear time.
Parameters:
charged - value of charged whose presence in the charged map is to be tested.

getChargedByKey

public Quantity getChargedByKey(java.lang.String key)
                         throws java.rmi.RemoteException
Returns the charged to which the charged map maps the specified key. Returns null if the map contains no charged for this key. A return value of null does not necessarily indicate that the map contains no charged for the key; it's also possible that the map explicitly maps the key to null. The containsKey operation may be used to distinguish these two cases.
Parameters:
key - key whose associated charged is to be returned.
Returns:
the charged to which the charged map maps the specified key, or null if the map contains no charged for the key.
Throws:
ClassCastException - key cannot be compared with the keys currently in the map.
NullPointerException - key is null and the charged map uses natural ordering, or its comparator does not tolerate null keys.
See Also:
#containsKey(Object)

getChargeds

public com.sun.java.util.collections.TreeMap getChargeds()
                                                  throws java.rmi.RemoteException
Returns a copy all of the chargeds from the specified map to the charged map. These chargeds replace any chargeds that the charged map had for any of the keys currently in the specified map.
Parameters:
chargeds - a copy of the chargeds.
Throws:
ClassCastException - class of a key or charged in the specified map prevents it from being stored in the charged map.
NullPointerException - the charged map does not permit null keys and a specified key is null.

getNumberOfChargeds

public int getNumberOfChargeds()
                        throws java.rmi.RemoteException
Returns the number of key-value mappings in the charged map.
Returns:
the number of key-value mappings in the charged map.

isChargedsEmpty

public boolean isChargedsEmpty()
                        throws java.rmi.RemoteException
Returns true if the charged map contains no key-value mappings.

Returns:
true if the charged map contains no key-value mappings.

putCharged

public void putCharged(java.lang.String key,
                       Quantity charged)
                throws java.rmi.RemoteException
Associates the specified charged with the specified key in the charged map. If the map previously contained a charged for this key, the old charged is replaced.
Parameters:
key - key with which the specified charged is to be associated.
charged - charged to be associated with the specified key.
Throws:
ClassCastException - key cannot be compared with the keys currently in the map.
NullPointerException - key is null and the charged map uses natural order, or its comparator does not tolerate null keys.

putChargeds

public void putChargeds(com.sun.java.util.collections.TreeMap chargeds)
                 throws java.rmi.RemoteException
Copies all of the chargeds from the specified charged map to this charged map. These chargeds replace any chargeds that this charged map had for any of the keys currently in the specified map.
Parameters:
charged - Chargeds to be stored in the charged map.
Throws:
ClassCastException - class of a key or charged in the specified map prevents it from being stored in the charged map.
NullPointerException - the charged map does not permit null keys and a specified key is null.

removeAllChargeds

public void removeAllChargeds()
                       throws java.rmi.RemoteException
Removes all chargeds from this charged map.

removeChargedByKey

public Quantity removeChargedByKey(java.lang.String key)
                            throws java.rmi.RemoteException
Removes the charged for this key from this charged map if present.
Parameters:
key - key with which the specified charged is associated.
Returns:
previous charged associated with specified key, or null if there was no charged for key. A null return can also indicate that the map previously associated null with the specified key.
Throws:
ClassCastException - key cannot be compared with the keys currently in the map.
NullPointerException - key is null and the charged map uses natural order, or its comparator does not tolerate null keys.

addFirstAccountEntry

public void addFirstAccountEntry(AccountEntry accountEntry)
                          throws java.rmi.RemoteException
Inserts the given accountEntry at the beginning of the accountEntry list.

addLastAccountEntry

public void addLastAccountEntry(AccountEntry accountEntry)
                         throws java.rmi.RemoteException
Appends the given accountEntry to the end of the accountEntry list. (Identical in function to the add method; included only for consistency.)

addAccountEntry

public void addAccountEntry(int index,
                            AccountEntry accountEntry)
                     throws java.rmi.RemoteException
Inserts the specified accountEntry at the specified position in the accountEntry list. Shifts the accountEntry currently at that position (if any) and any subsequent accountEntries to the right (adds one to their indices).
Parameters:
index - index at which the specified accountEntry is to be inserted.
accountEntry - accountEntry to be inserted.
Throws:
IndexOutOfBoundsException - if the specified index is out of range (index < 0 || index > size()).

addAccountEntry

public boolean addAccountEntry(AccountEntry accountEntry)
                        throws java.rmi.RemoteException
Appends the specified accountEntry to the end of the accountEntry list.
Parameters:
accountEntry - accountEntry to be appended to the accountEntry list.
Returns:
true (as per the general contract of Collection.add).

addAccountEntries

public boolean addAccountEntries(int index,
                                 com.sun.java.util.collections.LinkedList accountEntries)
                          throws java.rmi.RemoteException
Inserts all of the accountEntries in the specified collection into this list, starting at the specified position. Shifts the element currently at that position (if any) and any subsequent accountEntries to the right (increases their indices). The new accountEntries will appear in the accountEntry list in the order that they are returned by the specified collection's iterator.
Parameters:
index - index at which to insert first element from the specified collection.
accountEntries - accountEntries to be inserted into the accountEntry list.
Throws:
IndexOutOfBoundsException - if the specified index is out of range (index < 0 || index > size()).

addAccountEntries

public boolean addAccountEntries(com.sun.java.util.collections.LinkedList accountEntries)
                          throws java.rmi.RemoteException
Appends all of the accountEntries in the specified collection to the end of the accountEntry list, in the order that they are returned by the specified collection's iterator. The behavior of this operation is undefined if the specified collection is modified while the operation is in progress. (This implies that the behavior of this call is undefined if the specified Collection is the accountEntry list, and the accountEntry list is nonempty.)
Parameters:
accountEntries - accountEntries to be inserted into the accountEntry list.
Throws:
IndexOutOfBoundsException - if the specified index is out of range (index < 0 || index > size()).

containsAccountEntry

public boolean containsAccountEntry(AccountEntry accountEntry)
                             throws java.rmi.RemoteException
Returns true if the accountEntry list contains the specified element. More formally, returns true if and only if the accountEntry list contains at least one accountEntry e such that (o==null ? e==null : o.equals(e)).
Parameters:
accountEntry - accountEntry whose presence in the accountEntry list is to be tested.
Returns:
true if the accountEntry list contains the specified element.

getFirstAccountEntry

public AccountEntry getFirstAccountEntry()
                                  throws java.rmi.RemoteException
Returns the first accountEntry in the accountEntry list.
Returns:
the first accountEntry in the accountEntry list.

getLastAccountEntry

public AccountEntry getLastAccountEntry()
                                 throws java.rmi.RemoteException
Returns the last accountEntry in the accountEntry list.
Returns:
the last accountEntry in the accountEntry list.
Throws:
java.util.NoSuchElementException - if the accountEntry list is empty.

getNumberOfAccountEntries

public int getNumberOfAccountEntries()
                              throws java.rmi.RemoteException
Returns the number of accountEntries in the accountEntry list.
Returns:
the number of accountEntries in the accountEntry list.

getAccountEntry

public AccountEntry getAccountEntry(int index)
                             throws java.rmi.RemoteException
Returns the accountEntry at the specified position in the accountEntry list.
Parameters:
index - index of accountEntry to return.
Returns:
the accountEntry at the specified position in the accountEntry list.
Throws:
IndexOutOfBoundsException - if the specified index is is out of range (index < 0 || index >= size()).

getAccountEntries

public com.sun.java.util.collections.LinkedList getAccountEntries(int fromIndex,
                                                                  int toIndex)
                                                           throws java.rmi.RemoteException
Returns a view of the portion of the accountEntry list between fromIndex, inclusive, and toIndex, exclusive.
Parameters:
fromIndex - low endpoint (inclusive) of the subList.
toKey - high endpoint (exclusive) of the subList.
Returns:
a view of the specified range within the accountEntry list.
Throws:
IndexOutOfBoundsException - endpoint index value out of range (fromIndex < 0 || toIndex > size)
java.lang.IllegalArgumentException - endpoint indices out of order (fromIndex > toIndex)

getAccountEntries

public com.sun.java.util.collections.LinkedList getAccountEntries()
                                                           throws java.rmi.RemoteException
Returns all of the accountEntries in the accountEntry list.
Returns:
all of the accountEntries in the accountEntry list.

indexOfAccountEntry

public int indexOfAccountEntry(AccountEntry accountEntry)
                        throws java.rmi.RemoteException
Returns the index in the accountEntry list of the first occurrence of the specified element, or -1 if the accountEntry list does not contain this element. More formally, returns the lowest index i such that (o==null ? get(i)==null : o.equals(get(i))), or -1 if there is no such index.
Parameters:
accountEntry - accountEntry to search for.
Returns:
the index in the accountEntry list of the first occurrence of the specified element, or -1 if the accountEntry list does not contain this element.

isAccountEntriesEmtpy

public boolean isAccountEntriesEmtpy()
                              throws java.rmi.RemoteException
Returns true if the accountEntry list contains no accountEntries.

Returns:
true if the accountEntry list contains no accountEntries.

lastIndexOfAccountEntry

public int lastIndexOfAccountEntry(AccountEntry accountEntry)
                            throws java.rmi.RemoteException
Returns the index in the accountEntry list of the last occurrence of the specified element, or -1 if the accountEntry list does not contain this element. More formally, returns the highest index i such that (o==null ? get(i)==null : o.equals(get(i))), or -1 if there is no such index.
Parameters:
accountEntry - accountEntry to search for.
Returns:
the index in the accountEntry list of the last occurrence of the specified element, or -1 if the accountEntry list does not contain this element.

removeAllAccountEntries

public void removeAllAccountEntries()
                             throws java.rmi.RemoteException
Removes all of the accountEntries from the accountEntry list. This also removes them from the theory.smart.axiom.accounting.AccountEntryHome.

removeFirstAccountEntry

public AccountEntry removeFirstAccountEntry()
                                     throws java.rmi.RemoteException
Removes and returns the first accountEntry from the accountEntry list.
Returns:
the first accountEntry from the accountEntry list.
Throws:
java.util.NoSuchElementException - if the accountEntry list is empty.

removeLastAccountEntry

public AccountEntry removeLastAccountEntry()
                                    throws java.rmi.RemoteException
Removes and returns the last accountEntry from the accountEntry list.
Returns:
the last accountEntry from the accountEntry list.
Throws:
java.util.NoSuchElementException - if the accountEntry list is empty.

removeAccountEntry

public AccountEntry removeAccountEntry(int index)
                                throws java.rmi.RemoteException
Removes the accountEntry at the specified position in the accountEntry list. Shifts any subsequent accountEntries to the left (subtracts one from their indices). Returns the accountEntry that was removed from the accountEntry list.
Parameters:
index - the index of the accountEntry to removed.
Returns:
the accountEntry previously at the specified position.
Throws:
IndexOutOfBoundsException - if the specified index is out of range (index < 0 || index >= size()).

removeAccountEntry

public boolean removeAccountEntry(AccountEntry accountEntry)
                           throws java.rmi.RemoteException
Removes the first occurrence of the specified accountEntry in the accountEntry list. If the accountEntry list does not contain the element, it is unchanged. More formally, removes the accountEntry with the lowest index i such that (o==null ? get(i)==null : o.equals(get(i))) (if such an accountEntry exists).
Parameters:
accountEntry - accountEntry to be removed from the accountEntry list, if present.
Returns:
true if the accountEntry list contained the specified element.

setAccountEntry

public AccountEntry setAccountEntry(int index,
                                    AccountEntry accountEntry)
                             throws java.rmi.RemoteException
Replaces the accountEntry at the specified position in the accountEntry list with the specified element.
Parameters:
index - index of accountEntry to replace.
accountEntry - accountEntry to be stored at the specified position.
Returns:
the accountEntry previously at the specified position.
Throws:
IndexOutOfBoundsException - if the specified index is out of range (index < 0 || index >= size()).

containsBalanceKey

public boolean containsBalanceKey(java.lang.String key)
                           throws java.rmi.RemoteException
Returns true if the balance map contains a balance for the specified key.
Parameters:
key - key whose presence in the balance map is to be tested.
Returns:
true if the balance map contains a balance for the specified key.
Throws:
ClassCastException - if the key cannot be compared with the keys currently in the map.
NullPointerException - key is null and the balance map uses natural ordering, or its comparator does not tolerate null keys.

containsBalanceValue

public boolean containsBalanceValue(Quantity balance)
                             throws java.rmi.RemoteException
Returns true if the balance map maps one or more keys to the specified balance. This operation will probably require linear time.
Parameters:
balance - value of balance whose presence in the balance map is to be tested.

getBalanceByKey

public Quantity getBalanceByKey(java.lang.String key)
                         throws java.rmi.RemoteException
Returns the balance to which the balance map maps the specified key. Returns null if the map contains no balance for this key. A return value of null does not necessarily indicate that the map contains no balance for the key; it's also possible that the map explicitly maps the key to null. The containsKey operation may be used to distinguish these two cases.
Parameters:
key - key whose associated balance is to be returned.
Returns:
the balance to which the balance map maps the specified key, or null if the map contains no balance for the key.
Throws:
ClassCastException - key cannot be compared with the keys currently in the map.
NullPointerException - key is null and the balance map uses natural ordering, or its comparator does not tolerate null keys.
See Also:
#containsKey(Object)

getBalances

public com.sun.java.util.collections.TreeMap getBalances()
                                                  throws java.rmi.RemoteException
Returns a copy all of the balances from the specified map to the balance map. These balances replace any balances that the balance map had for any of the keys currently in the specified map.
Parameters:
balances - a copy of the balances.
Throws:
ClassCastException - class of a key or balance in the specified map prevents it from being stored in the balance map.
NullPointerException - the balance map does not permit null keys and a specified key is null.

getNumberOfBalances

public int getNumberOfBalances()
                        throws java.rmi.RemoteException
Returns the number of key-value mappings in the balance map.
Returns:
the number of key-value mappings in the balance map.

isBalancesEmpty

public boolean isBalancesEmpty()
                        throws java.rmi.RemoteException
Returns true if the balance map contains no key-value mappings.

Returns:
true if the balance map contains no key-value mappings.

putBalance

public void putBalance(java.lang.String key,
                       Quantity balance)
                throws java.rmi.RemoteException
Associates the specified balance with the specified key in the balance map. If the map previously contained a balance for this key, the old balance is replaced.
Parameters:
key - key with which the specified balance is to be associated.
balance - balance to be associated with the specified key.
Throws:
ClassCastException - key cannot be compared with the keys currently in the map.
NullPointerException - key is null and the balance map uses natural order, or its comparator does not tolerate null keys.

putBalances

public void putBalances(com.sun.java.util.collections.TreeMap balances)
                 throws java.rmi.RemoteException
Copies all of the balances from the specified balance map to this balance map. These balances replace any balances that this balance map had for any of the keys currently in the specified map.
Parameters:
balance - Balances to be stored in the balance map.
Throws:
ClassCastException - class of a key or balance in the specified map prevents it from being stored in the balance map.
NullPointerException - the balance map does not permit null keys and a specified key is null.

removeAllBalances

public void removeAllBalances()
                       throws java.rmi.RemoteException
Removes all balances from this balance map.

removeBalanceByKey

public Quantity removeBalanceByKey(java.lang.String key)
                            throws java.rmi.RemoteException
Removes the balance for this key from this balance map if present.
Parameters:
key - key with which the specified balance is associated.
Returns:
previous balance associated with specified key, or null if there was no balance for key. A null return can also indicate that the map previously associated null with the specified key.
Throws:
ClassCastException - key cannot be compared with the keys currently in the map.
NullPointerException - key is null and the balance map uses natural order, or its comparator does not tolerate null keys.

withdraw

public AccountEntry withdraw(Account to,
                             Quantity qty)
                      throws java.rmi.RemoteException,
                             PostingRuleException
Create a transaction that decreases the quantity of this account. The quantity is deposited into the account specified. The desposit represents a movement of some quantity from this account into another one.

applyTransaction

public void applyTransaction(AccountEntry trans)
                      throws java.rmi.RemoteException,
                             PostingRuleException
Apply the quantity to the balance of the account. If this account is the "to" account, record the amount as a deposit. If this account is the "from" account, record the amount as a withdrawal.

applyDeposit

public void applyDeposit(AccountEntry trans)
                  throws java.rmi.RemoteException,
                         PostingRuleException
Increase the balance of the account by the quantity and store a reference to this transaction.

applyWithdrawal

public void applyWithdrawal(AccountEntry trans)
                     throws java.rmi.RemoteException,
                            PostingRuleException
Reduce the balance of the account by the quantity and store a reference to this transaction.

deposit

public AccountEntry deposit(Account from,
                            Quantity qty)
                     throws java.rmi.RemoteException,
                            PostingRuleException
Create a transaction that increases the quantity of this account. The quantity is withdrawn from the account specified. The desposit represents a movement of some quantity from another account into this one.

add

public AccountEntry add(Quantity qty)
                 throws java.rmi.RemoteException,
                        PostingRuleException
This method creates a one sided transaction that increases the quantity in the account. This is how elements enter the system.

remove

public AccountEntry remove(Quantity qty)
                    throws java.rmi.RemoteException,
                           PostingRuleException
Create a one sided transaction that reduces the quantity in the account. This is how elements leave the system.

reverse

public AccountEntry reverse(AccountEntry trans)
                     throws java.rmi.RemoteException,
                            PostingRuleException
Create a transaction that reverses the original.

post

public void post(AccountEntry entry)
          throws java.rmi.RemoteException,
                 PostingRuleException
Execute all of the posting rules associated with this account with the specified AccountEntry as a paramter. This method is called upon completion of any method that modifies the balance of the account.

post

public void post(PostingRule rule,
                 AccountEntry entry)
          throws java.rmi.RemoteException,
                 PostingRuleException
Executea specific posting rule with the specified AccountEntry as a paramter.

setDefaultPostingRule

public void setDefaultPostingRule(PostingRule rule)
                           throws java.rmi.RemoteException

charge

public void charge(java.lang.String acctEntry)
            throws java.rmi.RemoteException
Cause the specified AccountEntry to set to charge and update the charged balance.

charge

public void charge(PostingRule rule,
                   AccountEntry entry)
            throws java.rmi.RemoteException

setDefaultChargingRule

public void setDefaultChargingRule(PostingRule rule)
                            throws java.rmi.RemoteException

BEA Systems, Inc.

Copyright © 2000 BEA Systems, Inc. All Rights Reserved