/*******************************************************************************
 *  Copyright 2017 Centre for Development of Advanced Computing(C-DAC), Pune
 *  
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *  
 *    http://www.apache.org/licenses/LICENSE-2.0
 *  
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *******************************************************************************/
package cdac.medinfo.sdk.hl7282.baselibs;

import cdac.medinfo.sdk.hl7282.baselibs.segmentfactory.DataElementFactory;
import cdac.medinfo.sdk.hl7282.commoninterface.IDataType;
import cdac.medinfo.sdk.hl7282.commoninterface.ISingleCollection;
import cdac.medinfo.sdk.hl7282.exceptions.InvalidComponentTypeException;
import cdac.medinfo.sdk.hl7282.utils.EnumDataType;
import cdac.medinfo.sdk.hl7282.utils.IDataTypeMap;

/**
 * XAD - Extended address<p>
 * This data type specifies the  address of a person, 
 * place or organization plus associated information.
 * <p>Represents an HL7 XAD data type. 
 * This data type has the following attributes:</p><p>
 *  1. Street Address (SAD)<b>Optional</b><br>
 *  2. Other Designation (ST)<b>Optional</b><br>
 *  3. City (ST)<b>Optional</b><br>
 *  4. State or Province (ST)<b>Optional</b><br>
 *  5. Zip or Postal Code (ST)<b>Optional</b><br>
 *  6. Country (ID)<b>Optional</b><br>
 *  7. Address Type (ID)<b>Conditional</b><br>
 *  8. Other Geographic Designation (ST)<b>Optional</b><br>
 *  9. County/Parish Code (CWE)<b>Optional</b><br>
 * 10. Census Tract (CWE)<b>Optional</b><br>
 * 11. Address Representation Code (ID)<b>Optional</b><br>
 * 
 * 13. Effective Date (DTM)<b>Optional</b><br>
 * 14. Expiration Date (DTM)<b>Optional</b><br><p>
 * 15. Expiration Reason (CWE)<b>Optional</b><br><p>
 * 16. Temporary Indicator (ID)<b>Optional</b><br><p>
 * 17. Bad Address Indicator (ID)<b>Optional</b><br><p>
 * 18. Address Usage (ID)<b>Optional</b><br><p>
 * 19. Addressee (ST)<b>Optional</b><br><p>
 * 20. Comment (ST)<b>Optional</b><br><p>
 * 21. Preference Order (NM)<b>Optional</b><br><p>
 * 22. Protection Code (CWE)<b>Optional</b><br><p>
 * 23. Address Identifier (EI)<b>Optional</b><br><p>
 * This class provides accessors & mutators for the elements mentioned above.
 * This class override the equal method, to check whether some other object is "equal to" this one.
 * 
 * <p>User can also create Data Type through {@link DataElementFactory} 
 */
public class XAD extends CompositeDataType    
{
	


	/**
	 * Default Constructor for XAD
	 */
	public XAD()
	{
		super(EnumDataType.HL7_DT_XAD);
		 
	}

	/**
	 * Constructor  for XAD class which takes four arguments and 
	 * sets the value in the respective member variable.
	 * @param iMinLength The Minimum length the DataType can have.
	 * @param iMaxLength The Maximum length the DataType can have.
	 * @param iCLength The Conformance length the DataType can have.
	 * @param iComponentType The Type of the component i.e Component or a subcomponent.
	 * @throws InvalidComponentTypeException - if Component Type is not specified or valid. 
	 */ 
	public XAD(int iMinLength, int iMaxLength, String strCLength,int iComponentType) throws InvalidComponentTypeException
	{
		super(EnumDataType.HL7_DT_XAD);
		this.iMinLength = iMinLength;
		this.iMaxLength = iMaxLength;
		this.iConformanceLength = strCLength;
		this.iComponentType = iComponentType;
		if(!isValidComponentType())
		{
			throw new InvalidComponentTypeException(this.getClass().getSimpleName());
		}
	}


	/**
	 * Constructor for XAD class which takes five arguments and 
	 * sets the value in the respective member variable.
	 * @param iMinLength The Minimum length the DataType can have.
	 * @param iMaxLength The Maximum length the DataType can have.
	 * @param iCLength The Conformance length the DataType can have.
	 * @param iTableNo The Table number to which the value for the component is specified. 
	 * @param iComponentType The Type of the component i.e Component or a subcomponent.
	 * @throws InvalidComponentTypeException - if Component Type is not specified or valid. 
	 */
	public XAD(int iMinLength, int iMaxLength, String strCLength,int iTableNo,int iComponentType) throws InvalidComponentTypeException
	{
		super(EnumDataType.HL7_DT_XAD);
		this.iMinLength = iMinLength;
		this.iMaxLength = iMaxLength;
		this.iConformanceLength = strCLength;
		this.iTableNo = iTableNo;
		this.iComponentType = iComponentType;
		if(!isValidComponentType())
		{
			throw new InvalidComponentTypeException(this.getClass().getSimpleName());		
		}
	}
	/**
	 * Constructor for XAD class which takes two arguments and 
	 * sets the value in the respective member variable.
	 * @param objIDataTypeMap object of Data Type Map.
	 * @param iComponentType The Type of the component i.e Component or a subcomponent.
	 * @throws InvalidComponentTypeException - if Component Type is not specified or valid. 
	 */
	public XAD(int iComponentType,IDataTypeMap objIDataTypeMap)
	{
		super(EnumDataType.HL7_DT_XAD);
		this.objIDataTypeMap = objIDataTypeMap;
		this.iComponentType = iComponentType;
		if(!isValidComponentType())
		{
			throw new InvalidComponentTypeException(this.getClass().getSimpleName());
		}
	}
	/**
	 * Constructor for XAD class which takes five arguments and 
	 * sets the value in the respective member variable.
	 * @param objIDataTypeMap object of Data Type Map.
	 * @param iComponentType The Type of the component i.e Component or a subcomponent.
	 * @param iMinLength The Minimum length the DataType can have.
	 * @param iMaxLength The Maximum length the DataType can have.
	 * @param iCLength The Conformance length the DataType can have.
	 * @throws InvalidComponentTypeException - if Component Type is not specified or valid. 
	 */
	public XAD(int iComponentType,int iMinLength, int iMaxLength, String strCLength,IDataTypeMap objIDataTypeMap)
	{
		super(EnumDataType.HL7_DT_XAD);
		this.objIDataTypeMap = objIDataTypeMap;
		this.iComponentType = iComponentType;
		this.iMinLength = iMinLength;
		this.iMaxLength = iMaxLength;
		this.iConformanceLength = strCLength;

		if(!isValidComponentType())
		{
			throw new InvalidComponentTypeException(this.getClass().getSimpleName());
		}
	}
	/**
	 * Constructor for XAD class which takes six arguments and 
	 * sets the value in the respective member variable.
	 * @param objIDataTypeMap object of Data Type Map.
	 * @param iComponentType The Type of the component i.e Component or a subcomponent.
	 * @param iMinLength The Minimum length the DataType can have.
	 * @param iMaxLength The Maximum length the DataType can have.
	 * @param iCLength The Conformance length the DataType can have.
	 * @param iTableNo The Table number to which the value for the component is specified. 
	 * @throws InvalidComponentTypeException - if Component Type is not specified or valid. 
	 */
	public XAD(int iComponentType,int iMinLength, int iMaxLength, String strCLength,int ITableNo,IDataTypeMap objIDataTypeMap)
	{
		super(EnumDataType.HL7_DT_XAD);
		this.objIDataTypeMap = objIDataTypeMap;
		this.iComponentType = iComponentType;
		this.iTableNo = ITableNo;
		this.iMinLength = iMinLength;
		this.iMaxLength = iMaxLength;
		this.iConformanceLength = strCLength;

		if(!isValidComponentType())
		{
			throw new InvalidComponentTypeException(this.getClass().getSimpleName());
		}
	}


	/**
	 * Sets the StreetAddress.
	 * @param objStreetAddress specifies the street address.
	 */
	public void setStreetAddress(SAD objStreetAddress)
	{
		setComponentType(1,objStreetAddress);
	}

	/**
	 *Sets the OtherDesignation.
	 *@param strOtherDesignation specifies the Second line of address.  
	 */
	public void setOtherDesignation(String strOtherDesignation)
	{
		if(strOtherDesignation!=null)
			setComponentType(2, strOtherDesignation);
		else
			setOtherDesignation((ST)null);
	}

	/**
	 *Sets the OtherDesignation.
	 *@param objST specifies the Second line of address. 
	 */
	public void setOtherDesignation(ST objST)
	{
		setComponentType(2,objST);
	}

	/**
	 *Sets the City.
	 *@param strCity the city, or district or place where the addressee is located.  
	 */
	public void setCity(String strCity)
	{
		if(strCity!=null)
			setComponentType(3, strCity);
		else
			setCity((ST)null);
	}

	/**
	 *Sets the City.
	 *@param objST the city, or district or place where the addressee is located. 
	 */
	public void setCity(ST objST)
	{
		setComponentType(3,objST);
	}

	/**
	 *Sets the StateOrProvince.
	 *@param strStateOrProvince specifies the state or province where the addressee is located. 
	 */
	public void setStateOrProvince(String strStateOrProvince)
	{
		if(strStateOrProvince!=null)
			setComponentType(4, strStateOrProvince);
		else
			setStateOrProvince((ST)null);
	}

	/**
	 *Sets the StateOrProvince.
	 *@param objST specifies the state or province where the addressee is located.
	 */
	public void setStateOrProvince(ST objST)
	{
		setComponentType(4,objST);
	}

	/**
	 *Sets the ZipOrPostalCode.
	 *@param strZipOrPostalCode specifies the zip or postal code where the addressee is located.  
	 */
	public void setZipOrPostalCode(String strZipOrPostalCode)
	{
		if(strZipOrPostalCode!=null)
			setComponentType(5, strZipOrPostalCode);
		else
			setZipOrPostalCode((ST)null);
	}

	/**
	 *Sets the ZipOrPostalCode.
	 *@param objST specifies the zip or postal code where the addressee is located. 
	 */
	public void setZipOrPostalCode(ST objST)
	{
		setComponentType(5,objST);
	}

	/**
	 *Sets the Country.
	 *@param strCountry specifies the country where the addressee is located. 
	 */
	public void setCountry(String strCountry)
	{
		if(strCountry!=null)
			setComponentType(6, strCountry);
		else
			setCountry((ID)null);
	}

	/**
	 *Sets the Country.
	 *@param objID specifies the country where the addressee is located.
	 */
	public void setCountry(ID objID)
	{
		setComponentType(6,objID);
	}

	/**
	 *Sets the AddressType.
	 *@param strAddressType specifies the kind or type of address. 
	 */
	public void setAddressType(String strAddressType)
	{
		if(strAddressType!=null)
			setComponentType(7, strAddressType);
		else
			setAddressType((ID)null);
	}

	/**
	 *Sets the AddressType.
	 *@param objID specifies the kind or type of address.
	 */
	public void setAddressType(ID objID)
	{
		setComponentType(7,objID);
	}

	/**
	 *Sets the OtherGeographicDesignation.
	 *@param strOtherGeographicDesignation specifies any other geographic designation.  
	 */
	public void setOtherGeographicDesignation(String strOtherGeographicDesignation)
	{
		if(strOtherGeographicDesignation!=null)
			setComponentType(8, strOtherGeographicDesignation);
		else
			setOtherGeographicDesignation((ST)null);
	}

	/**
	 *Sets the OtherGeographicDesignation.
	 *@param objST specifies any other geographic designation. 
	 */
	public void setOtherGeographicDesignation(ST objST)
	{
		setComponentType(8,objST);
	}
	
	/**
	 *Sets the CountyParishCode.
	 *@param strCountyParishCode specifies a code that represents the county in which the specified address resides.  
	 */
	public void setCountyParishCode(String strCountyParishCode)
	{
		if(strCountyParishCode!=null)
			setComponentType(9, strCountyParishCode);
		else
			setCountyParishCode((CWE)null);
	}

	/**
	 *Sets the CountyParishCode.
	 *@param objCWE specifies a code that represents the county in which the specified address resides. 
	 */
	public void setCountyParishCode(CWE objCWE)
	{
		setComponentType(9,objCWE);
	}
	
	/**
	 *Sets the CensusTract.
	 *@param strCensusTract specifies a code that represents the census tract in which the specified address resides.  
	 */
	public void setCensusTract(String strCensusTract)
	{
		if(strCensusTract!=null)
			setComponentType(10, strCensusTract);
		else
			setCensusTract((CWE)null);
	}

	/**
	 *Sets the CensusTract.
	 *@param objCWE specifies a code that represents the census tract in which the specified address resides. 
	 */
	public void setCensusTract(CWE objCWE)
	{
		setComponentType(10,objCWE);
	}

	/**
	 *Sets the AddressRepresentationCode.
	 *@param strAddrRepresentationCode specifies representations of the same name/address Suggested values are I,A,P [Refer table 0465] 
	 */
	public void setAddressRepresentationCode(String strAddrRepresentationCode)
	{
		if(strAddrRepresentationCode!=null)
			setComponentType(11, strAddrRepresentationCode);
		else
			setAddressRepresentationCode((ID)null);
	}

	/**
	 *Sets the AddressRepresentationCode.
	 *@param objID specifies representations of the same name/address Suggested values are I,A,P [Refer table 0465]
	 */
	public void setAddressRepresentationCode(ID objID)
	{
		setComponentType(11,objID);
	}
	
	/**
	 * Sets the EffectiveDate.
	 * @param strTime specifies The first date, if known, on which the address is valid and active.
	 */
	public void setEffectiveDate(String strEffectiveDate)
	{
		if(strEffectiveDate!=null)
			setComponentType(13, strEffectiveDate);
		else
			setEffectiveDate((DTM)null);
	}

	/**
	 * Sets the EffectiveDate.
	 * @param objEffectiveDate It is The first date, if known, on which the address is valid and active.
	 */
	public void setEffectiveDate(DTM objEffectiveDate)
	{
		setComponentType(13,objEffectiveDate);
	}
	
	/**
	 * Sets the ExpirationDate.
	 * @param strTime specifies The last date, if known, on which the address is valid and active.
	 */
	public void setExpirationDate(String strExpirationDate)
	{
		if(strExpirationDate!=null)
			setComponentType(14, strExpirationDate);
		else
			setExpirationDate((DTM)null);
	}

	/**
	 * Sets the ExpirationDate.
	 * @param objExpirationDate It is The last date, if known, on which the address is valid and active.
	 */
	public void setExpirationDate(DTM objExpirationDate)
	{
		setComponentType(14,objExpirationDate);
	}
	
	/**
	 *Sets the Expiration Reason.
	 *@param objCWE specifies why this address was marked as "ended".
	 */
	public void setExpirationReason(CWE objCWE)
	{
		setComponentType(15,objCWE);
	}
	
	/**
	 *Sets the Temporary Indicator.
	 *@param strTemporaryIndicator indicates that the address is considered temporary.
	 */
	public void setTemporaryIndicator(String strTemporaryIndicator)
	{
		if(strTemporaryIndicator!=null)
			setComponentType(16, strTemporaryIndicator);
		else
			setTemporaryIndicator((ID)null);
	}

	/**
	 *Sets the Temporary Indicator.
	 *@param objID indicates that the address is considered temporary.
	 */
	public void setTemporaryIndicator(ID objID)
	{
		setComponentType(16,objID);
	}
	
	/**
	 *Sets the Bad Address Indicator.
	 *@param strBadAddressIndicator indicates that it is not possible to contact the "owning" entity at this address.
	 */
	public void setBadAddressIndicator(String strBadAddressIndicator)
	{
		if(strBadAddressIndicator!=null)
			setComponentType(17, strBadAddressIndicator);
		else
			setBadAddressIndicator((ID)null);
	}

