在java中表示西班牙地址的最佳方式

发布于 2024-09-13 05:17:34 字数 1173 浏览 5 评论 0原文

我已对以下内容进行编码以代表西班牙的地址。如果有更好的方法可以做到这一点,或者是否已经有一个处理 i18n 地址的开源库,请告诉我。

/**
 * From <a href="http://www.addressdoctor.com/en/countries_data/sampleaddress.asp?code=ESP%2BSpain}">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();
}

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}">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();
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

眼眸里的快感 2024-09-20 05:17:43

我住在马德里并且能说流利的西班牙语,我可以提供一些评论。

我不会将街道类型和名称分开,因为街道类型通常是名称的一部分,或者可能会丢失(例如 Gran Via)。任何解析算法要么会出现一些错误,要么需要大量的异常表(并且仍然会出现一些错误)。

在地方之后为省提供一个字段。这是具有欺骗性的,因为对于大城市来说,省份经常被省略,特别是在城市名称和省份名称相同的情况下。以下是地区和省份不同的示例:

Calle Alcala, 45
28192 El Berrueco
Madrid
Spain

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文