views:

63

answers:

1

I have coded the below to represent addresses in Spain. Let me know if there are better ways of doing this or if there is already a open source library dealing with i18n addresses.

/**
 * From <a href="http://www.addressdoctor.com/en/countries_data/sampleaddress.asp?code=ESP%2BSpain}"&gt;Address doctor</a>
 * <p>
 * Format
 * </p>
 * 
 * <pre>
 * Line 1:  RECIPIENT
 * Line 2:  [URBANISATION]
 * Line 3:  STREET_TYPE STREET_NAME, HOUSE_NUMBER [FLOOR] [APARTMENT]
 * Line 4:  POSTAL_CODE LOCALITY
 * Line 5:  SPAIN
 * </pre>
 * 
 * Example
 * 
 * <pre>
 * Isidre Varo
 * Avenida de Canillejas a Vicalvaro 82 piso 4
 * 28022 MADRID
 * SPAIN
 * </pre>
 * 
 * @author Aravind R Yarram
 * 
 */
public interface SpainAddress
{
    /**
     * E.g road types would be Calle (Street)
     * <p>
     * TODO may be an enumeration
     * </p>
     */
    String getStreetType();

    String getStreetName();

    String getHouseNumber();

    String getFloorNumber();

    /**
     * <p>
     * TODO need validation
     * </p>
     */
    String getPostalCode();

    /**
     * Poblacion
     */
    String getCity();

    /**
     * Also known as province
     */
    String getLocality();
}
+3  A: 

Having lived in Madrid and being fluent in Spanish, I can offer a couple of comments.

I wouldn't separate street type and name, because the street type is often really part of the name, or may be missing (Gran Via, for instance). Any parsing algorithm will either get some wrong or require a huge table of exceptions (and it'll still get some wrong).

Provide a field for the Province, after the Locality. This is deceptive because for large cities the province is often omitted, especially where the city name and province name are the same. Here's an example where the locality and province are different:

Calle Alcala, 45
28192 El Berrueco
Madrid
Spain
Jim Garrison
Jim - Which is the province and which is the loacality?
Pangea
Our UI makes the street type and name mandatory (as shown below) so for me separating them out makes sense. Tipo di Via (Street type): Nombre di la Via (Street name):
Pangea
`El Berrueco` is the locality, `Madrid` is the province. Also `Tipo di Via` is Italian. In Spanish it's `Tipo de calle` and `Nombre de la Calle`, although those distinctions would probably look strange to a native user. Also, how will you cope with addresses starting `c/`, which is a standard abbreviation for `Calle [de]`? Before you release this in Spain I strongly suggest you have it reviewed by a native of the country.
Jim Garrison
The street type is not a free form filed. It is a drown down list of all valid (in the context of our business) values. And yes, the list is coming from the SME in Spain.
Pangea