View Javadoc
1   package nl.mineleni.openls.databinding.openls;
2   
3   import nl.mineleni.openls.XmlNamespaceConstants;
4   import nl.mineleni.openls.databinding.gml.Point;
5   
6   /**
7    * OLS GeocodedAddress.
8    * http://schemas.opengis.net/ols/1.2.0/LocationUtilityService.xsd
9    * 
10   * <pre>
11   * 
12   * &lt;complexType name="GeocodedAddressType"&gt;
13   *   &lt;sequence&gt;
14   *     &lt;element ref="gml:Point" /&gt;
15   *     &lt;element ref="xls:Address" /&gt;
16   *     &lt;element ref="xls:GeocodeMatchCode" minOccurs="0" /&gt;
17   *   &lt;/sequence&gt;
18   * &lt;/complexType&gt;
19   * 
20   * </pre>
21   * 
22   * @author mprins
23   */
24  public class GeocodedAddress implements XmlNamespaceConstants {
25  	/**
26  	 * serialization id.
27  	 */
28  	private static final long serialVersionUID = -2711370703109529657L;
29  
30  	/** The point. */
31  	private Point point;
32  
33  	/** The address. */
34  	private Address address;
35  
36  	/** The has point. */
37  	private boolean hasPoint;
38  
39  	/** The has address. */
40  	private boolean hasAddress;
41  
42  	/**
43  	 * Instantiates a new geocoded address.
44  	 */
45  	public GeocodedAddress() {
46  		this.hasPoint = false;
47  		this.hasAddress = false;
48  	}
49  
50  	/**
51  	 * Sets the point.
52  	 * 
53  	 * @param point
54  	 *            the new point
55  	 */
56  	public void setPoint(final Point point) {
57  		this.hasPoint = true;
58  		this.point = point;
59  	}
60  
61  	/**
62  	 * Gets the point.
63  	 * 
64  	 * @return the point
65  	 */
66  	public Point getPoint() {
67  		return this.point;
68  	}
69  
70  	/**
71  	 * Checks for point.
72  	 * 
73  	 * @return true, if successful
74  	 */
75  	public boolean hasPoint() {
76  		return this.hasPoint;
77  	}
78  
79  	/**
80  	 * Sets the address.
81  	 * 
82  	 * @param address
83  	 *            the new address
84  	 */
85  	public void setAddress(final Address address) {
86  		this.hasAddress = true;
87  		this.address = address;
88  	}
89  
90  	/**
91  	 * Gets the address.
92  	 * 
93  	 * @return the address
94  	 */
95  	public Address getAddress() {
96  		return this.address;
97  	}
98  
99  	/**
100 	 * Checks for address.
101 	 * 
102 	 * @return true, if successful
103 	 */
104 	public boolean hasAddress() {
105 		return this.hasAddress;
106 	}
107 
108 	/*
109 	 * (non-Javadoc)
110 	 * 
111 	 * @see nl.mineleni.openls.XmlNamespaceConstants#toXML()
112 	 */
113 	@Override
114 	public String toXML() {
115 		String xml = "<" + XmlNamespaceConstants.OPENLS_NAMESPACE_PREFIX
116 				+ ":GeocodedAddress>";
117 		if (this.hasPoint()) {
118 			xml += this.point.toXML();
119 		}
120 		if (this.hasAddress()) {
121 			xml += this.address.toXML();
122 		}
123 		xml += "</" + XmlNamespaceConstants.OPENLS_NAMESPACE_PREFIX
124 				+ ":GeocodedAddress>";
125 		return xml;
126 	}
127 }