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.
9 package eu
.etaxonomy
.cdm
.model
.agent
;
11 import javax
.persistence
.Entity
;
12 import javax
.persistence
.FetchType
;
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
.logging
.log4j
.LogManager
;
24 import org
.apache
.logging
.log4j
.Logger
;
25 import org
.hibernate
.envers
.Audited
;
27 import eu
.etaxonomy
.cdm
.model
.common
.VersionableEntity
;
28 import eu
.etaxonomy
.cdm
.model
.location
.Country
;
29 import eu
.etaxonomy
.cdm
.model
.location
.Point
;
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
41 * @since 08-Nov-2007 13:06:09
43 @XmlAccessorType(XmlAccessType
.FIELD
)
44 @XmlType(name
= "Address", propOrder
= {
53 @XmlRootElement(name
= "Address")
56 public class Address
extends VersionableEntity
{
58 private static final long serialVersionUID
= 682106303069088972L;
59 @SuppressWarnings("unused")
60 private static final Logger logger
= LogManager
.getLogger();
62 public static Address
NewInstance(){
66 public static Address
NewInstance(Country 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(Country 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 Country country
;
110 @XmlElement(name
= "Location")
111 private Point location
;
114 * Returns the {@link Country country} involved in <i>this</i> postal address.
116 * @return the country
118 public Country
getCountry(){
125 public void setCountry(Country 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
){
162 this.pobox
= pobox
== "" ?
null : 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
== "" ?
null : 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
== "" ?
null : 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
== "" ?
null: 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
== "" ?
null: 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 Address
clone() throws CloneNotSupportedException
{
241 Address result
= (Address
)super.clone();