/** * Information on someone on the net. Right now, includes only email * address and name. The email address should take the form name@host. * The name should not include quotation marks. Neither should be null: * use the empty string if you want an empty name. * * @author Sam Rebelsky * @version 1.0 of September 1999 */ public class NetEntity { // +--------+-------------------------------------------------- // | Fields | // +--------+ /** The person's email address. */ protected String email; /** The person's name (or alias). */ protected String name; // +--------------+-------------------------------------------- // | Constructors | // +--------------+ /** * Create a new entity, specifying email and name. See the intro * for restrictions on email and name. */ public NetEntity(String email, String name) { this.email = email; this.name = name; } // NetEntity(String,String) // +---------+------------------------------------------------- // | Methods | // +---------+ /** Get the email address. */ public String getEmail() { return this.email; } // getEmail() /** Get the name or alias. */ public String getName() { return this.name; } // getName() /** * Set the email address. See the introduction for restrictions. * Returns the old email address. */ public String setEmail(String email) { String old = email; this.email = email; return old; } // setEmail(String) /** * Set the name. *See the introduction for restrictions. * Returns the old name. */ public String setName(String name) { String old = name; this.name = name; return old; } // setName(String) /** Convert to a string for printing. */ public String toString() { if (name.equals("")) { return "<" + this.email + ">"; } else { return "\"" + this.name + "\"" + "<" + this.email + ">"; } } // toString() } // class NetEntity