org.starhope.appius.mb
Class UserAddress

java.lang.Object
  extended by org.starhope.appius.sql.SQLPeerDatum
      extended by org.starhope.appius.mb.UserAddress
All Implemented Interfaces:
Serializable

public class UserAddress
extends SQLPeerDatum

Author:
brpocock
See Also:
Serialized Form

Field Summary
private  String address
          WRITEME
private  String address2
          WRITEME
private  String addressType
          WRITEME
private  String city
          WRITEME
private  String country
          WRITEME
private  int database_id
          WRITEME
private  boolean externallyValidated
          WRITEME
private  BigDecimal latitude
          WRITEME
private  String locality
          WRITEME
private  BigDecimal longitude
          WRITEME
private  String mail
          WRITEME
private  String phone
          WRITEME
private  String postalCode
          WRITEME
private  String province
          WRITEME
private static long serialVersionUID
           
private  String title
          WRITEME
private  Person user
          WRITEME
private  String validatedByDomain
          WRITEME
private  Date validatedOn
          WRITEME
private  String zipPlus4
          WRITEME
 
Constructor Summary
UserAddress()
           
 
Method Summary
 void asyncValidate()
          Request an asynchronous validation against some online service or other (Google, Yahoo, whoever)
 boolean equals(String streetAddress, String otherCity, String otherProvince, String otherPostalCode, String otherCountry)
           Convenience method, to match up against the address fields as provided by Authorize.Net.
 void flush()
          This is an overriding method.
static UserAddress get(org.json.JSONObject object)
           
 String getAddress()
           
 String getAddress2()
           
 String getAddressPair()
           
 String getAddressType()
           
 String getApartment()
           
protected  String getCacheUniqueID()
           
 String getCity()
           
 String getCountry()
           
 BigDecimal getIntitude()
           
 BigDecimal getLatitude()
           
 String getLocality()
          TODO: document this method (brpocock, Sep 24, 2009)
 String getMail()
           
 String getPhone()
          TODO: document this method (brpocock, Sep 24, 2009)
 String getPostalCode()
           
 String getPropertyNumber()
           
 String getProvince()
           
 String getStreetName()
           
 String getStreetType()
           
 String getTitle()
           
 Person getUser()
           
 String getValidatedByDomain()
           
 Date getValidatedOn()
           
 String getZipPlus4()
           
 boolean isExternallyValidated()
           
 boolean isValidAddress()
          This method determines whether the supplied address is plausible to be valid.
 void set(org.json.JSONObject o)
           
protected  void set(ResultSet rs)
          This is an overriding method.
 void setAddress(String newAddress, String newAddress2)
           
 void setAddressType(String newAddressType)
           
 void setCity(String newCity)
           
 void setCountry(String newCountry)
           
 void setExternallyValidated(boolean externallyValidated1)
           
 void setLatitude(BigDecimal latitude1)
           
 void setLocality(String locality1)
          TODO: document this method (brpocock, Sep 23, 2009)
 void setLongitude(BigDecimal longitude1)
           
 void setMail(String newMail)
           
 void setPhone(String phone1)
          TODO: document this method (brpocock, Sep 23, 2009)
 void setPostalCode(String newPostalCode)
           
 void setProvince(String newProvince)
           
 void setTitle(String newTitle)
           
 void setUser(Person newUser)
           
 void setValidatedByDomain(String validatedByDomain1)
           
 void setValidatedOn(Date validated)
           
 void setZipPlus4(String newZipPlus4)
           
 org.json.JSONObject toJSON()
          This is an overriding method.
 boolean validate()
          WRITEME: document method.
 
Methods inherited from class org.starhope.appius.sql.SQLPeerDatum
changed, findInCache, get, saveInCache
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

address

private String address
WRITEME


address2

private String address2
WRITEME


addressType

private String addressType
WRITEME


city

private String city
WRITEME


country

private String country
WRITEME


database_id

private int database_id
WRITEME


externallyValidated

private boolean externallyValidated
WRITEME


latitude

private BigDecimal latitude
WRITEME


locality

private String locality
WRITEME


longitude

private BigDecimal longitude
WRITEME


mail

private String mail
WRITEME


phone

private String phone
WRITEME


postalCode

private String postalCode
WRITEME


province

private String province
WRITEME


title

private String title
WRITEME


user

private Person user
WRITEME


validatedByDomain

private String validatedByDomain
WRITEME


validatedOn

private Date validatedOn
WRITEME


zipPlus4

private String zipPlus4
WRITEME

Constructor Detail

UserAddress

public UserAddress()
Method Detail

get

public static UserAddress get(org.json.JSONObject object)
                       throws NotFoundException,
                              org.json.JSONException
Parameters:
object - The JSON object containing the reference to an address
Returns:
the UserAddress requested
Throws:
NotFoundException - if the address couldn't be found in the database sense. (Does not necessarily mean that the address exists IRL)
org.json.JSONException - if the JSON data couldn't be decoded properly

asyncValidate

public void asyncValidate()
Request an asynchronous validation against some online service or other (Google, Yahoo, whoever)


equals

public boolean equals(String streetAddress,
                      String otherCity,
                      String otherProvince,
                      String otherPostalCode,
                      String otherCountry)

Convenience method, to match up against the address fields as provided by Authorize.Net. Plus, it might come in useful in other contexts as well.

Note that this method doesn't care about address line two, but it's quite strict on the rest. It would actually make sense to run both addresses through some minimal degree of conformance first, but that's outside the current SOW. TODO?

Parameters:
streetAddress - streetAddress
otherCity - city
otherProvince - province/state
otherPostalCode - postal/ZIP code
otherCountry - country
Returns:
True, if all of the fields match up.