	/**
	 *Sets the Bad Address Indicator.
	 *@param objID indicates that it is not possible to contact the "owning" entity at this address.
	 */
	public void setBadAddressIndicator(ID objID)
	{
		setComponentType(17,objID);
	}
	
	/**
	 *Sets the Address Usage.
	 *@param strAddressUsage indicates how the address is intended to be used.
	 */
	public void setAddressUsage(String strAddressUsage)
	{
		if(strAddressUsage!=null)
			setComponentType(18, strAddressUsage);
		else
			setAddressUsage((ID)null);
	}

	/**
	 *Sets the Address Usage.
	 *@param objID indicates how the address is intended to be used.
	 */
	public void setAddressUsage(ID objID)
	{
		setComponentType(18,objID);
	}
	
	/**
	 *Sets the  Addressee .
	 *@param strAddressee  Identifies the name of the person or organization.  
	 */
	public void setAddressee (String strAddressee )
	{
		if(strAddressee !=null)
			setComponentType(19, strAddressee );
		else
			setAddressee ((ST)null);
	}

	/**
	 *Sets the  Addressee .
	 *@param objST Identifies the name of the person or organization.  
	 */
	public void setAddressee (ST objST)
	{
		setComponentType(19,objST);
	}
	
	/**
	 *Sets the  Comment .
	 *@param strComment specifies Descriptive information about the use of the address.
	 */
	public void setComment (String strComment )
	{
		if(strComment !=null)
			setComponentType(20, strComment );
		else
			setComment ((ST)null);
	}

	/**
	 *Sets the  Comment .
	 *@param objST specifies Descriptive information about the use of the address.
	 */
	public void setComment (ST objST)
	{
		setComponentType(20,objST);
	}
	
	/**
	 *Sets the  Preference Order .
	 *@param strPreferenceOrder indicates which is the 'most preferred' (lowest number) to 'least preferred' (highest number).
	 */
	public void setPreferenceOrder (String strPreferenceOrder )
	{
		if(strPreferenceOrder !=null)
			setComponentType(21, strPreferenceOrder );
		else
			setPreferenceOrder ((NM)null);
	}

	/**
	 *Sets the  Preference Order .
	 *@param objNM indicates which is the 'most preferred' (lowest number) to 'least preferred' (highest number).
	 */
	public void setPreferenceOrder (NM objNM)
	{
		setComponentType(21,objNM);
	}
	
	/**
	 *Sets the  Preference Code .
	 *@param objCWE Identifies that an address needs to be treated with special care or sensitivity.
	 */
	public void setProtectionCode (CWE objCWE)
	{
		setComponentType(22,objCWE);
	}
	
	/**
	 *Sets the  Address Identifier .
	 *@param objEI Identifies A unique identifier for the address.
	 */
	public void setAddressIdentifier(EI objEI)
	{
		setComponentType(23,objEI);
	}

	/**
	 * Returns Street Address
	 * @return SAD - data type.
	 */
	public SAD getStreetAddress()
	{
		ISingleCollection<IDataType> objDataCollection =getComponentType(1);
		if(objDataCollection != null && objDataCollection.size() != 0) 
			return (SAD)objDataCollection.elementAt(0);
		else
			return null;
	}

	/**
	 * Returns Other Designation
	 * @return ST - data type.
	 */
	public ST getOtherDesignation()
	{
		ISingleCollection<IDataType> objDataCollection =getComponentType(2);
		if(objDataCollection != null && objDataCollection.size() != 0) 
			return (ST)objDataCollection.elementAt(0);
		else
			return null;
	}

	/**
	 * Returns City
	 * @return ST - data type.
	 */
	public ST getCity()
	{
		ISingleCollection<IDataType> objDataCollection =getComponentType(3);
		if(objDataCollection != null && objDataCollection.size() != 0) 
			return (ST)objDataCollection.elementAt(0);
		else
			return null;
	}

	/**
	 * Returns State or Province
	 * @return ST - data type.
	 */
	public ST getStateOrProvince()
	{
		ISingleCollection<IDataType> objDataCollection =getComponentType(4);
		if(objDataCollection != null && objDataCollection.size() != 0) 
			return (ST)objDataCollection.elementAt(0);
		else
			return null;
	}

