View Javadoc
1   package nl.mineleni.openls.databinding.openls;
2   
3   import nl.mineleni.openls.XmlNamespaceConstants;
4   
5   /**
6    * OLS PostalCode. http://schemas.opengis.net/ols/1.2.0/ADT.xsd
7    * 
8    * <pre>
9    * 
10   * &lt;element name="PostalCode" type="xls:PostalCodeType"&gt;
11   *   &lt;annotation&gt;
12   *     &lt;documentation&gt;A zipcode or international postal code as
13   *     defined by the governing postal authority.&lt;/documentation&gt;
14   *   &lt;/annotation&gt;
15   * &lt;/element&gt;
16   * &lt;simpleType name="PostalCodeType"&gt;
17   *   &lt;annotation&gt;
18   *     &lt;documentation&gt;The AbstractPostalCodeType is an abstract type
19   *     for postal code within an AddressType. We do this because the
20   *     components of a postal code vary greatly throughout the world.
21   *     So that the schema can accommodate this variation we create
22   *     derived types such as the USZipCodeType which has the
23   *     components for a US zipcode&lt;/documentation&gt;
24   *   &lt;/annotation&gt;
25   *   &lt;restriction base="string" /&gt;
26   * &lt;/simpleType&gt;
27   * 
28   * </pre>
29   * 
30   * @author mprins
31   */
32  public class PostalCode implements XmlNamespaceConstants {
33  	/**
34  	 * serialization id.
35  	 */
36  	private static final long serialVersionUID = -78484525678140670L;
37  
38  	/** The postal code. */
39  	private String postalCode;
40  
41  	/** The has postal code. */
42  	private boolean hasPostalCode;
43  
44  	/**
45  	 * Instantiates a new postal code.
46  	 */
47  	public PostalCode() {
48  		this.hasPostalCode = false;
49  	}
50  
51  	/**
52  	 * Sets the postal code.
53  	 * 
54  	 * @param postalCode
55  	 *            the new postal code
56  	 */
57  	public void setPostalCode(final String postalCode) {
58  		this.hasPostalCode = true;
59  		this.postalCode = postalCode;
60  	}
61  
62  	/**
63  	 * Gets the postal code.
64  	 * 
65  	 * @return the postal code
66  	 */
67  	public String getPostalCode() {
68  		return this.postalCode;
69  	}
70  
71  	/**
72  	 * Checks for postal code.
73  	 * 
74  	 * @return true, if successful
75  	 */
76  	public boolean hasPostalCode() {
77  		return this.hasPostalCode;
78  	}
79  
80  	/*
81  	 * (non-Javadoc)
82  	 * 
83  	 * @see nl.mineleni.openls.XmlNamespaceConstants#toXML()
84  	 */
85  	@Override
86  	public String toXML() {
87  		String xml = "<" + XmlNamespaceConstants.OPENLS_NAMESPACE_PREFIX
88  				+ ":PostalCode>";
89  		if (this.hasPostalCode()) {
90  			xml += this.getPostalCode();
91  		}
92  		xml += "</" + XmlNamespaceConstants.OPENLS_NAMESPACE_PREFIX
93  				+ ":PostalCode>";
94  		return xml;
95  	}
96  }