flush

public void flush()
This is an overriding method.

Specified by:
flush in class SQLPeerDatum
See Also:
SQLPeerDatum.flush()

getAddress

public String getAddress()
Returns:
line 1 of the street address

getAddress2

public String getAddress2()
Returns:
line 2 of the street address

getAddressPair

public String getAddressPair()
Returns:
both lines of the street address, separated with a newline. If the address has only one line, it will not have a newline and a second line.

getAddressType

public String getAddressType()
Returns:
the type of address which this represents

getApartment

public String getApartment()
Returns:
the apartment number of the address

getCacheUniqueID

protected String getCacheUniqueID()
Specified by:
getCacheUniqueID in class SQLPeerDatum
Returns:
The local (Stringified) version of an unique ID; usually the database ID column
See Also:
SQLPeerDatum.getCacheUniqueID()

getCity

public String getCity()
Returns:
the city of the address

getCountry

public String getCountry()
Returns:
the country code for the address (2-char ISO code)

getIntitude

public BigDecimal getIntitude()
Returns:
the longitude (if known)

getLatitude

public BigDecimal getLatitude()
Returns:
the latitude (if known)

getLocality

public String getLocality()
TODO: document this method (brpocock, Sep 24, 2009)

Returns:
WRITEME

getMail

public String getMail()
Returns:
the postal code of the address

getPhone

public String getPhone()
TODO: document this method (brpocock, Sep 24, 2009)

Returns:
WRITEME

getPostalCode

public String getPostalCode()
Returns:
the postal code of the address

getPropertyNumber

public String getPropertyNumber()
Returns:
the property number (house number) of the address

getProvince

public String getProvince()
Returns:
the province/state part of the address

getStreetName

public String getStreetName()
Returns:
the street name (without the street type, e.g. for "123 Sesame St" this would yield "Sesame")

getStreetType

public String getStreetType()
Returns:
the street type (e.g. "St" or "Ave")

getTitle

public String getTitle()
Returns:
the title for this address, supplied by the user: e.g. "Home" or "Office" perhaps

getUser

public Person getUser()
Returns:
The user owning this address

getValidatedByDomain

public String getValidatedByDomain()
Returns:
the domain of the service which validated this address (if any)

getValidatedOn

public Date getValidatedOn()
Returns:
the date at which this address was validated

getZipPlus4

public String getZipPlus4()
Returns:
the four-digit "PLUS-4" part of a ZIP code

isExternallyValidated

public boolean isExternallyValidated()
Returns:
true, if an external engine has validated the address

isValidAddress

public boolean isValidAddress()
This method determines whether the supplied address is plausible to be valid. TODO

Returns:
false, if the address is clearly not valid

set

public void set(org.json.JSONObject o)
Overrides:
set in class SQLPeerDatum
Parameters:
o - The JSON data to be used to set the value of this object
See Also:
CastsToJSON.set(org.json.JSONObject)

set

protected void set(ResultSet rs)
            throws SQLException
This is an overriding method.

Specified by:
set in class SQLPeerDatum
Parameters:
rs - The result of an SQL query, with the cursor already pointed at the row describing this specific instance of the object.
Throws:
SQLException - if the database fails somehow
See Also:
SQLPeerDatum.set(java.sql.ResultSet)

setAddress

public void setAddress(String newAddress,
                       String newAddress2)
Parameters:
newAddress - the first line of the address
newAddress2 - the second line

setAddressType

public void setAddressType(String newAddressType)
Parameters:
newAddressType - the type of the address

setCity

public void setCity(String newCity)
Parameters:
newCity - the city/town/village part of the address

setCountry

public void setCountry(String newCountry)
Parameters:
newCountry - the country code for the address

setExternallyValidated

public void setExternallyValidated(boolean externallyValidated1)
Parameters:
externallyValidated1 - the externallyValidated to set

setLatitude

public void setLatitude(BigDecimal latitude1)
Parameters:
latitude1 - the latitude to set

setLocality

public void setLocality(String locality1)
TODO: document this method (brpocock, Sep 23, 2009)

Parameters:
locality1 - WRITEME

setLongitude

public void setLongitude(BigDecimal longitude1)
Parameters:
longitude1 - the longitude to set

setMail

public void setMail(String newMail)
Parameters:
newMail - WRITEME

setPhone

public void setPhone(String phone1)
TODO: document this method (brpocock, Sep 23, 2009)

Parameters:
phone1 - WRITEME

setPostalCode

public void setPostalCode(String newPostalCode)
Parameters:
newPostalCode - the postal/ZIP code of the address

setProvince

public void setProvince(String newProvince)
Parameters:
newProvince - the province/state/locality of the address

setTitle

public void setTitle(String newTitle)
Parameters:
newTitle - the user-visible title of the address

setUser

public void setUser(Person newUser)
Parameters:
newUser - the user whose address this is

setValidatedByDomain

public void setValidatedByDomain(String validatedByDomain1)
Parameters:
validatedByDomain1 - the validatedByDomain to set

setValidatedOn

public void setValidatedOn(Date validated)
Parameters:
validated - the validated to set

setZipPlus4

public void setZipPlus4(String newZipPlus4)
Parameters:
newZipPlus4 - the ZIP+4 code for a US address

toJSON

public org.json.JSONObject toJSON()
This is an overriding method.

Overrides:
toJSON in class SQLPeerDatum
Returns:
This object's data, serialized into JSON form.
See Also:
SQLPeerDatum.toJSON()

validate

public boolean validate()
WRITEME: document method.

Returns:
WRITEME