/**
 * A class for manipulating email addresses
 *
 * @author  Prof. David Bernstein
 * @version 1.0
 */
public class EmailAddress
{
//[getHost
    /**
     * Return the host portion of an email address
     *
     * @param  address   A String representation of an email address
     * @return The host portion of the email address
     */
    public static String getHost(String address) throws IllegalArgumentException
    {
       int     index;
       
       index = address.indexOf("@");
       if ((index <= 0) || (index >= address.length()-1))
       {
          throw new IllegalArgumentException("Misplaced or missing @.");
       }
       else
       {
          return address.substring(index+1);
       }

       // Note: This is equivalent to:
       //
       // if ((index <= 0) || (index >= address.length()-1))
       // {
       //     throw new IllegalArgumentException("Misplaced or missing @.");
       // }
       //
       // return address.substring(index+1);
    }
//]getHost
}
