//#############################################################################
//#                                                                           #
//#  Copyright (C) <2015>  <IMS MAXIMS>                                       #
//#                                                                           #
//#  This program is free software: you can redistribute it and/or modify     #
//#  it under the terms of the GNU Affero General Public License as           #
//#  published by the Free Software Foundation, either version 3 of the       #
//#  License, or (at your option) any later version.                          # 
//#                                                                           #
//#  This program is distributed in the hope that it will be useful,          #
//#  but WITHOUT ANY WARRANTY; without even the implied warranty of           #
//#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            #
//#  GNU Affero General Public License for more details.                      #
//#                                                                           #
//#  You should have received a copy of the GNU Affero General Public License #
//#  along with this program.  If not, see <http://www.gnu.org/licenses/>.    #
//#                                                                           #
//#  IMS MAXIMS provides absolutely NO GUARANTEE OF THE CLINICAL SAFTEY of    #
//#  this program.  Users of this software do so entirely at their own risk.  #
//#  IMS MAXIMS only ensures the Clinical Safety of unaltered run-time        #
//#  software that it builds, deploys and maintains.                          #
//#                                                                           #
//#############################################################################
//#EOH
// This code was generated by Barbara Worwood using IMS Development Environment (version 1.80 build 5589.25814)
// Copyright (C) 1995-2015 IMS MAXIMS. All rights reserved.
// WARNING: DO NOT MODIFY the content of this file

package ims.core.vo;

/**
 * Linked to core.generic.Address business object (ID: 1002100000).
 */
public class PersonAddress extends ims.core.generic.vo.AddressRefVo implements ims.vo.ImsCloneable, Comparable, ims.framework.interfaces.IAddress
{
	private static final long serialVersionUID = 1L;

