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 eu
.etaxonomy
.cdm
.model
.location
.WaterbodyOrCountry
;
14 import eu
.etaxonomy
.cdm
.model
.location
.Point
;
15 import eu
.etaxonomy
.cdm
.model
.common
.VersionableEntity
;
16 import org
.apache
.log4j
.Logger
;
17 import javax
.persistence
.*;
20 * Representation of an atomized postal address.
22 * See also the <a href="http://rs.tdwg.org/ontology/voc/ContactDetails#Address">TDWG Ontology</a>
26 * @created 08-Nov-2007 13:06:09
29 public class Address
extends VersionableEntity
{
30 static Logger logger
= Logger
.getLogger(Address
.class);
32 private String street
;
33 private String postcode
;
34 private String locality
;
35 private String region
;
36 private WaterbodyOrCountry country
;
37 private Point location
;
38 //Bidirectional only private
39 private Contact contact
;
43 * Returns the {@link Contact contact} (of a {@link Person person} or of an {@link Institution institution})
44 * to which this address belongs.
45 * Both kinds of agents cannot have more than one contact, but a contact may include
46 * several postal addresses.
48 * @return the contact this postal address belongs to
52 public Contact
getContact() {
58 * Adds this postal address to the set of addresses of a {@link Contact contact}.
59 * The same address instance cannot be assigned to different persons
60 * or institutions (if they do have the same postal address several
61 * address instances must be created). If this address already belongs to a
62 * contact this method shifts it from this contact to a new one.
63 * Therefore this address will be removed from the set of addresses of the old
64 * contact and added to the set of the new one.
66 * @param newContact the new contact to which this postal address should belong
67 * @see Contact#addAddress(Address)
68 * @see Contact#removeAddress(Address)
70 protected void setContact(Contact newContact
) {
71 // Hibernate bidirectional cascade hack:
72 // http://opensource.atlassian.com/projects/hibernate/browse/HHH-1054
73 if(this.contact
== newContact
) return;
74 if (contact
!= null) {
75 contact
.addresses
.remove(this);
77 if (newContact
!= null) {
78 newContact
.addresses
.add(this);
80 this.contact
= newContact
;
85 * Returns the {@link WaterbodyOrCountry country} involved in this postal address.
90 public WaterbodyOrCountry
getCountry(){
97 public void setCountry(WaterbodyOrCountry country
){
98 this.country
= country
;
102 * Returns the geophysical {@link Point location} (coordinates) of this postal address.
103 * The location can be useful for instance to visualize the address on a map.
105 * @return the point corresponding to this address
106 * @see eu.etaxonomy.cdm.model.location.Point
108 public Point
getLocation(){
109 return this.location
;
113 * @see #getLocation()
115 public void setLocation(Point location
){
116 this.location
= location
;
120 * Returns a string corresponding to the post office box
121 * involved in this postal address.
123 * @return the post office box string
125 public String
getPobox(){
132 public void setPobox(String pobox
){
137 * Returns the street name and number involved in this postal address.
138 * Street numbers are part of the street string.
140 * @return the string composed of street name and number
142 public String
getStreet(){
149 public void setStreet(String street
){
150 this.street
= street
;
154 * Returns the post code number involved in this postal address.
156 * @return the post code number string
158 public String
getPostcode(){
159 return this.postcode
;
163 * @see #getPostcode()
165 public void setPostcode(String postcode
){
166 this.postcode
= postcode
;
170 * Returns the town (possibly with locality or suburb) involved in this postal address.
172 * @return the string representing a town
174 public String
getLocality(){
175 return this.locality
;
179 * @see #getLocality()
181 public void setLocality(String locality
){
182 this.locality
= locality
;
186 * Returns the region or state involved in this postal address.
188 * @return the string representing a region or a state
190 public String
getRegion(){
197 public void setRegion(String region
){
198 this.region
= region
;