orderprocessing
Class Invoice

java.lang.Object
  |
  +--orderprocessing.Invoice
All Implemented Interfaces:
java.io.Serializable

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

This class represents what will ship from a customer order.

Additionally, this class maintains a collection of all Invoices.

See Also:
Serialized Form

Constructor Summary
Invoice(Order order, java.util.ArrayList shipableItems)
          Create an Invoice for a particular customer and a sequence of items ordered
 
Method Summary
static void close(java.io.ObjectOutputStream out)
          Write all of the Invoice data for all invoices to an output stream
 Customer customer()
          Retrieve the customer that generated this invoice
 void display()
          Display on standard out the information about Items that will ship, including extended prices and a total
static void dump()
          Display all of the invoices on standard output.
 boolean equals(java.lang.Object other)
           
 void format(java.io.BufferedWriter file)
          Format the invoices for printing
static void formatAll(java.io.BufferedWriter file)
          Format all of the invoices (no implied order) and write to output
static Invoice get(java.lang.String key)
          Get a particular invoice object from its customer number.
 int hashCode()
           
 CalculationCalendar invoiceDate()
          Retrieve the date the invoice was generated
static java.util.Iterator invoices()
          Provide an iteration service over all known invoices.
 java.lang.String key()
          Return the invoice number
static java.util.Iterator keys()
          Provide an iterator over the invoice numbers.
static void open(java.io.ObjectInputStream in)
          Read all invoice data for all invoices into the program at the beginning of a run
 Order order()
          Retrieve the order that generated this invoice
 CalculationCalendar paymentDueDate()
          Retrieve the date payment is due for this invoice
 java.util.Iterator shipableItems()
          Iterate over the shippable items for this invoice
 CalculationCalendar shipDate()
          Retrieve the date this invoice will/did ship
 int size()
          Retrieve the number of line items on this invoice
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Invoice

public Invoice(Order order,
               java.util.ArrayList shipableItems)
Create an Invoice for a particular customer and a sequence of items ordered
Parameters:
order - The order from which this invoice originates
shipableItems - A ArrayList of OrderItems representing the items shipped
Method Detail

customer

public Customer customer()
Retrieve the customer that generated this invoice
Returns:
the customer object

shipableItems

public java.util.Iterator shipableItems()
Iterate over the shippable items for this invoice
Returns:
an iterator over shippable items (no implied order)

size

public int size()
Retrieve the number of line items on this invoice
Returns:
the number of line items.

shipDate

public CalculationCalendar shipDate()
Retrieve the date this invoice will/did ship
Returns:
the invoice ship date

invoiceDate

public CalculationCalendar invoiceDate()
Retrieve the date the invoice was generated
Returns:
the invoice generation date

order

public Order order()
Retrieve the order that generated this invoice
Returns:
the order

key

public java.lang.String key()
Return the invoice number
Returns:
the invoice number

paymentDueDate

public CalculationCalendar paymentDueDate()
Retrieve the date payment is due for this invoice
Returns:
the payment due date

display

public void display()
Display on standard out the information about Items that will ship, including extended prices and a total

equals

public boolean equals(java.lang.Object other)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

formatAll

public static void formatAll(java.io.BufferedWriter file)
Format all of the invoices (no implied order) and write to output
Parameters:
file - the file to write to

format

public void format(java.io.BufferedWriter file)
            throws java.io.IOException
Format the invoices for printing
Parameters:
file - the file to write the formatted invoice on
Throws:
java.io.IOException -  

get

public static Invoice get(java.lang.String key)
Get a particular invoice object from its customer number.
Parameters:
key - the invoice number
Returns:
the invoice object or null if none

close

public static final void close(java.io.ObjectOutputStream out)
                        throws java.io.IOException
Write all of the Invoice data for all invoices to an output stream
Parameters:
out - the Object stream to write to
Throws:
java.io.IOException -  

open

public static final void open(java.io.ObjectInputStream in)
                       throws java.io.IOException,
                              java.lang.ClassNotFoundException
Read all invoice data for all invoices into the program at the beginning of a run
Parameters:
in - the Object stream to read from
Throws:
java.io.IOException -  
java.lang.ClassNotFoundException -  

invoices

public static java.util.Iterator invoices()
Provide an iteration service over all known invoices. The iterator will return invoice objects. There is no implied ordering.
Returns:
an Iterator over the invoice part of the database

keys

public static java.util.Iterator keys()
Provide an iterator over the invoice numbers. The iterator will return just the invoice numbers as Strings. There is no implied ordering.
Returns:
an iterator over the invoice numbers (strings).

dump

public static void dump()
Display all of the invoices on standard output. No order implied.