	public PersonAddress()
	{
	}
	public PersonAddress(Integer id, int version)
	{
		super(id, version);
	}
	public PersonAddress(ims.core.vo.beans.PersonAddressBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.line1 = bean.getLine1();
		this.line2 = bean.getLine2();
		this.line3 = bean.getLine3();
		this.line4 = bean.getLine4();
		this.line5 = bean.getLine5();
		this.postcode = bean.getPostCode();
		this.phone = bean.getPhone();
		this.county = bean.getCounty() == null ? null : ims.ntpf.vo.lookups.County.buildLookup(bean.getCounty());
		this.fax = bean.getFax();
		this.updatedate = bean.getUpdateDate() == null ? null : bean.getUpdateDate().buildDateTime();
		this.notificationdate = bean.getNotificationDate() == null ? null : bean.getNotificationDate().buildDate();
		this.addresstype = bean.getAddressType() == null ? null : ims.core.vo.lookups.AddressType.buildLookup(bean.getAddressType());
		this.addresssearchtxt = bean.getAddressSearchTxt();
		this.pct = bean.getPCT();
		this.otherphone = bean.getOtherphone();
		this.lsoa = bean.getLSOA();
		this.organisation = bean.getOrganisation();
		this.areaofresidence = bean.getAreaOfResidence() == null ? null : ims.ntpf_ptr.vo.lookups.AreaOfResidence.buildLookup(bean.getAreaOfResidence());
		this.pafkey = bean.getPafkey();
		this.description = bean.getDescription();
		this.objectidentifier = bean.getObjectidentifier();
		this.beffdate = bean.getBeffdate() == null ? null : bean.getBeffdate().buildDate();
		this.beffdatecnf = bean.getBeffdatecnf();
		this.betdate = bean.getBetdate() == null ? null : bean.getBetdate().buildDate();
		this.betdatecnf = bean.getBetdatecnf();
		this.pdsupdatemode = bean.getPdsUpdateMode() == null ? null : ims.core.vo.lookups.PDSUpdateMode.buildLookup(bean.getPdsUpdateMode());
		this.country = bean.getCountry() == null ? null : ims.core.vo.lookups.Country.buildLookup(bean.getCountry());
		this.nofixedabode = bean.getNoFixedAbode();
		this.carehome = bean.getCareHome();
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.core.vo.beans.PersonAddressBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.line1 = bean.getLine1();
		this.line2 = bean.getLine2();
		this.line3 = bean.getLine3();
		this.line4 = bean.getLine4();
		this.line5 = bean.getLine5();
		this.postcode = bean.getPostCode();
		this.phone = bean.getPhone();
		this.county = bean.getCounty() == null ? null : ims.ntpf.vo.lookups.County.buildLookup(bean.getCounty());
		this.fax = bean.getFax();
		this.updatedate = bean.getUpdateDate() == null ? null : bean.getUpdateDate().buildDateTime();
		this.notificationdate = bean.getNotificationDate() == null ? null : bean.getNotificationDate().buildDate();
		this.addresstype = bean.getAddressType() == null ? null : ims.core.vo.lookups.AddressType.buildLookup(bean.getAddressType());
		this.addresssearchtxt = bean.getAddressSearchTxt();
		this.pct = bean.getPCT();
		this.otherphone = bean.getOtherphone();
		this.lsoa = bean.getLSOA();
		this.organisation = bean.getOrganisation();
		this.areaofresidence = bean.getAreaOfResidence() == null ? null : ims.ntpf_ptr.vo.lookups.AreaOfResidence.buildLookup(bean.getAreaOfResidence());
		this.pafkey = bean.getPafkey();
		this.description = bean.getDescription();
		this.objectidentifier = bean.getObjectidentifier();
		this.beffdate = bean.getBeffdate() == null ? null : bean.getBeffdate().buildDate();
		this.beffdatecnf = bean.getBeffdatecnf();
		this.betdate = bean.getBetdate() == null ? null : bean.getBetdate().buildDate();
		this.betdatecnf = bean.getBetdatecnf();
		this.pdsupdatemode = bean.getPdsUpdateMode() == null ? null : ims.core.vo.lookups.PDSUpdateMode.buildLookup(bean.getPdsUpdateMode());
		this.country = bean.getCountry() == null ? null : ims.core.vo.lookups.Country.buildLookup(bean.getCountry());
		this.nofixedabode = bean.getNoFixedAbode();
		this.carehome = bean.getCareHome();
	}
	public ims.vo.ValueObjectBean getBean()
	{
		return this.getBean(new ims.vo.ValueObjectBeanMap());
	}
	public ims.vo.ValueObjectBean getBean(ims.vo.ValueObjectBeanMap map)
	{
		ims.core.vo.beans.PersonAddressBean bean = null;
		if(map != null)
			bean = (ims.core.vo.beans.PersonAddressBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.core.vo.beans.PersonAddressBean();
			map.addValueObjectBean(this, bean);
			bean.populate(map, this);
		}
		return bean;
	}
	public Object getFieldValueByFieldName(String fieldName)
	{
		if(fieldName == null)
			throw new ims.framework.exceptions.CodingRuntimeException("Invalid field name");
		fieldName = fieldName.toUpperCase();
		if(fieldName.equals("LINE1"))
			return getLine1();
		if(fieldName.equals("LINE2"))
			return getLine2();
		if(fieldName.equals("LINE3"))
			return getLine3();
		if(fieldName.equals("LINE4"))
			return getLine4();
		if(fieldName.equals("LINE5"))
			return getLine5();
		if(fieldName.equals("POSTCODE"))
			return getPostCode();
		if(fieldName.equals("PHONE"))
			return getPhone();
		if(fieldName.equals("COUNTY"))
			return getCounty();
		if(fieldName.equals("FAX"))
			return getFax();
		if(fieldName.equals("UPDATEDATE"))
			return getUpdateDate();
		if(fieldName.equals("NOTIFICATIONDATE"))
			return getNotificationDate();
		if(fieldName.equals("ADDRESSTYPE"))
			return getAddressType();
		if(fieldName.equals("ADDRESSSEARCHTXT"))
			return getAddressSearchTxt();
		if(fieldName.equals("PCT"))
			return getPCT();
		if(fieldName.equals("OTHERPHONE"))
			return getOtherphone();
		if(fieldName.equals("LSOA"))
			return getLSOA();
		if(fieldName.equals("ORGANISATION"))
			return getOrganisation();
		if(fieldName.equals("AREAOFRESIDENCE"))
			return getAreaOfResidence();
		if(fieldName.equals("PAFKEY"))
			return getPafkey();
		if(fieldName.equals("DESCRIPTION"))
			return getDescription();
		if(fieldName.equals("OBJECTIDENTIFIER"))
			return getObjectidentifier();
		if(fieldName.equals("BEFFDATE"))
			return getBeffdate();
		if(fieldName.equals("BEFFDATECNF"))
			return getBeffdatecnf();
		if(fieldName.equals("BETDATE"))
			return getBetdate();
		if(fieldName.equals("BETDATECNF"))
			return getBetdatecnf();
		if(fieldName.equals("PDSUPDATEMODE"))
			return getPdsUpdateMode();
		if(fieldName.equals("COUNTRY"))
			return getCountry();
		if(fieldName.equals("NOFIXEDABODE"))
			return getNoFixedAbode();
		if(fieldName.equals("CAREHOME"))
			return getCareHome();
		return super.getFieldValueByFieldName(fieldName);
	}
	public boolean getLine1IsNotNull()
	{
		return this.line1 != null;
	}
	public String getLine1()
	{
		return this.line1;
	}
	public static int getLine1MaxLength()
	{
		return 40;
	}
	public void setLine1(String value)
	{
		this.isValidated = false;
		this.line1 = value;
	}
	public boolean getLine2IsNotNull()
	{
		return this.line2 != null;
	}
	public String getLine2()
	{
		return this.line2;
	}
	public static int getLine2MaxLength()
	{
		return 40;
	}
	public void setLine2(String value)
	{
		this.isValidated = false;
		this.line2 = value;
	}
	public boolean getLine3IsNotNull()
	{
		return this.line3 != null;
	}
	public String getLine3()
	{
		return this.line3;
	}
	public static int getLine3MaxLength()
	{
		return 40;
	}
	public void setLine3(String value)
	{
		this.isValidated = false;
		this.line3 = value;
	}
	public boolean getLine4IsNotNull()
	{
		return this.line4 != null;
	}
	public String getLine4()
	{
		return this.line4;
	}
	public static int getLine4MaxLength()
	{
		return 40;
	}
	public void setLine4(String value)
	{
		this.isValidated = false;
		this.line4 = value;
	}
	public boolean getLine5IsNotNull()
	{
		return this.line5 != null;
	}
	public String getLine5()
	{
		return this.line5;
	}
	public static int getLine5MaxLength()
	{
		return 40;
	}
	public void setLine5(String value)
	{
		this.isValidated = false;
		this.line5 = value;
	}
	public boolean getPostCodeIsNotNull()
	{
		return this.postcode != null;
	}
	public String getPostCode()
	{
		return this.postcode;
	}
	public static int getPostCodeMaxLength()
	{
		return 10;
	}
	public void setPostCode(String value)
	{
		this.isValidated = false;
		this.postcode = value;
	}
	public boolean getPhoneIsNotNull()
	{
		return this.phone != null;
	}
	public String getPhone()
	{
		return this.phone;
	}
	public static int getPhoneMaxLength()
	{
		return 30;
	}
	public void setPhone(String value)
	{
		this.isValidated = false;
		this.phone = value;
	}
	public boolean getCountyIsNotNull()
	{
		return this.county != null;
	}
	public ims.ntpf.vo.lookups.County getCounty()
	{
		return this.county;
	}
	public void setCounty(ims.ntpf.vo.lookups.County value)
	{
		this.isValidated = false;
		this.county = value;
	}
	public boolean getFaxIsNotNull()
	{
		return this.fax != null;
	}
	public String getFax()
	{
		return this.fax;
	}
	public static int getFaxMaxLength()
	{
		return 30;
	}
	public void setFax(String value)
	{
		this.isValidated = false;
		this.fax = value;
	}
	public boolean getUpdateDateIsNotNull()
	{
		return this.updatedate != null;
	}
	public ims.framework.utils.DateTime getUpdateDate()
	{
		return this.updatedate;
	}
	public void setUpdateDate(ims.framework.utils.DateTime value)
	{
		this.isValidated = false;
		this.updatedate = value;
	}
	public boolean getNotificationDateIsNotNull()
	{
		return this.notificationdate != null;
	}
	public ims.framework.utils.Date getNotificationDate()
	{
		return this.notificationdate;
	}
	public void setNotificationDate(ims.framework.utils.Date value)
	{
		this.isValidated = false;
		this.notificationdate = value;
	}
	public boolean getAddressTypeIsNotNull()
	{
		return this.addresstype != null;
	}
	public ims.core.vo.lookups.AddressType getAddressType()
	{
		return this.addresstype;
	}
	public void setAddressType(ims.core.vo.lookups.AddressType value)
	{
		this.isValidated = false;
		this.addresstype = value;
	}
	public boolean getAddressSearchTxtIsNotNull()
	{
		return this.addresssearchtxt != null;
	}
	public String getAddressSearchTxt()
	{
		return this.addresssearchtxt;
	}
	public static int getAddressSearchTxtMaxLength()
	{
		return 255;
	}
	public void setAddressSearchTxt(String value)
	{
		this.isValidated = false;
		this.addresssearchtxt = value;
	}
	public boolean getPCTIsNotNull()
	{
		return this.pct != null;
	}
	public String getPCT()
	{
		return this.pct;
	}
	public static int getPCTMaxLength()
	{
		return 15;
	}
	public void setPCT(String value)
	{
		this.isValidated = false;
		this.pct = value;
	}
	public boolean getOtherphoneIsNotNull()
	{
		return this.otherphone != null;
	}
	public String getOtherphone()
	{
		return this.otherphone;
	}
	public static int getOtherphoneMaxLength()
	{
		return 30;
	}
	public void setOtherphone(String value)
	{
		this.isValidated = false;
		this.otherphone = value;
	}
	public boolean getLSOAIsNotNull()
	{
		return this.lsoa != null;
	}
	public String getLSOA()
	{
		return this.lsoa;
	}
	public static int getLSOAMaxLength()
	{
		return 255;
	}
	public void setLSOA(String value)
	{
		this.isValidated = false;
		this.lsoa = value;
	}
	public boolean getOrganisationIsNotNull()
	{
		return this.organisation != null;
	}
	public String getOrganisation()
	{
		return this.organisation;
	}
	public static int getOrganisationMaxLength()
	{
		return 255;
	}
	public void setOrganisation(String value)
	{
		this.isValidated = false;
		this.organisation = value;
	}
	public boolean getAreaOfResidenceIsNotNull()
	{
		return this.areaofresidence != null;
	}
	public ims.ntpf_ptr.vo.lookups.AreaOfResidence getAreaOfResidence()
	{
		return this.areaofresidence;
	}
	public void setAreaOfResidence(ims.ntpf_ptr.vo.lookups.AreaOfResidence value)
	{
		this.isValidated = false;
		this.areaofresidence = value;
	}
	public boolean getPafkeyIsNotNull()
	{
		return this.pafkey != null;
	}
	public String getPafkey()
	{
		return this.pafkey;
	}
	public static int getPafkeyMaxLength()
	{
		return 8;
	}
	public void setPafkey(String value)
	{
		this.isValidated = false;
		this.pafkey = value;
	}
	public boolean getDescriptionIsNotNull()
	{
		return this.description != null;
	}
	public String getDescription()
	{
		return this.description;
	}
	public static int getDescriptionMaxLength()
	{
		return 100;
	}
	public void setDescription(String value)
	{
		this.isValidated = false;
		this.description = value;
	}
	public boolean getObjectidentifierIsNotNull()
	{
		return this.objectidentifier != null;
	}
	public String getObjectidentifier()
	{
		return this.objectidentifier;
	}
	public static int getObjectidentifierMaxLength()
	{
		return 14;
	}
	public void setObjectidentifier(String value)
	{
		this.isValidated = false;
		this.objectidentifier = value;
	}
	public boolean getBeffdateIsNotNull()
	{
		return this.beffdate != null;
	}
	public ims.framework.utils.Date getBeffdate()
	{
		return this.beffdate;
	}
	public void setBeffdate(ims.framework.utils.Date value)
	{
		this.isValidated = false;
		this.beffdate = value;
	}
	public boolean getBeffdatecnfIsNotNull()
	{
		return this.beffdatecnf != null;
	}
	public Boolean getBeffdatecnf()
	{
		return this.beffdatecnf;
	}
	public void setBeffdatecnf(Boolean value)
	{
		this.isValidated = false;
		this.beffdatecnf = value;
	}
	public boolean getBetdateIsNotNull()
	{
		return this.betdate != null;
	}
	public ims.framework.utils.Date getBetdate()
	{
		return this.betdate;
	}
	public void setBetdate(ims.framework.utils.Date value)
	{
		this.isValidated = false;
		this.betdate = value;
	}
	public boolean getBetdatecnfIsNotNull()
	{
		return this.betdatecnf != null;
	}
	public Boolean getBetdatecnf()
	{
		return this.betdatecnf;
	}
	public void setBetdatecnf(Boolean value)
	{
		this.isValidated = false;
		this.betdatecnf = value;
	}
	public boolean getPdsUpdateModeIsNotNull()
	{
		return this.pdsupdatemode != null;
	}
	public ims.core.vo.lookups.PDSUpdateMode getPdsUpdateMode()
	{
		return this.pdsupdatemode;
	}
	public void setPdsUpdateMode(ims.core.vo.lookups.PDSUpdateMode value)
	{
		this.isValidated = false;
		this.pdsupdatemode = value;
	}
	public boolean getCountryIsNotNull()
	{
		return this.country != null;
	}
	public ims.core.vo.lookups.Country getCountry()
	{
		return this.country;
	}
	public void setCountry(ims.core.vo.lookups.Country value)
	{
		this.isValidated = false;
		this.country = value;
	}
	public boolean getNoFixedAbodeIsNotNull()
	{
		return this.nofixedabode != null;
	}
	public Boolean getNoFixedAbode()
	{
		return this.nofixedabode;
	}
	public void setNoFixedAbode(Boolean value)
	{
		this.isValidated = false;
		this.nofixedabode = value;
	}
	public boolean getCareHomeIsNotNull()
	{
		return this.carehome != null;
	}
	public Boolean getCareHome()
	{
		return this.carehome;
	}
	public void setCareHome(Boolean value)
	{
		this.isValidated = false;
		this.carehome = value;
	}
	/**
	* toDisplayString: Returns a formatted String suitable for Display purposes
	*/
	public String toDisplayString()
	{
		java.lang.StringBuffer sb = new java.lang.StringBuffer("");
		boolean bPostCodeAdded = false;
	
		if (line1 != null && line1.length() > 0) {
			sb.append(line1 + ", ");
		}
		if (line2 != null && line2.length() > 0) {
			sb.append(line2 + ", ");
		}
		if (line3 != null && line3.length() > 0) {
			sb.append(line3 + ", ");
		}
		if (line4 != null && line4.length() > 0) {
			sb.append(line4 + ", ");
		}
		if (line5 != null && line5.length() > 0) {
			sb.append(line5 + ", ");
		}
		if (areaofresidence != null && areaofresidence.getText() != null) {
			sb.append(areaofresidence.getText() + ", ");
		}
		if (postcode != null && postcode.length() > 0) {
			sb.append(postcode);
			bPostCodeAdded = true;
		}
		if (county != null && county.getText() != null)
		{
			sb.append((bPostCodeAdded ? ", " : "") + county.getText() + (this.countFieldsWithValue() > 2 ? "." : "")); //only adding full stop if more than 1 address field filled in
		}
		else
			sb.append(bPostCodeAdded && this.countFieldsWithValue() > 2 ? "." : ""); //only adding full stop if more than 1 address field filled in
		
		if (sb.length() > 0)
		{
			if (sb.toString().trim().length() > 0 && sb.toString().trim().endsWith(","))	
				sb.setLength(sb.toString().trim().length() - 1);
			sb.append("   ");
		}
		return sb.toString();
	}
	
