Holger's
Java API

com.antelmann.crm
Class GlobalAddress

java.lang.Object
  extended by com.antelmann.crm.GlobalAddress
All Implemented Interfaces:
XMLSerializable, GeoEncoded, DetailedString, Forgeable<GlobalAddress>, Localizable, Serializable
Direct Known Subclasses:
ImmutableGlobalAddress

public class GlobalAddress
extends Object
implements Serializable, Forgeable<GlobalAddress>, DetailedString, GeoEncoded, XMLSerializable, Localizable

represents means to store addresses based on their way of transport; in addition, it also provides a Locale and a salutation.

Since:
5. Juli 2007, 11:39
Author:
Holger Antelmann
See Also:
Serialized Form

Nested Class Summary
static class GlobalAddress.Transport
           
 
Nested classes/interfaces inherited from interface com.antelmann.util.Localizable
Localizable.Adapter
 
Field Summary
static DataFlavor GLOBAL_ADDRESS_FLAVOR
           
 
Constructor Summary
GlobalAddress()
           
GlobalAddress(GlobalAddress adr)
           
 
Method Summary
 void clearAll()
           
 boolean containsTransport(GlobalAddress.Transport t)
           
 boolean ensureSnailMail()
          ensures that a SnailMailAddress exists.
 boolean equals(Object obj)
           
 void exportXML(OutputStream out)
          exports the entire object as XML and writes it to the given Writer, so that the object can be reconstructed with importXML(InputSource).
 String getAddressDetailString()
          provides a (multi-line) String that displays all relevant address data
 GlobalAddress.Transport[] getAvailableTransports()
           
 BankAccount getBankAccount()
           
 String getCountry()
          shortcut to the SnailMailAddress
 String getEmail()
          returns the email address set for this instance (if any)
 PhoneNumber getFax()
           
 GeoPoint getGeoPoint()
           
 String getIM()
          returns the address-String for instant messaging
 Locale getLocale()
          if a Locale is explicitly set to a non-null value, it is returned; otherwise, the locale is constructed using the country code.
static Hashtable<Class<?>,PersistenceDelegate> getPersistenceDelegates()
           
 String getSalutation()
          provides a suitable String to address the person/company/entity in a letter header
 PhoneNumber getSMS()
           
 SnailMailAddress getSnailMail()
           
 String getSnailMailAddressString()
           
 String getSnailMailAddressString(Locale l)
           
 Locale getSpecifiedLocale()
          returns the locale that was explicitly set by setLocale(Locale), if any
 TimeZone getTimeZone()
           
 String getTitle()
          shortcut to the SnailMailAddress
 URL getURL()
           
 Object getValuefor(GlobalAddress.Transport t)
           
 PhoneNumber getVoice()
           
 boolean hasEmail()
           
 int hashCode()
           
 boolean hasSnailMail()
           
 void importXML(InputStream source)
          The object is fully reinitialized with the XML data contained in the given ImputSource, so that the object has the same state as it had during export.
 boolean isEmpty()
           
 void removeAddress(GlobalAddress.Transport t)
           
 boolean sameAs(GlobalAddress adr)
           
 void setAllFrom(GlobalAddress ga)
          initializes the internal map based on the content of the given address instance
 void setBankAccount(BankAccount ba)
           
 void setEmail(String email)
          allows to specify an email address for this instance
 void setFax(PhoneNumber fax)
           
 void setFax(String number)
           
 void setGeoPoint(GeoPoint gp)
           
 void setIM(String im)
           
 void setLocale(Locale locale)
           
 void setLocale(Locale locale, Object context)
          sets the Locale for this object so that all subsequent return values of method calls to this instance can be localized accordingly until a different Locale is set.
 void setSalutation(String salutation)
           
 void setSMS(PhoneNumber sms)
           
 void setSMS(String number)
           
 void setSnailMail(SnailMailAddress adr)
           
 void setTimeZone(TimeZone tz)
           
 void setTitle(String title)
          shortcut to the SnailMailAddress
 void setURL(URL url)
           
 void setValueFor(GlobalAddress.Transport t, Object address)
           
 void setVoice(PhoneNumber phone)
           
 void setVoice(String phone)
           
 boolean supportsTransport(GlobalAddress.Transport t)
          determines if the given transport type is supported; returns true by default
 String toDetailedString()
          provides full details of this instance in a String.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

GLOBAL_ADDRESS_FLAVOR

public static final DataFlavor GLOBAL_ADDRESS_FLAVOR
Constructor Detail

GlobalAddress

public GlobalAddress()

GlobalAddress

public GlobalAddress(GlobalAddress adr)
Method Detail

clearAll

public void clearAll()

isEmpty

public boolean isEmpty()

ensureSnailMail

public boolean ensureSnailMail()
ensures that a SnailMailAddress exists.

Returns:
true if an empty SnailMailAddress had to be added

getPersistenceDelegates

public static Hashtable<Class<?>,PersistenceDelegate> getPersistenceDelegates()

exportXML

public void exportXML(OutputStream out)
               throws IOException
Description copied from interface: XMLSerializable
exports the entire object as XML and writes it to the given Writer, so that the object can be reconstructed with importXML(InputSource). The given stream is neither flushed nor closed, so that other data may be effectively written to the InputSource after the method returned.

Specified by:
exportXML in interface XMLSerializable
Throws:
IOException
See Also:
XMLSerializable.importXML(InputStream)

importXML

public void importXML(InputStream source)
               throws SAXException,
                      IOException
