|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.ahmadsoft.postal.USPostalCodeService
public class USPostalCodeService
Provides a postal code service implementation for the United States of America.
Nested Class Summary | |
---|---|
static class |
USPostalCodeService.MatchOptions
Specifies options for performing an advanced match operation. |
static class |
USPostalCodeService.MatchResult
The result of a matching operation. |
Constructor Summary | |
---|---|
USPostalCodeService()
|
Method Summary | |
---|---|
void |
dispose()
Disposes an instance of this object. |
PostalCodeEntry |
getActualFor(int postalCode)
Returns the PostalCodeEntry for the actual city
registered with the U.S. |
java.util.List |
getCandidates(int postalCode)
Returns a list of all recognized candidate cities for a given postal code. |
void |
initialize(PostalRetrievalStrategy retrievalStrategy)
Initializes an instance of the US Postal Code Service. |
boolean |
isPostalCodeIn(int postalCode,
java.lang.String stateAbbr)
Returns true if the given postal code is within
the given state, or false otherwise. |
java.util.List |
match(java.lang.String city,
int postalCode)
Performs a match using default matching options well-suited to common validation. |
java.util.List |
match(java.lang.String city,
int postalCode,
USPostalCodeService.MatchOptions options)
Returns a list of the closest matches to the specified city within the specified postal code. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public USPostalCodeService()
Method Detail |
---|
public void dispose() throws java.lang.Exception
java.lang.Exception
public void initialize(PostalRetrievalStrategy retrievalStrategy) throws java.lang.Exception
retrievalStrategy
- an initialized postal retrieval strategy.
java.lang.Exception
- if an error occurs during initialization. Renders
this service instance unusable.public java.util.List getCandidates(int postalCode)
postalCode
- the postal code.
public boolean isPostalCodeIn(int postalCode, java.lang.String stateAbbr)
true
if the given postal code is within
the given state, or false
otherwise. For
example, isPostalCodeIn(85050, "AZ")
will return true
because the 85050 postal code is within Arizona, but
isPostalCodeIn(43202, "CA")
will return false
because the 43202 is not in California, but rather in Ohio.
postalCode
- the postal code.stateAbbr
- the two-digit, upper-case abbreviation for
a state, as specified in
United States Postal Service - Abbreviations.
true
if the given postal code is within
the given state, or false
otherwise.public PostalCodeEntry getActualFor(int postalCode)
PostalCodeEntry
for the actual city
registered with the U.S. Post Office for this postal code. This
is a useful operation because every postal code has an official
city name associated with it, as well as several other names
recognized by the post office as acceptable or unacceptable.
For example, getActualFor(90064)
will return a
PostalCodeEntry
for Los Angeles, CA, which is
the official city for the 90064 postal code. Rancho Park, CA
is an acceptable, but not the actual, name.
postalCode
-
PostalCodeEntry
for the actual city
registered with the U.S. Post Office for this postal code, or
null
if there is no "actual" candidate for this postal code.
This may occur if the postal code is not yet assigned, or is
out of range.public java.util.List match(java.lang.String city, int postalCode)
true
, ignore punctuation is true
,
ignore whitespace is false
, and the minimum match
level is PostalCodeConstants.CITY_ACCEPTABLE
.
city
- the city to match.postalCode
- the postal code within which to match the city.
match(String, int, MatchOptions)
public java.util.List match(java.lang.String city, int postalCode, USPostalCodeService.MatchOptions options)
Note: This method does not take the state into consideration. Rather, use #isPostalCodeIn(int, String) to determine if a postal code is within a given state.
city
- the city to match.postalCode
- the postal code within which to match the city.options
- parameters to control the matching process.
USPostalCodeService.MatchOptions
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |