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
;
13 import javax
.persistence
.Entity
;
14 import javax
.persistence
.ManyToOne
;
15 import javax
.xml
.bind
.annotation
.XmlAccessType
;
16 import javax
.xml
.bind
.annotation
.XmlAccessorType
;
17 import javax
.xml
.bind
.annotation
.XmlElement
;
18 import javax
.xml
.bind
.annotation
.XmlRootElement
;
19 import javax
.xml
.bind
.annotation
.XmlTransient
;
20 import javax
.xml
.bind
.annotation
.XmlType
;
22 import org
.apache
.log4j
.Logger
;
24 import eu
.etaxonomy
.cdm
.model
.common
.VersionableEntity
;
25 import eu
.etaxonomy
.cdm
.model
.location
.Point
;
26 import eu
.etaxonomy
.cdm
.model
.location
.WaterbodyOrCountry
;
29 * Representation of an atomized postal address.
31 * See also the <a href="http://rs.tdwg.org/ontology/voc/ContactDetails#Address">TDWG Ontology</a>
35 * @created 08-Nov-2007 13:06:09
37 @XmlAccessorType(XmlAccessType
.FIELD
)
38 @XmlType(name
= "", propOrder
= {
48 @XmlRootElement(name
= "Address")
50 public class Address
extends VersionableEntity
{
52 static Logger logger
= Logger
.getLogger(Address
.class);
54 @XmlElement(name
= "POBox")
57 @XmlElement(name
= "Street")
58 private String street
;
60 @XmlElement(name
= "Postcode")
61 private String postcode
;
63 @XmlElement(name
= "Locality", required
= true)
64 private String locality
;
66 @XmlElement(name
= "Region")
67 private String region
;
69 @XmlElement(name
= "Country")
70 private WaterbodyOrCountry country
;
72 @XmlElement(name
= "Location")
73 private Point location
;
75 //Bidirectional only private
76 @XmlElement(name
= "Contact")
77 private Contact contact
;
81 * Returns the {@link Contact contact} (of a {@link Person person} or of an {@link Institution institution})
82 * to which <i>this</i> address belongs.
83 * Both kinds of agents cannot have more than one contact, but a contact may include
84 * several postal addresses.
86 * @return the contact <i>this</i> postal address belongs to
90 public Contact
getContact() {
96 * Adds <i>this</i> postal address to the set of addresses of a {@link Contact contact}.
97 * The same address instance cannot be assigned to different persons
98 * or institutions (if they do have the same postal address several
99 * address instances must be created). If <i>this</i> address already belongs to a
100 * contact this method shifts it from this contact to a new one.
101 * Therefore <i>this</i> address will be removed from the set of addresses of the old
102 * contact and added to the set of the new one.
104 * @param newContact the new contact to which <i>this</i> postal address should belong
105 * @see Contact#addAddress(Address)
106 * @see Contact#removeAddress(Address)
108 protected void setContact(Contact newContact
) {
109 this.contact
= newContact
;
114 * Returns the {@link WaterbodyOrCountry country} involved in <i>this</i> postal address.
116 * @return the country
119 public WaterbodyOrCountry
getCountry(){
126 public void setCountry(WaterbodyOrCountry country
){
127 this.country
= country
;
131 * Returns the geophysical {@link Point location} (coordinates) of <i>this</i> postal address.
132 * The location can be useful for instance to visualize the address on a map.
134 * @return the point corresponding to <i>this</i> address
135 * @see eu.etaxonomy.cdm.model.location.Point
138 public Point
getLocation(){
139 return this.location
;
143 * @see #getLocation()
145 public void setLocation(Point location
){
146 this.location
= location
;
150 * Returns a string corresponding to the post office box
151 * involved in <i>this</i> postal address.
153 * @return the post office box string
155 public String
getPobox(){
162 public void setPobox(String pobox
){
167 * Returns the street name and number involved in <i>this</i> postal address.
168 * Street numbers are part of the street string.
170 * @return the string composed of street name and number
172 public String
getStreet(){
179 public void setStreet(String street
){
180 this.street
= street
;
184 * Returns the post code number involved in <i>this</i> postal address.
186 * @return the post code number string
188 public String
getPostcode(){
189 return this.postcode
;
193 * @see #getPostcode()
195 public void setPostcode(String postcode
){
196 this.postcode
= postcode
;
200 * Returns the town (possibly with locality or suburb) involved in <i>this</i> postal address.
202 * @return the string representing a town
204 public String
getLocality(){
205 return this.locality
;
209 * @see #getLocality()
211 public void setLocality(String locality
){
212 this.locality
= locality
;
216 * Returns the region or state involved in <i>this</i> postal address.
218 * @return the string representing a region or a state
220 public String
getRegion(){
227 public void setRegion(String region
){
228 this.region
= region
;