Description copied from interface: XMLSerializable
The object is fully reinitialized with the XML data contained in the given ImputSource, so that the object has the same state as it had during export.

Specified by:
importXML in interface XMLSerializable
Throws:
SAXException
IOException
See Also:
XMLSerializable.exportXML(OutputStream)

toDetailedString

public String toDetailedString()
Description copied from interface: DetailedString
provides full details of this instance in a String. In case the String contains multiple lines, it is recommended to use '\n' rather than the platform specific line-break for better compatibility.

Specified by:
toDetailedString in interface DetailedString
Returns:
a (potentially multi-line) String providing full details on this object instance

getAddressDetailString

@Localized
public String getAddressDetailString()
provides a (multi-line) String that displays all relevant address data


setAllFrom

public void setAllFrom(GlobalAddress ga)
                throws NullPointerException,
                       IllegalArgumentException
initializes the internal map based on the content of the given address instance

Specified by:
setAllFrom in interface Forgeable<GlobalAddress>
Parameters:
ga - the object whose behavior is to be copied to this instance
Throws:
NullPointerException - if the given object parameter is null
IllegalArgumentException - if the given object contains properties that for some reason cannot be copied to this instance
See Also:
supportsTransport(Transport)

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

sameAs

public boolean sameAs(GlobalAddress adr)

getValuefor

public Object getValuefor(GlobalAddress.Transport t)

containsTransport

public boolean containsTransport(GlobalAddress.Transport t)

getAvailableTransports

public GlobalAddress.Transport[] getAvailableTransports()

removeAddress

public void removeAddress(GlobalAddress.Transport t)

supportsTransport

public boolean supportsTransport(GlobalAddress.Transport t)
determines if the given transport type is supported; returns true by default


setValueFor

public void setValueFor(GlobalAddress.Transport t,
                        Object address)
                 throws IllegalArgumentException,
                        NullPointerException
Throws:
IllegalArgumentException - if the given transport is not supported or the if the address doesn't match the transport
NullPointerException
See Also:
supportsTransport(Transport)

getGeoPoint

public GeoPoint getGeoPoint()
Specified by:
getGeoPoint in interface GeoEncoded

setGeoPoint

public void setGeoPoint(GeoPoint gp)

hasSnailMail

public boolean hasSnailMail()

getSnailMail

public SnailMailAddress getSnailMail()

setSnailMail

public void setSnailMail(SnailMailAddress adr)

getSnailMailAddressString

public String getSnailMailAddressString()

getSnailMailAddressString

public String getSnailMailAddressString(Locale l)

hasEmail

public boolean hasEmail()

getEmail

public String getEmail()
returns the email address set for this instance (if any)


setEmail

public void setEmail(String email)
allows to specify an email address for this instance


getVoice

public PhoneNumber getVoice()

setVoice

public void setVoice(String phone)

setVoice

public void setVoice(PhoneNumber phone)

getFax

public PhoneNumber getFax()

setFax

public void setFax(String number)

setFax

public void setFax(PhoneNumber fax)

getIM

public String getIM()
returns the address-String for instant messaging


setIM

public void setIM(String im)

getURL

public URL getURL()

setURL

public void setURL(URL url)

getSMS

public PhoneNumber getSMS()

setSMS

public void setSMS(String number)

setSMS

public void setSMS(PhoneNumber sms)

getBankAccount

public BankAccount getBankAccount()

setBankAccount

public void setBankAccount(BankAccount ba)

getTimeZone

public TimeZone getTimeZone()

setTimeZone

public void setTimeZone(TimeZone tz)

setSalutation

public void setSalutation(String salutation)

getSalutation

public String getSalutation()
provides a suitable String to address the person/company/entity in a letter header

Returns:
a String to be used as a salutation, which may be null (in which case a given standard is to be used)

setLocale

public void setLocale(Locale locale,
                      Object context)
Description copied from interface: Localizable
sets the Locale for this object so that all subsequent return values of method calls to this instance can be localized accordingly until a different Locale is set.

Specified by:
setLocale in interface Localizable
Parameters:
locale - the Locale that is to be used to determine return values for all methods of this instance; if set to null, the default locale is to be used.
context - a context that may be required for this instance to load the resources for the given locale; this context may be null for objects that do not require an external context. Examples of a context may be a database, a resource file, some map or no context at all.
See Also:
Localizable.getLocale()

setLocale

public void setLocale(Locale locale)

getSpecifiedLocale

public Locale getSpecifiedLocale()
returns the locale that was explicitly set by setLocale(Locale), if any


getLocale

public Locale getLocale()
if a Locale is explicitly set to a non-null value, it is returned; otherwise, the locale is constructed using the country code. This may return null if no Locale is set and the country code doesn't correspond to any supported Locale.

Specified by:
getLocale in interface Localizable
Returns:
the current Locale that this instance uses to determine return values for its methods; if null is returned, this instance is expected to use the default Locale of the system.
See Also:
getSpecifiedLocale(), setLocale(Locale, Object), SnailMailAddress.getCountry(), I18n.localeFor(String)

getCountry

public String getCountry()
shortcut to the SnailMailAddress


getTitle

public String getTitle()
shortcut to the SnailMailAddress


setTitle

public void setTitle(String title)
shortcut to the SnailMailAddress


toString

public String toString()
Overrides:
toString in class Object


(c) Holger Antelmann since 2001- all rights reserved (contact: info@antelmann.com)
see www.antelmann.com/developer for further details and available downloads