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
.FetchType
;
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
.XmlIDREF
;
19 import javax
.xml
.bind
.annotation
.XmlRootElement
;
20 import javax
.xml
.bind
.annotation
.XmlSchemaType
;
21 import javax
.xml
.bind
.annotation
.XmlTransient
;
22 import javax
.xml
.bind
.annotation
.XmlType
;
24 import org
.apache
.log4j
.Logger
;
25 import org
.hibernate
.envers
.Audited
;
27 import eu
.etaxonomy
.cdm
.model
.common
.VersionableEntity
;
28 import eu
.etaxonomy
.cdm
.model
.location
.Point
;
29 import eu
.etaxonomy
.cdm
.model
.location
.WaterbodyOrCountry
;
32 * This class represents atomized postal addresses.
34 * This class corresponds to: <ul>
35 * <li> Address according to the TDWG ontology
36 * <li> Address according to the TCS
37 * <li> Address according to the ABCD schema
42 * @created 08-Nov-2007 13:06:09
44 @XmlAccessorType(XmlAccessType
.FIELD
)
45 @XmlType(name
= "Address", propOrder
= {
54 @XmlRootElement(name
= "Address")
57 public class Address
extends VersionableEntity
implements Cloneable
{
58 private static final long serialVersionUID
= 682106303069088972L;
59 @SuppressWarnings("unused")
60 private static final Logger logger
= Logger
.getLogger(Address
.class);
62 public static Address
NewInstance(){
66 public static Address
NewInstance(WaterbodyOrCountry country
,
67 String locality
, String pobox
, String postcode
,
68 String region
, String street
, Point location
) {
69 return new Address(country
, locality
, location
, pobox
, postcode
,
77 private Address(WaterbodyOrCountry country
, String locality
, Point location
,
78 String pobox
, String postcode
, String region
, String street
) {
80 this.country
= country
;
81 this.locality
= locality
;
82 this.location
= location
;
84 this.postcode
= postcode
;
89 @XmlElement(name
= "POBox")
92 @XmlElement(name
= "Street")
93 private String street
;
95 @XmlElement(name
= "Postcode")
96 private String postcode
;
98 @XmlElement(name
= "Locality", required
= true)
99 private String locality
;
101 @XmlElement(name
= "Region")
102 private String region
;
104 @XmlElement(name
= "Country")
106 @XmlSchemaType(name
= "IDREF")
107 @ManyToOne(fetch
= FetchType
.LAZY
)
108 private WaterbodyOrCountry country
;
110 @XmlElement(name
= "Location")
111 private Point location
;
114 * Returns the {@link WaterbodyOrCountry country} involved in <i>this</i> postal address.
116 * @return the country
118 public WaterbodyOrCountry
getCountry(){
125 public void setCountry(WaterbodyOrCountry country
){
126 this.country
= country
;
130 * Returns the geophysical {@link Point location} (coordinates) of <i>this</i> postal address.
131 * The location can be useful for instance to visualize the address on a map.
133 * @return the point corresponding to <i>this</i> address
134 * @see eu.etaxonomy.cdm.model.location.Point
137 public Point
getLocation(){
138 return this.location
;
142 * @see #getLocation()
144 public void setLocation(Point location
){
145 this.location
= location
;
149 * Returns a string corresponding to the post office box
150 * involved in <i>this</i> postal address.
152 * @return the post office box string
154 public String
getPobox(){
161 public void setPobox(String pobox
){
166 * Returns the street name and number involved in <i>this</i> postal address.
167 * Street numbers are part of the street string.
169 * @return the string composed of street name and number
171 public String
getStreet(){
178 public void setStreet(String street
){
179 this.street
= street
;
183 * Returns the post code number involved in <i>this</i> postal address.
185 * @return the post code number string
187 public String
getPostcode(){
188 return this.postcode
;
192 * @see #getPostcode()
194 public void setPostcode(String postcode
){
195 this.postcode
= postcode
;
199 * Returns the town (possibly with locality or suburb) involved in <i>this</i> postal address.
201 * @return the string representing a town
203 public String
getLocality(){
204 return this.locality
;
208 * @see #getLocality()
210 public void setLocality(String locality
){
211 this.locality
= locality
;
215 * Returns the region or state involved in <i>this</i> postal address.
217 * @return the string representing a region or a state
219 public String
getRegion(){
226 public void setRegion(String region
){
227 this.region
= region
;
230 //************************ CLONE ************************ //
232 * Clones this Address.
233 * Set fields for nextVersion, previousVersion, updated, updatedBy and createdBy are set to <tt>null</tt>
234 * The id is set to 0.
235 * The uuid is created new.
236 * The createdWhen is set to the current date.
237 * @see java.lang.Object#clone()
240 public Object
clone() throws CloneNotSupportedException
{
241 Address result
= (Address
)super.clone();