Building Parsers with Java

sjm.examples.coffee
Class Coffee

java.lang.Object
  |
  +--sjm.examples.coffee.Coffee

public class Coffee
extends java.lang.Object
implements PubliclyCloneable

A Coffee object represents a type of coffee. Each type of coffee has a name, and may have a former name. Each type also has a roast, which may be Regular, French, or Italian. We offer some types of coffee in two roasts, where French is an alternative to the normal roast. Finally, each type has a country of origin, and a price per pound.


Field Summary
protected  boolean alsoOfferFrench
           
protected  java.lang.String country
           
protected  java.lang.String formerName
           
protected  java.lang.String name
           
protected  double price
           
protected  java.lang.String roast
           
 
Constructor Summary
Coffee()
           
 
Method Summary
 java.lang.Object clone()
          Return a copy of this object.
static boolean equal(java.lang.Object o1, java.lang.Object o2)
          Compares two objects for equality, treating nulls carefullly, and relying on the first object's implementation of equals().
 boolean equals(java.lang.Object o)
          Compares this object against the specified object.
 boolean getAlsoOfferFrench()
          Return true, if we offer a french roast version of this coffee in addition to another roast.
 java.lang.String getCountry()
          Return the country of origin for of this type of coffee's beans.
 java.lang.String getFormerName()
          Return a former name for this type of coffee.
 java.lang.String getName()
          Return the name of this type of coffee.
 double getPrice()
          Return the price per pound of this coffee.
 java.lang.String getRoast()
          Return the name of the roast of this coffee.
 void setAlsoOfferFrench(boolean alsoOfferFrench)
          Set the truth of the notion that, in addition to some other type of roast, we offer a french roast version of this coffee.
 void setCountry(java.lang.String country)
          Set the country of origin for of this type of coffee's beans.
 void setFormerName(java.lang.String formerName)
          Set a former name of this coffee.
 void setName(java.lang.String name)
          Set the name of this coffee.
 void setPrice(double price)
          Set the price per pound of this coffee
 void setRoast(java.lang.String roast)
          Set the roast of this coffee.
 java.lang.String toString()
          Return a textual description of this coffee type.
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

name

protected java.lang.String name

formerName

protected java.lang.String formerName

roast

protected java.lang.String roast

alsoOfferFrench

protected boolean alsoOfferFrench

country

protected java.lang.String country

price

protected double price
Constructor Detail

Coffee

public Coffee()
Method Detail

clone

public java.lang.Object clone()
Return a copy of this object.
Specified by:
clone in interface PubliclyCloneable
Overrides:
clone in class java.lang.Object
Returns:
a copy of this object

equal

public static boolean equal(java.lang.Object o1,
                            java.lang.Object o2)
Compares two objects for equality, treating nulls carefullly, and relying on the first object's implementation of equals().
Parameters:
o1 - one object
o2 - the other
Returns:
true if the objects are equal and false otherwise.

equals

public boolean equals(java.lang.Object o)
Compares this object against the specified object. The result is true if and only if the argument is not null and is a Coffee object whose attributes all equal this object's attributes.
Overrides:
equals in class java.lang.Object
Parameters:
o - the object to compare with.
Returns:
true if the objects are equal and false otherwise.

getAlsoOfferFrench

public boolean getAlsoOfferFrench()
Return true, if we offer a french roast version of this coffee in addition to another roast.
Returns:
true, if we offer a french roast version of this coffee in addition to another roast

getCountry

public java.lang.String getCountry()
Return the country of origin for of this type of coffee's beans.
Returns:
the country of origin for of this type of coffee's beans

getFormerName

public java.lang.String getFormerName()
Return a former name for this type of coffee.
Returns:
a former name for this type of coffee

getName

public java.lang.String getName()
Return the name of this type of coffee.
Returns:
the name of this type of coffee

getPrice

public double getPrice()
Return the price per pound of this coffee.
Returns:
the price per pound of this coffee

getRoast

public java.lang.String getRoast()
Return the name of the roast of this coffee.
Returns:
the name of the roast of this coffee

setAlsoOfferFrench

public void setAlsoOfferFrench(boolean alsoOfferFrench)
Set the truth of the notion that, in addition to some other type of roast, we offer a french roast version of this coffee.
Parameters:
boolean - true, if we offer a french roast version of this coffee

setCountry

public void setCountry(java.lang.String country)
Set the country of origin for of this type of coffee's beans.
Parameters:
String - the country

setFormerName

public void setFormerName(java.lang.String formerName)
Set a former name of this coffee.
Parameters:
String - the name

setName

public void setName(java.lang.String name)
Set the name of this coffee.
Parameters:
String - the name

setPrice

public void setPrice(double price)
Set the price per pound of this coffee
Parameters:
double - the price

setRoast

public void setRoast(java.lang.String roast)
Set the roast of this coffee.
Parameters:
String - the roast

toString

public java.lang.String toString()
Return a textual description of this coffee type.
Overrides:
toString in class java.lang.Object
Returns:
a textual description of this coffee type

by Steve Metsker