	/**
	 * Returns Zip or Postal Code
	 * @return ST - data type.
	 */
	public ST getZipOrPostalCode()
	{
		ISingleCollection<IDataType> objDataCollection =getComponentType(5);
		if(objDataCollection != null && objDataCollection.size() != 0) 
			return (ST)objDataCollection.elementAt(0);
		else
			return null;
	}

	/**
	 * Returns Country
	 * @return ID - data type.
	 */
	public ID getCountry()
	{
		ISingleCollection<IDataType> objDataCollection =getComponentType(6);
		if(objDataCollection != null && objDataCollection.size() != 0) 
			return (ID)objDataCollection.elementAt(0);
		else
			return null;
	}

	/**
	 * Returns Address Type
	 * @return ID - data type.
	 */
	public ID getAddressType()
	{
		ISingleCollection<IDataType> objDataCollection =getComponentType(7);
		if(objDataCollection != null && objDataCollection.size() != 0) 
			return (ID)objDataCollection.elementAt(0);
		else
			return null;
	}

	/**
	 * Returns Other Geographic Designation
	 * @return ST - data type.
	 */
	public ST getOtherGeographicDesignation()
	{
		ISingleCollection<IDataType> objDataCollection =getComponentType(8);
		if(objDataCollection != null && objDataCollection.size() != 0) 
			return (ST)objDataCollection.elementAt(0);
		else
			return null;
	}

	/**
	 * Returns County/Parish Code
	 * @return CWE - data type.
	 */
	public CWE getCountyParishCode()
	{
		ISingleCollection<IDataType> objDataCollection =getComponentType(9);
		if(objDataCollection != null && objDataCollection.size() != 0) 
			return (CWE)objDataCollection.elementAt(0);
		else
			return null;
	}

	/**
	 * Returns Census Tract
	 * @return CWE - data type.
	 */
	public CWE getCensusTract()
	{
		ISingleCollection<IDataType> objDataCollection =getComponentType(10);
		if(objDataCollection != null && objDataCollection.size() != 0) 
			return (CWE)objDataCollection.elementAt(0);
		else
			return null;
	}

	/**
	 * Returns Address Representation Code
	 * @return ID - data type.
	 */
	public ID getAddressRepresentationCode()
	{
		ISingleCollection<IDataType> objDataCollection =getComponentType(11);
		if(objDataCollection != null && objDataCollection.size() != 0) 
			return (ID)objDataCollection.elementAt(0);
		else
			return null;
	}

	/**
	 * Returns Effective Date
	 * @return DTM - data type.
	 */
	public DTM getEffectiveDate()
	{
		ISingleCollection<IDataType> objDataCollection =getComponentType(13);
		if(objDataCollection != null && objDataCollection.size() != 0) 
			return (DTM)objDataCollection.elementAt(0);
		else
			return null;
	}

	/**
	 * Returns Expiration Date
	 * @return DTM - data type.
	 */
	public DTM getExpirationDate()
	{
		ISingleCollection<IDataType> objDataCollection =getComponentType(14);
		if(objDataCollection != null && objDataCollection.size() != 0) 
			return (DTM)objDataCollection.elementAt(0);
		else
			return null;
	}
	
	/**
	 * Returns Expiration Reason
	 * @return CWE - data type.
	 */
	public CWE getExpirationReason()
	{
		ISingleCollection<IDataType> objDataCollection =getComponentType(15);
		if(objDataCollection != null && objDataCollection.size() != 0) 
			return (CWE)objDataCollection.elementAt(0);
		else
			return null;
	}
	
	/**
	 * Returns Temporary Indicator
	 * @return ID - data type.
	 */
	public ID getTemporaryIndicator()
	{
		ISingleCollection<IDataType> objDataCollection =getComponentType(16);
		if(objDataCollection != null && objDataCollection.size() != 0) 
			return (ID)objDataCollection.elementAt(0);
		else
			return null;
	}
	
