package resources; /** * Author: W. M. Farmer
* Revised: February 21, 2007
*
* Description: The objects of this class are Elements which hold a String. * * @author W. M. Farmer */ public class StringElement implements Element { private String contents_; /** * Constructs a StringElement that holds a String. * * @param s a String */ public StringElement(String s) { contents_ = s; } /** * Checks if the String held by this StringElement is equal to the * String held by another StringElement. * * @param e a StringElement * @return true iff the StringElements are equal */ public boolean same(Element e) { return e != null && e instanceof StringElement && toString().equals(((StringElement)e).toString()); } /** * Returns the String held by this StringElement. * * @return a String */ public String toString() { return contents_; } }