1 package nl.mineleni.openls.databinding.openls; 2 3 import nl.mineleni.openls.XmlNamespaceConstants; 4 5 /** 6 * OLS StreetAddress. http://schemas.opengis.net/ols/1.2.0/ADT.xsd 7 * 8 * <pre> 9 * 10 * <complexType name="StreetAddressType"> 11 * <annotation> 12 * <documentation>A set of precise and complete data elements that 13 * cannot be subdivided and that describe the physical location of 14 * a place.</documentation> 15 * </annotation> 16 * <sequence> 17 * <element ref="xls:_StreetLocation" minOccurs="0" /> 18 * <element ref="xls:Street" maxOccurs="unbounded" /> 19 * </sequence> 20 * <attribute name="locator"> 21 * <annotation> 22 * <documentation>typically used for the street number (e.g. 23) 23 * a. Can accommodate a number, or any other building locator b. 24 * "windmill house", "24E" and "323" are acceptable uses of the 25 * locator c. We will adopt the following conventions for 26 * representing address ranges in the locator attribute: i. 27 * Discontinuous range example: "1-9" means 1,3,5,7,9 ii. Two 28 * discontinous ranges: "1-9,2-10" implies 1,3,5,7,9 on one side 29 * of block and 2,4,6,8,10 on other side of block iii. 30 * Continuous range: "1...10" means 31 * 1,2,3,4,5,6,7,8,9,10</documentation> 32 * </annotation> 33 * </attribute> 34 * </complexType> 35 * <element name="StreetAddress" type="xls:StreetAddressType"> 36 * <annotation> 37 * <documentation>Structured street address.</documentation> 38 * </annotation> 39 * </element> 40 * 41 * </pre> 42 * 43 * @author Mark 44 */ 45 public class StreetAddress implements XmlNamespaceConstants { 46 /** 47 * serialization id. 48 */ 49 private static final long serialVersionUID = 4263464123444246781L; 50 51 /** The building. */ 52 private Building building; 53 54 /** The street. */ 55 private Street street; 56 57 /** The has building. */ 58 private boolean hasBuilding; 59 60 /** If this address has a street. */ 61 private boolean hasStreet; 62 63 /** 64 * Instantiates a new street address. 65 */ 66 public StreetAddress() { 67 this.hasBuilding = false; 68 this.hasStreet = false; 69 } 70 71 /** 72 * Sets the building. 73 * 74 * @param building 75 * the new building 76 */ 77 public void setBuilding(final Building building) { 78 this.hasBuilding = true; 79 this.building = building; 80 } 81 82 /** 83 * Gets the building. 84 * 85 * @return the building 86 */ 87 public Building getBuilding() { 88 return this.building; 89 } 90 91 /** 92 * Checks for building. 93 * 94 * @return true, if successful 95 */ 96 public boolean hasBuilding() { 97 return this.hasBuilding; 98 } 99 100 /** 101 * Sets the street. 102 * 103 * @param street 104 * the new street 105 */ 106 public void setStreet(final Street street) { 107 this.hasStreet = true; 108 this.street = street; 109 } 110 111 /** 112 * Gets the street. 113 * 114 * @return the street 115 */ 116 public Street getStreet() { 117 return this.street; 118 } 119 120 /** 121 * Checks for street. 122 * 123 * @return true, if successful 124 */ 125 public boolean hasStreet() { 126 return this.hasStreet; 127 } 128 129 /* 130 * (non-Javadoc) 131 * 132 * @see nl.mineleni.openls.XmlNamespaceConstants#toXML() 133 */ 134 @Override 135 public String toXML() { 136 String xml = "<" + XmlNamespaceConstants.OPENLS_NAMESPACE_PREFIX 137 + ":StreetAddress>"; 138 if (this.hasBuilding()) { 139 xml += this.building.toXML(); 140 } 141 if (this.hasStreet()) { 142 xml += this.street.toXML(); 143 } 144 xml += "</" + XmlNamespaceConstants.OPENLS_NAMESPACE_PREFIX 145 + ":StreetAddress>"; 146 return xml; 147 } 148 }