	/**
	 * Returns Bad Address Indicator
	 * @return ID - data type.
	 */
	public ID getBadAddressIndicator()
	{
		ISingleCollection<IDataType> objDataCollection =getComponentType(17);
		if(objDataCollection != null && objDataCollection.size() != 0) 
			return (ID)objDataCollection.elementAt(0);
		else
			return null;
	}
	
	/**
	 * Returns Address UsagE
	 * @return ID - data type.
	 */
	public ID getAddressUsage()
	{
		ISingleCollection<IDataType> objDataCollection =getComponentType(18);
		if(objDataCollection != null && objDataCollection.size() != 0) 
			return (ID)objDataCollection.elementAt(0);
		else
			return null;
	}
	
	/**
	 * Returns Addressee
	 * @return ST - data type.
	 */
	public ST getAddressee()
	{
		ISingleCollection<IDataType> objDataCollection =getComponentType(19);
		if(objDataCollection != null && objDataCollection.size() != 0) 
			return (ST)objDataCollection.elementAt(0);
		else
			return null;
	}
	
	/**
	 * Returns Comment
	 * @return st - data type.
	 */
	public ST getComment()
	{
		ISingleCollection<IDataType> objDataCollection =getComponentType(20);
		if(objDataCollection != null && objDataCollection.size() != 0) 
			return (ST)objDataCollection.elementAt(0);
		else
			return null;
	}
	
	/**
	 * Returns Preference Order
	 * @return NM - data type.
	 */
	public NM getPreferenceOrder()
	{
		ISingleCollection<IDataType> objDataCollection =getComponentType(21);
		if(objDataCollection != null && objDataCollection.size() != 0) 
			return (NM)objDataCollection.elementAt(0);
		else
			return null;
	}
	
	/**
	 * Returns Protection Code
	 * @return CWE - data type.
	 */
	public CWE getProtectionCode()
	{
		ISingleCollection<IDataType> objDataCollection =getComponentType(22);
		if(objDataCollection != null && objDataCollection.size() != 0) 
			return (CWE)objDataCollection.elementAt(0);
		else
			return null;
	}
	
	/**
	 * Returns Address Identifier 
	 * @return EI - data type.
	 */
	public EI getAddressIdentifier ()
	{
		ISingleCollection<IDataType> objDataCollection =getComponentType(23);
		if(objDataCollection != null && objDataCollection.size() != 0) 
			return (EI)objDataCollection.elementAt(0);
		else
			return null;
	}

	/**
	 * This method checks the equality of Object.
	 * @param objObject object of Object class.
	 * @return boolean - shows success or failure of the comparison.
	 */
	public boolean equals(Object objObject)
	{
		if((objObject == null ) || (!(objObject instanceof XAD)))
			return false;

		if(this.getStreetAddress() == null)
		{
			if(((XAD)objObject).getStreetAddress() != null)
				return false;
		}
		else if(false == (this.getStreetAddress().equals(((XAD)objObject).getStreetAddress())))
			return false;

		if(this.getOtherDesignation() == null)
		{
			if(((XAD)objObject).getOtherDesignation() != null)
				return false;
		}
		else if(false == (this.getOtherDesignation().equals(((XAD)objObject).getOtherDesignation())))
			return false;

		if(this.getCity() == null)
		{
			if(((XAD)objObject).getCity() != null)
				return false;
		}
		else if(false == (this.getCity().equals(((XAD)objObject).getCity())))
			return false;

		if(this.getStateOrProvince() == null)
		{
			if(((XAD)objObject).getStateOrProvince() != null)
				return false;
		}
		else if(false == (this.getStateOrProvince().equals(((XAD)objObject).getStateOrProvince())))
			return false;

		if(this.getZipOrPostalCode() == null)
		{
			if(((XAD)objObject).getZipOrPostalCode() != null)
				return false;
		}
		else if(false == (this.getZipOrPostalCode().equals(((XAD)objObject).getZipOrPostalCode())))
			return false;

		if(this.getCountry() == null)
		{
			if(((XAD)objObject).getCountry() != null)
				return false;
		}
		else if(false == (this.getCountry().equals(((XAD)objObject).getCountry())))
			return false;

		if(this.getAddressType() == null)
		{
			if(((XAD)objObject).getAddressType() != null)
				return false;
		}
		else if(false == (this.getAddressType().equals(((XAD)objObject).getAddressType())))
			return false;

		if(this.getOtherGeographicDesignation() == null)
		{
			if(((XAD)objObject).getOtherGeographicDesignation() != null)
				return false;
		}
		else if(false == (this.getOtherGeographicDesignation().equals(((XAD)objObject).getOtherGeographicDesignation())))
			return false;

		if(this.getCountyParishCode() == null)
		{
			if(((XAD)objObject).getCountyParishCode() != null)
				return false;
		}
		else if(false == (this.getCountyParishCode().equals(((XAD)objObject).getCountyParishCode())))
			return false;

		if(this.getCensusTract() == null)
		{
			if(((XAD)objObject).getCensusTract() != null)
				return false;
		}
		else if(false == (this.getCensusTract().equals(((XAD)objObject).getCensusTract())))
			return false;

		if(this.getAddressRepresentationCode() == null)
		{
			if(((XAD)objObject).getAddressRepresentationCode() != null)
				return false;
		}
		else if(false == (this.getAddressRepresentationCode().equals(((XAD)objObject).getAddressRepresentationCode())))
			return false;

		if(this.getEffectiveDate() == null)
		{
			if(((XAD)objObject).getEffectiveDate() != null)
				return false;
		}
		else if(false == (this.getEffectiveDate().equals(((XAD)objObject).getEffectiveDate())))
			return false;

		if(this.getExpirationDate() == null)
		{
			if(((XAD)objObject).getExpirationDate() != null)
				return false;
		}
		else if(false == (this.getExpirationDate().equals(((XAD)objObject).getExpirationDate())))
			return false;
		
		if(this.getExpirationReason() == null)
		{
			if(((XAD)objObject).getExpirationReason() != null)
				return false;
		}
		else if(false == (this.getExpirationReason().equals(((XAD)objObject).getExpirationReason())))
			return false;
		
		if(this.getTemporaryIndicator() == null)
		{
			if(((XAD)objObject).getTemporaryIndicator() != null)
				return false;
		}
		else if(false == (this.getTemporaryIndicator().equals(((XAD)objObject).getTemporaryIndicator())))
			return false;
		
		if(this.getBadAddressIndicator() == null)
		{
			if(((XAD)objObject).getBadAddressIndicator() != null)
				return false;
		}
		else if(false == (this.getBadAddressIndicator().equals(((XAD)objObject).getBadAddressIndicator())))
			return false;
		
		if(this.getAddressUsage() == null)
		{
			if(((XAD)objObject).getAddressUsage() != null)
				return false;
		}
		else if(false == (this.getAddressUsage().equals(((XAD)objObject).getAddressUsage())))
			return false;
		
		if(this.getAddressee() == null)
		{
			if(((XAD)objObject).getAddressee() != null)
				return false;
		}
		else if(false == (this.getAddressee().equals(((XAD)objObject).getAddressee())))
			return false;
		
		if(this.getComment() == null)
		{
			if(((XAD)objObject).getComment() != null)
				return false;
		}
		else if(false == (this.getComment().equals(((XAD)objObject).getComment())))
			return false;
		
		if(this.getPreferenceOrder() == null)
		{
			if(((XAD)objObject).getPreferenceOrder() != null)
				return false;
		}
		else if(false == (this.getPreferenceOrder().equals(((XAD)objObject).getPreferenceOrder())))
			return false;

		if(this.getProtectionCode() == null)
		{
			if(((XAD)objObject).getProtectionCode() != null)
				return false;
		}
		else if(false == (this.getProtectionCode().equals(((XAD)objObject).getProtectionCode())))
			return false;
		
		if(this.getAddressIdentifier() == null)
		{
			if(((XAD)objObject).getAddressIdentifier() != null)
				return false;
		}
		else if(false == (this.getAddressIdentifier().equals(((XAD)objObject).getAddressIdentifier())))
			return false;

		return true;
	}
}