	/**
	* toDisplayStringForMultiLineTextBox: returns a carriage return formatted String
	*/
	public String toDisplayStringForMultiLineTextBox()
	{
		java.lang.StringBuffer sb = new java.lang.StringBuffer("");
		if (line1 != null && line1.length() > 0) {
			sb.append(line1 + "\r\n");
		}
		if (line2 != null && line2.length() > 0) {
			sb.append(line2 + "\r\n");
		}
		if (line3 != null && line3.length() > 0) {
			sb.append(line3 + "\r\n");
		}
		if (line4 != null && line4.length() > 0) {
			sb.append(line4 + "\r\n");
		}
		if (line5 != null && line5.length() > 0) {
			sb.append(line5 + "\r\n");
		}
		if (areaofresidence != null && areaofresidence.getText() != null) {
			sb.append(areaofresidence.getText() + "\r\n");
		}
		if (postcode != null && postcode.length() > 0) {
			sb.append(postcode + "\r\n");
		}
		if (county != null && county.getText() != null)
		{
			sb.append(county.getText() + "\r\n");
		}
	
		if (sb.length() > 0)
		{
			sb.setLength(sb.length() - 1);
		}
		return sb.toString();
	}
	/**
	* toNTPFDisplayString
	*/
	public String toNTPFDisplayString()
	{
		java.lang.StringBuffer sb = new java.lang.StringBuffer("");
		if (line1 != null && line1.length() > 0) {
			sb.append(line1 + ",");
		}
		if (line2 != null && line2.length() > 0) {
			sb.append(line2 + ",");
		}
		if (line3 != null && line3.length() > 0) {
			sb.append(line3 + ",");
		}
		if (postcode != null && postcode.length() > 0) {
			sb.append(postcode + ",");
		}
		if (county != null && county.getText().length() > 0) {
			sb.append(county.getText() + ",");
		}			
		if (sb.length() > 0)
		{
			sb.setLength(sb.length() - 1);
		}
		return sb.toString();
	}
	
	/**
	* IAddress Interface implementation
	*/
			public String getAddressBuildingNumber() 
			{
				return line2;
			}
			public String getAddressCounty() {
				
				return line5;
			}
			public String getAddressLine5() 
			{
				return line5;
			}
			public String getAddressLocality() 
			{		
				return line3;
			}
			public String getAddressPostCode() 
			{
				return postcode;
			}
			public String getAddressPostTown() 
			{
				return line4;
			}
			public String getAddressStreet() 
			{
				return line2;
			}
			public void setAddressBuildingNumber(String buildingNumber) {
				line2 = buildingNumber;
				
			}
			public void setAddressLine5(String addrLine5) 
			{
				line5 = addrLine5;
				
			}
			public void setAddressCounty(String county) {
				line5 = county;
				
			}
			public void setAddressLocality(String locality) {
				line3 = locality;
			}
			public void setAddressPostCode(String postCode) {
				postcode = postCode;
				
			}
			public void setAddressPostTown(String postTown) {
				line4 = postTown;
				
			}
			public void setAddressStreet(String street) {
				if (line2 != null && line2.equals(""))
					line2 = street;
				else
					line2 += " " + street;			
			}
			public String getAddressSearchText() 
			{
				return this.addresssearchtxt;
			}
			public void setAddressSearchText(String addressSearchText) 
			{		
				this.addresssearchtxt = addressSearchText;
			}
			
			public String getAddressBuildingName() 
			{
				return line1;
			}
			public void setAddressBuildingName(String buildingName) 
			{
				line1 = buildingName;			
			}
		      public String getPctCode() 
		      {
			      return pct;
		      }
		      public void setPCTcode(String pctCode) 
		      {
			      pct = pctCode;
		      }
		      public String getAddressOrganisation() 
		      {
			      return organisation;
		      }
		      public void setAddressOrganisation(String orgCode) 
		      {
			      organisation = orgCode;
		      }
	
	/**
	* equals
	*/
	public boolean equals(Object obj)
		{
			if (!(obj instanceof PersonAddress))
				return false;
			PersonAddress compareObj = (PersonAddress)obj;
			if ((line1 == null ? compareObj.line1 == null : line1.equals(compareObj.line1)) &&
				(line2 == null ? compareObj.line2 == null : line2.equals(compareObj.line2)) &&
				(line3 == null ? compareObj.line3 == null : line3.equals(compareObj.line3)) &&
				(line4 == null ? compareObj.line4 == null : line4.equals(compareObj.line4)) &&
				(line5 == null ? compareObj.line5 == null : line5.equals(compareObj.line5)) &&
				(phone == null ? compareObj.phone == null : phone.equals(compareObj.phone)) &&
				(postcode == null ? compareObj.postcode == null : postcode.equals(compareObj.postcode)) &&
				(county == null ? compareObj.county == null : county.equals(compareObj.county)) &&
				(areaofresidence == null ? compareObj.areaofresidence == null : areaofresidence .equals(compareObj.areaofresidence)) &&
				(addresstype == null ? compareObj.addresstype == null : addresstype.equals(compareObj.addresstype)) &&
				(notificationdate == null ? compareObj.notificationdate == null : notificationdate.equals(compareObj.notificationdate)) &&
				(beffdate == null ? compareObj.beffdate == null : beffdate.equals(compareObj.beffdate)) &&
				(betdate == null ? compareObj.betdate == null : betdate.equals(compareObj.betdate)))
					return true;
				return super.equals(obj);
		}
	/**
	* hashCode
	*/
	public int hashCode()
		{
			int hashValue = 0;
			if (this.line1 != null)
				hashValue += this.line1.hashCode();
			if (this.line2 != null)
				hashValue += this.line2.hashCode();
			if (this.line3 != null)
				hashValue += this.line3.hashCode();
			if (this.line4 != null)
				hashValue += this.line4.hashCode();
			if (this.line5 != null)
				hashValue += this.line5.hashCode();
			if (this.phone != null)
				hashValue += this.phone.hashCode();
			if (this.county != null)
				hashValue += this.county.hashCode();
			if (this.postcode != null)
				hashValue += this.postcode.hashCode();
			if (this.areaofresidence != null)
				hashValue += this.areaofresidence.hashCode();
			if (this.addresstype != null)
				hashValue += this.addresstype.hashCode();
			if (this.notificationdate!=null)
				hashValue += this.notificationdate.hashCode();
			return hashValue;
		}
	/**
	* pdsEquals
	*/
		public boolean pdsEquals(Object obj)
		{
			if (this == obj)
				return true;
	
			if(obj == null)
				return false;
			
			if (getClass() != obj.getClass())
				return false;
			
			PersonAddress other = (PersonAddress) obj;
			if (addresstype == null)
			{
				if (other.addresstype != null)
					return false;
			}
			else if (!addresstype.equals(other.addresstype))
				return false;
			if (areaofresidence == null)
			{
				if (other.areaofresidence != null)
					return false;
			}
			else if (!areaofresidence.equals(other.areaofresidence))
				return false;
			if (beffdate == null)
			{
				if (other.beffdate != null)
					return false;
			}
			else if (!beffdate.equals(other.beffdate))
				return false;
			if (beffdatecnf == null)
			{
				if (other.beffdatecnf != null)
					return false;
			}
			else if (!beffdatecnf.equals(other.beffdatecnf))
				return false;
			if (betdate == null)
			{
				if (other.betdate != null)
					return false;
			}
			else if (!betdate.equals(other.betdate))
				return false;
			if (betdatecnf == null)
			{
				if (other.betdatecnf != null)
					return false;
			}
			else if (!betdatecnf.equals(other.betdatecnf))
				return false;
			if (carehome == null)
			{
				if (other.carehome != null)
					return false;
			}
			else if (other.carehome != null && !carehome.equals(other.carehome))
				return false;
			if (country == null)
			{
				if (other.country != null)
					return false;
			}
			else if (!country.equals(other.country))
				return false;
			if (county == null)
			{
				if (other.county != null)
					return false;
			}
			else if (!county.equals(other.county))
				return false;
			if (description == null)
			{
				if (other.description != null)
					return false;
			}
			else if (!description.equals(other.description))
				return false;
			if (fax == null)
			{
				if (other.fax != null)
					return false;
			}
			else if (!fax.equals(other.fax))
				return false;
			if (isBusy != other.isBusy)
				return false;
			if (isValidated != other.isValidated)
				return false;
				if (line1 == null)
				{
					if (other.line1 != null)
						return false;
				}
				else if (line1 != null && line1.length()==0)
				{
					if (other.line1 != null)
						return false;
				}
				else if (!line1.equals(other.line1))
					return false;
				if (line2 == null)
				{
					if (other.line2 != null)
						return false;
				}
				else if (line2 != null && line2.length()==0)
				{
					if (other.line2 != null)
						return false;
				}
				else if (!line2.equals(other.line2))
					return false;
				if (line3 == null)
				{
					if (other.line3 != null)
						return false;
				}
				else if (line3 != null && line3.length()==0)
				{
					if (other.line3 != null)
						return false;
				}			
				else if (!line3.equals(other.line3))
					return false;
				if (line4 == null)
				{
					if (other.line4 != null)
						return false;
				}
				else if (line4 != null && line4.length()==0)
				{
					if (other.line4 != null)
						return false;
				}						
				else if (!line4.equals(other.line4))
					return false;
				if (line5 == null)
				{
					if (other.line5 != null)
						return false;
				}
				else if (line5 != null && line5.length()==0)
				{
					if (other.line5 != null)
						return false;
				}									
				else if (!line5.equals(other.line5))
					return false;
			if (nofixedabode == null)
			{
				if (other.nofixedabode != null)
					return false;
			}
			else if (other.nofixedabode != null && !nofixedabode.equals(other.nofixedabode))
				return false;
			if (notificationdate == null)
			{
				if (other.notificationdate != null)
					return false;
			}
			else if (!notificationdate.equals(other.notificationdate))
				return false;
			if (otherphone == null)
			{
				if (other.otherphone != null)
					return false;
			}
			else if (!otherphone.equals(other.otherphone))
				return false;
			if (pafkey == null)
			{
				if (other.pafkey != null)
					return false;
			}
			else if (!pafkey.equals(other.pafkey))
				return false;
			if (pct == null)
			{
				if (other.pct != null)
					return false;
			}
			else if (!pct.equals(other.pct))
				return false;
			if (phone == null)
			{
				if (other.phone != null)
					return false;
			}
			else if (!phone.equals(other.phone))
				return false;
			if (postcode == null)
			{
				if (other.postcode != null)
					return false;
			}
			else if (!postcode.equals(other.postcode))
				return false;
			if (updatedate == null)
			{
				if (other.updatedate != null)
					return false;
			}
			else if (!updatedate.equals(other.updatedate))
				return false;
			return true;
		}
	public boolean isValidated()
	{
		if(this.isBusy)
			return true;
		this.isBusy = true;
	
		if(!this.isValidated)
		{
			this.isBusy = false;
			return false;
		}
		this.isBusy = false;
		return true;
	}
	public String[] validate()
	{
		return validate(null);
	}
	public String[] validate(String[] existingErrors)
	{
		if(this.isBusy)
			return null;
		this.isBusy = true;
	
		java.util.ArrayList<String> listOfErrors = new java.util.ArrayList<String>();
		if(existingErrors != null)
		{
			for(int x = 0; x < existingErrors.length; x++)
			{
				listOfErrors.add(existingErrors[x]);
			}
		}
		if(this.line1 != null)
			if(this.line1.length() > 40)
				listOfErrors.add("The length of the field [line1] in the value object [ims.core.vo.PersonAddress] is too big. It should be less or equal to 40");
		if(this.line2 != null)
			if(this.line2.length() > 40)
				listOfErrors.add("The length of the field [line2] in the value object [ims.core.vo.PersonAddress] is too big. It should be less or equal to 40");
		if(this.line3 != null)
			if(this.line3.length() > 40)
				listOfErrors.add("The length of the field [line3] in the value object [ims.core.vo.PersonAddress] is too big. It should be less or equal to 40");
		if(this.line4 != null)
			if(this.line4.length() > 40)
				listOfErrors.add("The length of the field [line4] in the value object [ims.core.vo.PersonAddress] is too big. It should be less or equal to 40");
		if(this.line5 != null)
			if(this.line5.length() > 40)
				listOfErrors.add("The length of the field [line5] in the value object [ims.core.vo.PersonAddress] is too big. It should be less or equal to 40");
		if(this.postcode != null)
			if(this.postcode.length() > 10)
				listOfErrors.add("The length of the field [postcode] in the value object [ims.core.vo.PersonAddress] is too big. It should be less or equal to 10");
		if(this.phone != null)
			if(this.phone.length() > 30)
				listOfErrors.add("The length of the field [phone] in the value object [ims.core.vo.PersonAddress] is too big. It should be less or equal to 30");
		if(this.fax != null)
			if(this.fax.length() > 30)
				listOfErrors.add("The length of the field [fax] in the value object [ims.core.vo.PersonAddress] is too big. It should be less or equal to 30");
		if(this.pct != null)
			if(this.pct.length() > 15)
				listOfErrors.add("The length of the field [pct] in the value object [ims.core.vo.PersonAddress] is too big. It should be less or equal to 15");
		if(this.otherphone != null)
			if(this.otherphone.length() > 30)
				listOfErrors.add("The length of the field [otherphone] in the value object [ims.core.vo.PersonAddress] is too big. It should be less or equal to 30");
		if(this.pafkey != null)
			if(this.pafkey.length() > 8)
				listOfErrors.add("The length of the field [pafkey] in the value object [ims.core.vo.PersonAddress] is too big. It should be less or equal to 8");
		if(this.description != null)
			if(this.description.length() > 100)
				listOfErrors.add("The length of the field [description] in the value object [ims.core.vo.PersonAddress] is too big. It should be less or equal to 100");
		if(this.objectidentifier != null)
			if(this.objectidentifier.length() > 14)
				listOfErrors.add("The length of the field [objectidentifier] in the value object [ims.core.vo.PersonAddress] is too big. It should be less or equal to 14");
		int errorCount = listOfErrors.size();
		if(errorCount == 0)
		{
			this.isBusy = false;
			this.isValidated = true;
			return null;
		}
		String[] result = new String[errorCount];
		for(int x = 0; x < errorCount; x++)
			result[x] = (String)listOfErrors.get(x);
		this.isBusy = false;
		this.isValidated = false;
		return result;
	}
	public void clearIDAndVersion()
	{
		this.id = null;
		this.version = 0;
	}
	public Object clone()
	{
		if(this.isBusy)
			return this;
		this.isBusy = true;
	
		PersonAddress clone = new PersonAddress(this.id, this.version);
		
		clone.line1 = this.line1;
		clone.line2 = this.line2;
		clone.line3 = this.line3;
		clone.line4 = this.line4;
		clone.line5 = this.line5;
		clone.postcode = this.postcode;
		clone.phone = this.phone;
		if(this.county == null)
			clone.county = null;
		else
			clone.county = (ims.ntpf.vo.lookups.County)this.county.clone();
		clone.fax = this.fax;
		if(this.updatedate == null)
			clone.updatedate = null;
		else
			clone.updatedate = (ims.framework.utils.DateTime)this.updatedate.clone();
		if(this.notificationdate == null)
			clone.notificationdate = null;
		else
			clone.notificationdate = (ims.framework.utils.Date)this.notificationdate.clone();
		if(this.addresstype == null)
			clone.addresstype = null;
		else
			clone.addresstype = (ims.core.vo.lookups.AddressType)this.addresstype.clone();
		clone.addresssearchtxt = this.addresssearchtxt;
		clone.pct = this.pct;
		clone.otherphone = this.otherphone;
		clone.lsoa = this.lsoa;
		clone.organisation = this.organisation;
		if(this.areaofresidence == null)
			clone.areaofresidence = null;
		else
			clone.areaofresidence = (ims.ntpf_ptr.vo.lookups.AreaOfResidence)this.areaofresidence.clone();
		clone.pafkey = this.pafkey;
		clone.description = this.description;
		clone.objectidentifier = this.objectidentifier;
		if(this.beffdate == null)
			clone.beffdate = null;
		else
			clone.beffdate = (ims.framework.utils.Date)this.beffdate.clone();
		clone.beffdatecnf = this.beffdatecnf;
		if(this.betdate == null)
			clone.betdate = null;
		else
			clone.betdate = (ims.framework.utils.Date)this.betdate.clone();
		clone.betdatecnf = this.betdatecnf;
		if(this.pdsupdatemode == null)
			clone.pdsupdatemode = null;
		else
			clone.pdsupdatemode = (ims.core.vo.lookups.PDSUpdateMode)this.pdsupdatemode.clone();
		if(this.country == null)
			clone.country = null;
		else
			clone.country = (ims.core.vo.lookups.Country)this.country.clone();
		clone.nofixedabode = this.nofixedabode;
		clone.carehome = this.carehome;
		clone.isValidated = this.isValidated;
		
		this.isBusy = false;
		return clone;
	}
	public int compareTo(Object obj)
	{
		return compareTo(obj, true);
	}
	public int compareTo(Object obj, boolean caseInsensitive)
	{
		if (obj == null)
		{
			return -1;
		}
		if(caseInsensitive); // this is to avoid eclipse warning only.
		if (!(PersonAddress.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A PersonAddress object cannot be compared an Object of type " + obj.getClass().getName());
		}
		PersonAddress compareObj = (PersonAddress)obj;
		int retVal = 0;
		if (retVal == 0)
		{
			if(this.getLine1() == null && compareObj.getLine1() != null)
				return -1;
			if(this.getLine1() != null && compareObj.getLine1() == null)
				return 1;
			if(this.getLine1() != null && compareObj.getLine1() != null)
			{
				if(caseInsensitive)
					retVal = this.getLine1().toLowerCase().compareTo(compareObj.getLine1().toLowerCase());
				else
					retVal = this.getLine1().compareTo(compareObj.getLine1());
			}
		}
		if (retVal == 0)
		{
			if(this.getLine2() == null && compareObj.getLine2() != null)
				return -1;
			if(this.getLine2() != null && compareObj.getLine2() == null)
				return 1;
			if(this.getLine2() != null && compareObj.getLine2() != null)
			{
				if(caseInsensitive)
					retVal = this.getLine2().toLowerCase().compareTo(compareObj.getLine2().toLowerCase());
				else
					retVal = this.getLine2().compareTo(compareObj.getLine2());
			}
		}
		if (retVal == 0)
		{
			if(this.getLine3() == null && compareObj.getLine3() != null)
				return -1;
			if(this.getLine3() != null && compareObj.getLine3() == null)
				return 1;
			if(this.getLine3() != null && compareObj.getLine3() != null)
			{
				if(caseInsensitive)
					retVal = this.getLine3().toLowerCase().compareTo(compareObj.getLine3().toLowerCase());
				else
					retVal = this.getLine3().compareTo(compareObj.getLine3());
			}
		}
		return retVal;
	}
	public synchronized static int generateValueObjectUniqueID()
	{
		return ims.vo.ValueObject.generateUniqueID();
	}
	public int countFieldsWithValue()
	{
		int count = 0;
		if(this.line1 != null)
			count++;
		if(this.line2 != null)
			count++;
		if(this.line3 != null)
			count++;
		if(this.line4 != null)
			count++;
		if(this.line5 != null)
			count++;
		if(this.postcode != null)
			count++;
		if(this.phone != null)
			count++;
		if(this.county != null)
			count++;
		if(this.fax != null)
			count++;
		if(this.updatedate != null)
			count++;
		if(this.notificationdate != null)
			count++;
		if(this.addresstype != null)
			count++;
		if(this.pct != null)
			count++;
		if(this.otherphone != null)
			count++;
		if(this.lsoa != null)
			count++;
		if(this.organisation != null)
			count++;
		if(this.areaofresidence != null)
			count++;
		if(this.pafkey != null)
			count++;
		if(this.description != null)
			count++;
		if(this.objectidentifier != null)
			count++;
		if(this.beffdate != null)
			count++;
		if(this.beffdatecnf != null)
			count++;
		if(this.betdate != null)
			count++;
		if(this.betdatecnf != null)
			count++;
		if(this.pdsupdatemode != null)
			count++;
		if(this.country != null)
			count++;
		if(this.nofixedabode != null)
			count++;
		if(this.carehome != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return 28;
	}
	protected String line1;
	protected String line2;
	protected String line3;
	protected String line4;
	protected String line5;
	protected String postcode;
	protected String phone;
	protected ims.ntpf.vo.lookups.County county;
	protected String fax;
	protected ims.framework.utils.DateTime updatedate;
	protected ims.framework.utils.Date notificationdate;
	protected ims.core.vo.lookups.AddressType addresstype;
	protected String addresssearchtxt;
	protected String pct;
	protected String otherphone;
	protected String lsoa;
	protected String organisation;
	protected ims.ntpf_ptr.vo.lookups.AreaOfResidence areaofresidence;
	protected String pafkey;
	protected String description;
	protected String objectidentifier;
	protected ims.framework.utils.Date beffdate;
	protected Boolean beffdatecnf;
	protected ims.framework.utils.Date betdate;
	protected Boolean betdatecnf;
	protected ims.core.vo.lookups.PDSUpdateMode pdsupdatemode;
	protected ims.core.vo.lookups.Country country;
	protected Boolean nofixedabode;
	protected Boolean carehome;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
