/* -*- Mode: java; indent-tabs-mode: nil; c-basic-offset: 2 -*- * * The contents of this file are subject to the Mozilla Public License * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and limitations * under the License. * * The Original Code is the Grendel mail/news client. * * The Initial Developer of the Original Code is Netscape Communications * Corporation. Portions created by Netscape are Copyright (C) 1997 * Netscape Communications Corporation. All Rights Reserved. * * Created: Eric Bina , 30 Oct 1997. */ package grendel.storage.addressparser; import java.io.*; import java.util.*; /** * Stores a RFC822 mailbox. Defined as being either a * addr-spec (local-part@domain), or a route-addr * preceeded by a phrase (phrase <local-part@domain>). *

* Mere humans tends to consider this a name and an * address. In the first addr-spec form, the name is usually * within a RFC822 comment preceeding the addr-spec. * If there is no comment, a mailbox name may be null. *

* Normally used only as a data type returned by the RFC822MailboxList * class. * * @see RFC822MailboxList * @author Eric Bina */ public class RFC822Mailbox { private String name, address; /** * Should be created only by the RFC822MailboxList class. * * @see RFC822MailboxList */ public RFC822Mailbox(String name, String address) { this.name = name; this.address = address; } public String getName() { return(this.name); } public String getAddress() { return(this.address); } /** * Creates a valid RFC822 mailbox. Since we don't like to lose * the comment information, this will reform addresses like: *
(Eric Bina) ebina@netscape.com
* to addresses like: *
"Eric Bina" <ebina@netscape.com>
*/ public String getMailboxString() { String mailbox = null; if ((this.name != null)&&(this.name.equalsIgnoreCase("") == false)) { mailbox = this.name + " <" + this.address + ">"; } else { mailbox = this.address; } return(mailbox); } }