adams.core.net
Class EmailAddressBook

java.lang.Object
  extended by adams.core.net.EmailAddressBook

public class EmailAddressBook
extends Object

Helper class for email addresses.

Version:
$Revision: 6908 $
Author:
fracpete (fracpete at waikato dot ac dot nz)

Field Summary
static String FILENAME
          the properties filename.
protected  Properties m_Properties
          the underlying properties.
protected static EmailAddressBook m_Singleton
          the singleton.
 
Constructor Summary
EmailAddressBook()
           
 
Method Summary
 Object addContact(EmailContact value)
          Adds the contact to the properties.
static String createKey(EmailContact value)
          Generates a property key for the contact.
static EmailContact fromString(String s)
          Turns the string obtained from the properties file into an object.
 EmailContact getContact(EmailAddress address)
          Returns the contact associated with the email address, null if not found.
 EmailContact getContact(EmailAddress address, EmailContact defValue)
          Returns the contact associated with the given email address, the default value if not found.
 List<EmailContact> getContacts()
          Returns all stored contacts.
 Properties getProperties()
          Returns the properties, loads them if necessary.
static EmailAddressBook getSingleton()
          Returns the singleton.
 boolean save()
          Saves the properties.
static String toString(EmailContact value)
          Turns the object into a string to be stored in the properties file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FILENAME

public static final String FILENAME
the properties filename.

See Also:
Constant Field Values

m_Singleton

protected static EmailAddressBook m_Singleton
the singleton.


m_Properties

protected Properties m_Properties
the underlying properties.

Constructor Detail

EmailAddressBook

public EmailAddressBook()
Method Detail

getProperties

public Properties getProperties()
Returns the properties, loads them if necessary.

Returns:
the properties

save

public boolean save()
Saves the properties.


addContact

public Object addContact(EmailContact value)
Adds the contact to the properties.

Parameters:
value - the contact to add

getContact

public EmailContact getContact(EmailAddress address)
Returns the contact associated with the email address, null if not found.

Parameters:
address - the email address to look up
Returns:
the contact, or null if not found

getContact

public EmailContact getContact(EmailAddress address,
                               EmailContact defValue)
Returns the contact associated with the given email address, the default value if not found.

Parameters:
address - the email address to look up
Returns:
the contact, or the default if not found

getContacts

public List<EmailContact> getContacts()
Returns all stored contacts.

Returns:
the contacts

fromString

public static EmailContact fromString(String s)
Turns the string obtained from the properties file into an object.

Parameters:
s - the string to parse
Returns:
the generated object, null if failed to generate

createKey

public static String createKey(EmailContact value)
Generates a property key for the contact.

Parameters:
value - the object to generate the key for
Returns:
the generated key

toString

public static String toString(EmailContact value)
Turns the object into a string to be stored in the properties file.

Parameters:
value - the object to convert
Returns:
the generated string

getSingleton

public static EmailAddressBook getSingleton()
Returns the singleton.

Returns:
the singleton


Copyright © 2013 University of Waikato, Hamilton, NZ. All Rights Reserved.