com.mizar.usaddress
Class USAddressStreet

java.lang.Object
  extended by com.mizar.usaddress.USAddressStreet

public class USAddressStreet
extends java.lang.Object

IMPORTANT: Do not add any references to Mizar utility classes in this class. Just copy the required methods as private methods. This facilitates delivering the class as a PL/SQL procedure. The USAddressStreet class provides a set of utilities for parsing and constructing preferred US street addresses. Guidelines were taken from www.metrogis.org/data/standards/address_guidelines.shtml and USPS Schedule 28


Constructor Summary
USAddressStreet()
          constructs an empty class instance.
USAddressStreet(java.lang.String inputStreetAddress)
          Constructs a USAddressStreet class, setting the inputAddress and parsing it.
 
Method Summary
 boolean equals(java.lang.Object obj)
          equals determins if the provided object is equal to the current USAddressStreet
 java.lang.String getAddressLine()
           
 java.lang.String getCity()
           
 java.lang.String getCounty()
           
 java.lang.String getFullName()
           
 int getId()
           
 java.lang.String getInputAddress()
           
 java.util.List<java.lang.String> getKnownStreetNames()
           
 java.util.List<java.lang.String> getKnownTowns()
           
 int getMcode()
           
 int getNumberStreetMode()
           
 java.lang.String getPartialName(boolean includePrefix, boolean includeType, boolean includeSuffix, boolean includeRteNumber, java.lang.String separator)
          This method is used to create consistent malformed versions of the street name, which is useful to test a non-perfect match.
 java.lang.String getPoBox()
           
 java.lang.String getPrefixDirection()
           
 int getResultType()
           
 java.lang.String getRteNumber()
           
 java.lang.String getRteOwner()
           
 java.lang.String getRteType()
           
 java.lang.String getRuralRouteBoxNumber()
           
 java.lang.String getState()
           
 java.lang.String getStreetName()
           
 java.lang.String getStreetNumber()
           
 java.lang.String getStreetType()
           
 java.lang.String getSuffixDirection()
           
 java.lang.String getUnitNumber()
           
 java.lang.String getUnitType()
           
 java.lang.String getZip()
           
 java.lang.String getZip4()
           
 int hashCode()
           
 boolean isGeocodable()
          To be geocodable a street must have a name and a number from which an integer can be inferred.
 boolean isParseLocked()
           
static void main(java.lang.String[] args)
           
static java.lang.String parseAddress(java.lang.String addressLine)
           
 java.lang.String parseAddressLine()
           
 java.lang.String parseAddressLine(java.lang.String inputStreetAddress)
          The method sets inputAddress and attempts to parse it into address parts
static java.lang.String parsePOBox(java.lang.String addressLine, java.lang.String errorValue)
           
static java.lang.String parsePrefixDirection(java.lang.String addressLine, java.lang.String errorValue)
           
static java.lang.String parseRuralRouteBoxNo(java.lang.String addressLine, java.lang.String errorValue)
           
static java.lang.String parseStreetName(java.lang.String addressLine, java.lang.String errorValue)
           
static java.lang.String parseStreetNumber(java.lang.String addressLine, java.lang.String errorValue)
           
static java.lang.String parseStreetType(java.lang.String addressLine, java.lang.String errorValue)
           
static java.lang.String parseSuffixDirection(java.lang.String addressLine, java.lang.String errorValue)
           
static java.lang.String parseUnitNumber(java.lang.String addressLine, java.lang.String errorValue)
           
static java.lang.String parseUnitType(java.lang.String addressLine, java.lang.String errorValue)
           
 void setAddressLine(java.lang.String addressLine)
           
 void setCity(java.lang.String city)
           
 void setCounty(java.lang.String county)
           
 void setId(int ID)
           
 void setInputAddress(java.lang.String inputStreetAddress)
           
 void setKnownStreetNames(java.util.List<java.lang.String> knownStreetNames)
           
 void setKnownTowns(java.util.List<java.lang.String> knownTowns)
           
 void setMcode(int MCODE)
           
 void setNumberStreetMode(int numberStreetMode)
           
 void setPoBox(java.lang.String poBox)
           
 void setPrefixDirection(java.lang.String prefixDirection)
           
 void setResultType(int resultType)
           
 void setRuralRouteBoxNumber(java.lang.String ruralRouteBoxNumber)
           
 void setState(java.lang.String state)
           
 void setStreetName(java.lang.String streetName)
           
 void setStreetNumber(java.lang.String streetNumber)
           
 void setStreetType(java.lang.String streetType)
          setStreetType
 void setSuffixDirection(java.lang.String suffixDirection)
           
 void setUnitNumber(java.lang.String unitNumber)
           
 void setUnitType(java.lang.String unitType)
           
 void setZip(java.lang.String zip)
           
 void setZip4(java.lang.String zip4)
           
 java.lang.String toString()
           
static java.lang.String unsmashDirection(java.lang.String streetName)
          This method corrects a error found in street names where the space between the direction and the numeric street name is missing.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

USAddressStreet

public USAddressStreet()
constructs an empty class instance.


USAddressStreet

public USAddressStreet(java.lang.String inputStreetAddress)
                throws USAddressException
Constructs a USAddressStreet class, setting the inputAddress and parsing it.

Parameters:
inputStreetAddress - the street address to be parsed.
Throws:
USAddressException
Method Detail

unsmashDirection

public static java.lang.String unsmashDirection(java.lang.String streetName)
This method corrects a error found in street names where the space between the direction and the numeric street name is missing. For examples "100 SSIXTH ST" is changed to "100 S SIXTH ST"

Parameters:
streetName -
Returns:

main

public static void main(java.lang.String[] args)

parseAddressLine

public java.lang.String parseAddressLine()
                                  throws USAddressException
Throws:
USAddressException

parseAddressLine

public java.lang.String parseAddressLine(java.lang.String inputStreetAddress)
                                  throws USAddressException
The method sets inputAddress and attempts to parse it into address parts

Parameters:
inputStreetAddress - address line to parse
Throws:
USAddressException - the parser has failed to retrieve required information.

getFullName

public java.lang.String getFullName()
Returns:
the full street name but excluding any unit or street number

getPartialName

public java.lang.String getPartialName(boolean includePrefix,
                                       boolean includeType,
                                       boolean includeSuffix,
                                       boolean includeRteNumber,
                                       java.lang.String separator)
This method is used to create consistent malformed versions of the street name, which is useful to test a non-perfect match.

Parameters:
includePrefix - if false skip the prefix
includeType - if false skip the type
includeSuffix - if false skip the suffix
includeRteNumber - if false skip the Route Number
Returns:

setInputAddress

public void setInputAddress(java.lang.String inputStreetAddress)
Parameters:
inputStreetAddress - an address to be parsed

getInputAddress

public java.lang.String getInputAddress()
Returns:
the original street address line

setPoBox

public void setPoBox(java.lang.String poBox)
Parameters:
poBox -

getPoBox

public java.lang.String getPoBox()
Returns:
the post office box number

setRuralRouteBoxNumber

public void setRuralRouteBoxNumber(java.lang.String ruralRouteBoxNumber)
Parameters:
ruralRouteBoxNumber -

getRuralRouteBoxNumber

public java.lang.String getRuralRouteBoxNumber()
Returns:

setPrefixDirection

public void setPrefixDirection(java.lang.String prefixDirection)
Parameters:
prefixDirection - supports most unambiguous directions such as North, N, North-West, Northwest, NW and will convert to the USPS standards.

getPrefixDirection

public java.lang.String getPrefixDirection()
Returns:
the standard USPS direction

setStreetNumber

public void setStreetNumber(java.lang.String streetNumber)
Parameters:
streetNumber - the house or building address

getStreetNumber

public java.lang.String getStreetNumber()
Returns:
the street number (house or building address number)

setStreetName

public void setStreetName(java.lang.String streetName)
Parameters:
streetName - is just the name portion of the full street name. It does NOT include the direction or street type.

getStreetName

public java.lang.String getStreetName()

setStreetType

public void setStreetType(java.lang.String streetType)
setStreetType

Parameters:
streetType -

getStreetType

public java.lang.String getStreetType()
Returns:
a standard USPS street type

setSuffixDirection

public void setSuffixDirection(java.lang.String suffixDirection)
Parameters:
suffixDirection - supports most unambiguous directions such as North, N, North-West, Northwest, NW and will convert to the USPS standards.

getSuffixDirection

public java.lang.String getSuffixDirection()
Returns:
a USPS standard suffix direction

setUnitNumber

public void setUnitNumber(java.lang.String unitNumber)
Parameters:
unitNumber - not all unitTypes anticipate unitNumbers but this class does not differentiate between unitTypes that support unit numbers (e.g. APT, PIER, SUITE, etc.) and those that do not (e.g. BASEMENT, FRONT, REAR, UPPER, LOWER, etc.)

getUnitNumber

public java.lang.String getUnitNumber()
Returns:
the unit number

setUnitType

