|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--orderprocessing.Customer
This class maintains information about a single customer
Note that any changes to the public part of this class or any change in the fields will require versioning. This is because these objects are stored in the object database for this application.
This class can serve as a model for other classes that need versioning. Be sure to add versioning infrastructure to them before you include them in the database for the first time.
Note that Addresses are already implicitly included in the database since they are written whenever a Customer is written.
Additionally, this class maintains a collection of all customers.
Constructor Summary | |
Customer(java.lang.String name,
Address billingAddress)
create a customer object with default values for ship address and terms |
|
Customer(java.lang.String name,
Address billingAddress,
Address shipAddress)
Create a customer object with default terms. |
|
Customer(java.lang.String name,
Address billingAddress,
Address shipAddress,
BillingTerms billingTerms)
create a customer object with all options specified. |
Method Summary | |
Address |
billingAddress()
Retrieve the customer's billing address |
BillingTerms |
billingTerms()
Retrieve this customer's default billing terms |
void |
billingTerms(BillingTerms terms)
Set new billing terms for this customer |
static void |
close(java.io.ObjectOutputStream out)
Write all of the customer data for all customers to an output stream |
static java.util.Iterator |
customers()
Provide an iteration service over all known customers. |
void |
display()
Display this customer info on standard output |
static void |
dump()
Display all of the customers on standard output. |
boolean |
equals(java.lang.Object other)
|
static Customer |
get(java.lang.String customerNumber)
Get a particular customer object from its customer number. |
int |
hashcode()
|
boolean |
isActive()
Tell if a customer is active. |
java.lang.String |
key()
Retrieve the customer number |
static java.util.Iterator |
keys()
Provide an iterator over the customer numbers. |
java.lang.String |
name()
Retrieve the customer name |
void |
name(java.lang.String name)
Change the name of this customer |
static void |
open(java.io.ObjectInputStream in)
Read all customer data for all customers into the program at the beginning of a run |
static void |
remove(java.lang.String key)
Make a customer inactive. |
Address |
shippingAddress()
Retrieve the customer's ship address |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public Customer(java.lang.String name, Address billingAddress)
public Customer(java.lang.String name, Address billingAddress, Address shipAddress)
public Customer(java.lang.String name, Address billingAddress, Address shipAddress, BillingTerms billingTerms)
name
- the customer name.billingAddress
- the customer billing addressshipAddress
- the ship address if not specified on an orderbillingTerms
- the billing terms if not specified on an order.
Note: As with ALL constructors in ALL classes, the verification of the data
must occur BEFORE you call the constructor. Only call a constructor when
the data is correct to create a fully usable object that maintains all
of its invariants. Never create a partially complete object unless you take
foolproof steps to complete the process of creation.Method Detail |
public java.lang.String key()
public java.lang.String name()
public Address billingAddress()
public Address shippingAddress()
public BillingTerms billingTerms()
public void billingTerms(BillingTerms terms)
terms
- the new billing termspublic void name(java.lang.String name)
name
- the new customer namepublic void display()
public boolean equals(java.lang.Object other)
equals
in class java.lang.Object
public int hashcode()
public java.lang.String toString()
toString
in class java.lang.Object
public static final void close(java.io.ObjectOutputStream out) throws java.io.IOException
out
- the Object stream to write tojava.io.IOException
- public boolean isActive()
public static final void open(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException
in
- the Object stream to read fromjava.io.IOException
- java.lang.ClassNotFoundException
- public static java.util.Iterator customers()
public static java.util.Iterator keys()
public static void dump()
public static Customer get(java.lang.String customerNumber)
customerNumber
- the customer's numberpublic static void remove(java.lang.String key)
key
- the customer to "remove"
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |