View Javadoc
1   package nl.mineleni.openls.databinding.openls;
2   
3   import java.util.Vector;
4   
5   import nl.mineleni.openls.XmlNamespaceConstants;
6   
7   /**
8    * OLS GeocodeResponseList.
9    * http://schemas.opengis.net/ols/1.2.0/LocationUtilityService.xsd
10   * 
11   * <pre>
12   * 
13   *  &lt;complexType name="GeocodeResponseListType"&gt;
14   *   &lt;sequence&gt;
15   *     &lt;element name="GeocodedAddress" type="xls:GeocodedAddressType" maxOccurs="unbounded"&gt;
16   *       &lt;annotation&gt;
17   *         &lt;documentation&gt;The list of 1-n addresses that are returned for each Address 
18   *         request, sorted by Accuracy.&lt;/documentation&gt;
19   *       &lt;/annotation&gt;
20   *     &lt;/element&gt;
21   *   &lt;/sequence&gt;
22   *   &lt;attribute name="numberOfGeocodedAddresses" type="nonNegativeInteger" use="required"&gt;
23   *     &lt;annotation&gt;
24   *       &lt;documentation&gt;This is the number of responses generated per the different requests. 
25   *       Within each geocoded address it's possible to have multiple candidates.&lt;/documentation&gt;
26   *     &lt;/annotation&gt;
27   *   &lt;/attribute&gt;
28   * &lt;/complexType&gt;
29   * 
30   * </pre>
31   * 
32   * @author mprins
33   * @since 1.7
34   */
35  public class GeocodeResponseList implements XmlNamespaceConstants {
36  
37  	/** serialisation id. */
38  	private static final long serialVersionUID = 6830914161263736467L;
39  
40  	/** The geocoded address. */
41  	private final Vector<GeocodedAddress> geocodedAddress = new Vector<>();
42  
43  	/** The number of geocoded addresses. */
44  	private int numberOfGeocodedAddresses;
45  
46  	/**
47  	 * Adds the geocoded address.
48  	 * 
49  	 * @param val
50  	 *            the val
51  	 */
52  	public void addGeocodedAddress(final GeocodedAddress val) {
53  		this.geocodedAddress.add(val);
54  	}
55  
56  	/**
57  	 * Gets the geocoded address at.
58  	 * 
59  	 * @param i
60  	 *            the i
61  	 * @return the geocoded address at
62  	 */
63  	public GeocodedAddress getGeocodedAddressAt(final int i) {
64  		return this.geocodedAddress.get(i);
65  	}
66  
67  	/**
68  	 * Gets the geocoded address size.
69  	 * 
70  	 * @return the geocoded address size
71  	 */
72  	public int getGeocodedAddressSize() {
73  		return this.geocodedAddress.size();
74  	}
75  
76  	/**
77  	 * Sets the number of geocoded addresses.
78  	 * 
79  	 * @param val
80  	 *            the new number of geocoded addresses
81  	 */
82  	public void setNumberOfGeocodedAddresses(final int val) {
83  		this.numberOfGeocodedAddresses = val;
84  	}
85  
86  	/**
87  	 * Gets the number of geocoded addresses.
88  	 * 
89  	 * @return the number of geocoded addresses
90  	 */
91  	public int getNumberOfGeocodedAddresses() {
92  		return this.numberOfGeocodedAddresses;
93  	}
94  
95  	/*
96  	 * (non-Javadoc)
97  	 * 
98  	 * @see nl.mineleni.openls.XmlNamespaceConstants#toXML()
99  	 */
100 	@Override
101 	public String toXML() {
102 		final StringBuilder sb = new StringBuilder("<"
103 				+ XmlNamespaceConstants.OPENLS_NAMESPACE_PREFIX
104 				+ ":GeocodeResponseList " + "numberOfGeocodedAddresses=\""
105 				+ Integer.toString(this.getGeocodedAddressSize()) + "\">");
106 		for (final GeocodedAddress gca : this.geocodedAddress) {
107 			sb.append(gca.toXML());
108 		}
109 		sb.append("</" + XmlNamespaceConstants.OPENLS_NAMESPACE_PREFIX
110 				+ ":GeocodeResponseList>");
111 		return sb.toString();
112 	}
113 }