public void setUnitType(java.lang.String unitType)
Parameters:
unitType - this is the USPS Secondary Unit Designator. See www.usps.com/ncsc/lookups/abbreviations.html for specifics. Input resembling standard USPS secondary unit designators will be converted to that standard. This includes the following, APARTMENT, BASEMENT, BUILDING, DEPARTMENT, FLOOR, FRONT, HANGAR, LOBBY, LOT, LOWER, OFFICE, PENTHOUSE, PIER, REAR, ROOM, SIDE, SLIP, SPACE, STOP, SUITE, TRAILER, UNIT, and UPPER. The method tolerates most misspellings and abbreviations and will automatically correct them if they correspond to one of the designators in the previous wkt.

getUnitType

public java.lang.String getUnitType()
Returns:

getAddressLine

public java.lang.String getAddressLine()
Returns:
a full street address constructed from the parsed properties.

setAddressLine

public void setAddressLine(java.lang.String addressLine)
                    throws USAddressException
Throws:
USAddressException

setCounty

public void setCounty(java.lang.String county)
Parameters:
county -

getCounty

public java.lang.String getCounty()
Returns:

setCity

public void setCity(java.lang.String city)
Parameters:
city -

getCity

public java.lang.String getCity()
Returns:

setState

public void setState(java.lang.String state)
Parameters:
state -

getState

public java.lang.String getState()
Returns:

setId

public void setId(int ID)
Parameters:
ID -

getId

public int getId()
Returns:

setMcode

public void setMcode(int MCODE)
Parameters:
MCODE -

getMcode

public int getMcode()
Returns:

setZip

public void setZip(java.lang.String zip)
Parameters:
zip -

getZip

public java.lang.String getZip()
Returns:

setZip4

public void setZip4(java.lang.String zip4)
Parameters:
zip4 -

getZip4

public java.lang.String getZip4()
Returns:

isGeocodable

public boolean isGeocodable()
To be geocodable a street must have a name and a number from which an integer can be inferred.

Returns:
true if the street name has the potential to be geocodable
See Also:
is used to determine if the address number is usable.

isParseLocked

public boolean isParseLocked()
Returns:

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
Returns:

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object
Returns:

equals

public boolean equals(java.lang.Object obj)
equals determins if the provided object is equal to the current USAddressStreet

Overrides:
equals in class java.lang.Object
Parameters:
obj -
Returns:

parseAddress

public static java.lang.String parseAddress(java.lang.String addressLine)

parseStreetName

public static java.lang.String parseStreetName(java.lang.String addressLine,
                                               java.lang.String errorValue)

parseStreetNumber

public static java.lang.String parseStreetNumber(java.lang.String addressLine,
                                                 java.lang.String errorValue)

parseStreetType

public static java.lang.String parseStreetType(java.lang.String addressLine,
                                               java.lang.String errorValue)

parsePrefixDirection

public static java.lang.String parsePrefixDirection(java.lang.String addressLine,
                                                    java.lang.String errorValue)

parseSuffixDirection

public static java.lang.String parseSuffixDirection(java.lang.String addressLine,
                                                    java.lang.String errorValue)

parsePOBox

public static java.lang.String parsePOBox(java.lang.String addressLine,
                                          java.lang.String errorValue)

parseUnitNumber

public static java.lang.String parseUnitNumber(java.lang.String addressLine,
                                               java.lang.String errorValue)

parseUnitType

public static java.lang.String parseUnitType(java.lang.String addressLine,
                                             java.lang.String errorValue)

parseRuralRouteBoxNo

public static java.lang.String parseRuralRouteBoxNo(java.lang.String addressLine,
                                                    java.lang.String errorValue)

setKnownTowns

public void setKnownTowns(java.util.List<java.lang.String> knownTowns)
Parameters:
knownTowns - a set of known town names used to resolve ambiguities

getKnownTowns

public java.util.List<java.lang.String> getKnownTowns()
Returns:
a set of known town names used to resolve ambiguities

setKnownStreetNames

public void setKnownStreetNames(java.util.List<java.lang.String> knownStreetNames)
Parameters:
knownStreetNames - a set of known street names used to resolve ambiguities

getKnownStreetNames

public java.util.List<java.lang.String> getKnownStreetNames()
Returns:
a set of known street names used to resolve ambiguities

setNumberStreetMode

public void setNumberStreetMode(int numberStreetMode)

getNumberStreetMode

public int getNumberStreetMode()

setResultType

public void setResultType(int resultType)

getResultType

public int getResultType()

getRteNumber

public java.lang.String getRteNumber()

getRteType

public java.lang.String getRteType()

getRteOwner

public java.lang.String getRteOwner()