2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
10 package eu
.etaxonomy
.cdm
.model
.agent
;
12 import javax
.persistence
.Entity
;
13 import javax
.persistence
.ManyToOne
;
14 import javax
.xml
.bind
.annotation
.XmlAccessType
;
15 import javax
.xml
.bind
.annotation
.XmlAccessorType
;
16 import javax
.xml
.bind
.annotation
.XmlElement
;
17 import javax
.xml
.bind
.annotation
.XmlIDREF
;
18 import javax
.xml
.bind
.annotation
.XmlRootElement
;
19 import javax
.xml
.bind
.annotation
.XmlSchemaType
;
20 import javax
.xml
.bind
.annotation
.XmlTransient
;
21 import javax
.xml
.bind
.annotation
.XmlType
;
23 import org
.apache
.log4j
.Logger
;
25 import eu
.etaxonomy
.cdm
.model
.common
.VersionableEntity
;
26 import eu
.etaxonomy
.cdm
.model
.location
.Point
;
27 import eu
.etaxonomy
.cdm
.model
.location
.WaterbodyOrCountry
;
30 * This class represents atomized postal addresses.
32 * This class corresponds to: <ul>
33 * <li> Address according to the TDWG ontology
34 * <li> Address according to the TCS
35 * <li> Address according to the ABCD schema
40 * @created 08-Nov-2007 13:06:09
42 @XmlAccessorType(XmlAccessType
.FIELD
)
43 @XmlType(name
= "", propOrder
= {
53 @XmlRootElement(name
= "Address")
55 public class Address
extends VersionableEntity
<Address
> {
60 private static final long serialVersionUID
= 682106303069088972L;
62 static Logger logger
= Logger
.getLogger(Address
.class);
64 @XmlElement(name
= "POBox")
67 @XmlElement(name
= "Street")
68 private String street
;
70 @XmlElement(name
= "Postcode")
71 private String postcode
;
73 @XmlElement(name
= "Locality", required
= true)
74 private String locality
;
76 @XmlElement(name
= "Region")
77 private String region
;
79 @XmlElement(name
= "Country")
81 @XmlSchemaType(name
= "IDREF")
82 private WaterbodyOrCountry country
;
84 @XmlElement(name
= "Location")
85 private Point location
;
87 //Bidirectional only private
88 @XmlElement(name
= "Contact")
89 private Contact contact
;
93 * Returns the {@link Contact contact} (of a {@link Person person} or of an {@link Institution institution})
94 * to which <i>this</i> address belongs.
95 * Both kinds of agents cannot have more than one contact, but a contact may include
96 * several postal addresses.
98 * @return the contact <i>this</i> postal address belongs to
102 public Contact
getContact() {
108 * Adds <i>this</i> postal address to the set of addresses of a {@link Contact contact}.
109 * The same address instance cannot be assigned to different persons
110 * or institutions (if they do have the same postal address several
111 * address instances must be created). If <i>this</i> address already belongs to a
112 * contact this method shifts it from this contact to a new one.
113 * Therefore <i>this</i> address will be removed from the set of addresses of the old
114 * contact and added to the set of the new one.
116 * @param newContact the new contact to which <i>this</i> postal address should belong
117 * @see Contact#addAddress(Address)
118 * @see Contact#removeAddress(Address)
120 protected void setContact(Contact newContact
) {
121 this.contact
= newContact
;
126 * Returns the {@link WaterbodyOrCountry country} involved in <i>this</i> postal address.
128 * @return the country
131 public WaterbodyOrCountry
getCountry(){
138 public void setCountry(WaterbodyOrCountry country
){
139 this.country
= country
;
143 * Returns the geophysical {@link Point location} (coordinates) of <i>this</i> postal address.
144 * The location can be useful for instance to visualize the address on a map.
146 * @return the point corresponding to <i>this</i> address
147 * @see eu.etaxonomy.cdm.model.location.Point
150 public Point
getLocation(){
151 return this.location
;
155 * @see #getLocation()
157 public void setLocation(Point location
){
158 this.location
= location
;
162 * Returns a string corresponding to the post office box
163 * involved in <i>this</i> postal address.
165 * @return the post office box string
167 public String
getPobox(){
174 public void setPobox(String pobox
){
179 * Returns the street name and number involved in <i>this</i> postal address.
180 * Street numbers are part of the street string.
182 * @return the string composed of street name and number
184 public String
getStreet(){
191 public void setStreet(String street
){
192 this.street
= street
;
196 * Returns the post code number involved in <i>this</i> postal address.
198 * @return the post code number string
200 public String
getPostcode(){
201 return this.postcode
;
205 * @see #getPostcode()
207 public void setPostcode(String postcode
){
208 this.postcode
= postcode
;
212 * Returns the town (possibly with locality or suburb) involved in <i>this</i> postal address.
214 * @return the string representing a town
216 public String
getLocality(){
217 return this.locality
;
221 * @see #getLocality()
223 public void setLocality(String locality
){
224 this.locality
= locality
;
228 * Returns the region or state involved in <i>this</i> postal address.
230 * @return the string representing a region or a state
232 public String
getRegion(){
239 public void setRegion(String region
){
240 this.region
= region
;