ecash.kernel
Class BuyerPurse

java.lang.Object
  |
  +--ecash.kernel.BuyerPurse
All Implemented Interfaces:
java.io.Serializable

public class BuyerPurse
extends java.lang.Object
implements java.io.Serializable

Contains all the notes and information used to build them. Calls to the add() and the remove() methods will be taken into account only after a call to addCommit() and removeCommit() respectively. The clear() method will initialize this process. Each item of this list is a BuyerPurseUnit object.

Author:
Michel Deriaz
See Also:
BuyerPurseUnit, Serialized Form

Constructor Summary
BuyerPurse()
          Creates a BuyerPurse.
 
Method Summary
 void add(Note note, FullNotesList fullNotesList, BankChoice bankChoice)
          Adds a new note and its building information.
 void addCommit()
          Let's take into effect all the calls made to the add() method, and then calls the clear() method.
 void clear()
          Initializes the data for the add() and the remove() methods.
 int findAmount(java.lang.String amount)
          Returns the first index of a note with the specified amount.
 java.util.Vector getAmountList()
          Returns the amounts list of the notes.
 BankChoice getBankChoice(int index)
          Gets the BankChoice of the specified note.
 FullNotesList getFullNotesList(int index)
          Gets the FullNotesList of the specified note.
 Note getNote(int index)
          Gets the specified note.
 void initFindAmount()
          Initializes the findAmount() method.
 void remove(int index)
          Removes a note.
 void removeCommit()
          Let's take into effect all the calls made to the remove() method, and then calls the clear() method.
 int size()
          Returns the number of notes.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BuyerPurse

public BuyerPurse()
Creates a BuyerPurse.

Method Detail

add

public void add(Note note,
                FullNotesList fullNotesList,
                BankChoice bankChoice)
Adds a new note and its building information.

Parameters:
note - the note
fullNotesList - all the information used to create the note, and also the other notes (the bank gets several notes and then choose wich one she will sign
bankChoice - the note chosen by the bank
See Also:
addCommit()

addCommit

public void addCommit()
Let's take into effect all the calls made to the add() method, and then calls the clear() method.

See Also:
add(ecash.kernel.Note, ecash.kernel.FullNotesList, ecash.kernel.BankChoice)

remove

public void remove(int index)
Removes a note.

Parameters:
index - the index of the note to remove
See Also:
removeCommit()

removeCommit

public void removeCommit()
Let's take into effect all the calls made to the remove() method, and then calls the clear() method.

See Also:
remove(int)

getNote

public Note getNote(int index)
Gets the specified note.

Parameters:
index - the index in the list

getFullNotesList

public FullNotesList getFullNotesList(int index)
Gets the FullNotesList of the specified note.

Parameters:
index - the index in the list

getBankChoice

public BankChoice getBankChoice(int index)
Gets the BankChoice of the specified note.

Parameters:
index - the index in the list

getAmountList

public java.util.Vector getAmountList()
Returns the amounts list of the notes. Each entry of this Vector is a String.

Returns:
a vector containing the amounts of all the notes

size

public int size()
Returns the number of notes.

Returns:
the number of notes

clear

public void clear()
Initializes the data for the add() and the remove() methods.


initFindAmount

public void initFindAmount()
Initializes the findAmount() method.


findAmount

public int findAmount(java.lang.String amount)
Returns the first index of a note with the specified amount. Then the note is "marked" in order to avoid to return the same note when the method is called again with the same parameter. The initFindAmount() will "unmark" all the notes.

Parameters:
amount - the amount to find
Returns:
the index in the list