/*******************************************************************************
 *  Copyright 2017-2018 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.dcm30_04.baselibs;

import cdac.medinfo.sdk.dcm30_04.commoninterface.IDataElement;
import cdac.medinfo.sdk.dcm30_04.commoninterface.IDicomValue;
import cdac.medinfo.sdk.dcm30_04.commoninterface.IDictionaryReader;
import cdac.medinfo.sdk.dcm30_04.commoninterface.ITransferSyntax;
import cdac.medinfo.sdk.dcm30_04.exceptions.ConditionFailedException;
import cdac.medinfo.sdk.dcm30_04.exceptions.InvalidItemException;
import cdac.medinfo.sdk.dcm30_04.exceptions.MandatoryMissingException;
import cdac.medinfo.sdk.dcm30_04.exceptions.ValidationException;
import cdac.medinfo.sdk.dcm30_04.utils.DicomConfig;
import cdac.medinfo.sdk.dcm30_04.utils.DicomConstants;
import cdac.medinfo.sdk.dcm30_04.utils.DicomLogger;
import cdac.medinfo.sdk.dcm30_04.utils.ISingleCollection;
/**
* This item class contains the methods to set, get and validate the attribute present in Optical Path Sequence .
 */

public class OpticalPathSequenceItem extends Item
{
	private static final long serialVersionUID = 1L;

	/**
	 * This constructor creates the item with default TransferSyntax 
	 */
	OpticalPathSequenceItem()
	{
		super();
	}

	/*
	 * This constructor calls the respective superclass constructor
	 * This constructor should throw exception if null TS is tried to be set
	 */
	/**
	 * This constructor creates the item with specified TransferSyntax 
	 * and default DictionaryReader
	 * @param objITransferSyntax specifies the DICOM Standard defined TransfeSyntax
	 */
	OpticalPathSequenceItem(ITransferSyntax objITransferSyntax)
	{
		super(objITransferSyntax);
	}

	/**
	 * This constructor creates OpticalPathSequenceItem with specified TransferSyntax and
	 * specified DictionaryReader.
	 * @param objTransferSyntax specifies the DICOM Standard defined TransfeSyntax.
	 * @param objDictionaryReader specifies the DICOM Dictionary reader to be used.
	 */
	OpticalPathSequenceItem(ITransferSyntax objTransferSyntax, IDictionaryReader objDictionaryReader)
	{
		super(objTransferSyntax,objDictionaryReader);
	}

	/*
	 * (non-Javadoc) This method validates the contents of the Item
	 * @see cdac.medinfo.sdk.dcm30_04.commoninterface.IItem#validate()
	 */
	/**
	 * Validates all the attributes in OpticalPathSequenceItem that are present in the DataSet
	 * @return boolean - Success -true, Failure - false
	 * @throws InvalidItemException throws InvalidItemException If Mandatory or Conditional element fails.
	 */
	public boolean validateForModule()  throws InvalidItemException
	{
		try{
			if(!contains(0x0048,0x0106))
				throw new MandatoryMissingException("0048,0106");
			if(!contains(0x0048,0x0108))
				throw new ConditionFailedException("0048,0108");
			if(!contains(0x0022,0x0055))
				throw new ConditionFailedException("0022,0055");
			if(!contains(0x0022,0x0016))
				throw new MandatoryMissingException("0022,0016");
			if(!contains(0x0022,0x001A))
				throw new MandatoryMissingException("0022,001A");
			if(!contains(0x0028,0x2000))
				throw new MandatoryMissingException("0028,2000");
		}
		catch(MandatoryMissingException me)
		{
			if(DicomConfig.createInstance().isLoggingOn())
			{
				DicomLogger.getLogger().log(me.getMessage());
			}
			throw new ValidationException(this.getClass().getSimpleName(),me);
		}
		catch( ConditionFailedException me)
		{
			if(DicomConfig.createInstance().isLoggingOn())
			{
				DicomLogger.getLogger().log(me.getMessage());
			}
			throw new ValidationException(this.getClass().getSimpleName(),me);
		}
		return true;
	}
	/**
	 * Sets the uniquely identified path described in the Optical PathSequence (0048,0105) by reference to an Item with the sameOptical Path Identifier (0048,0106) value..
	 * @param strOpticalPathIdentifier
	 */
	public void setOpticalPathIdentifier(String strOpticalPathIdentifier)
	{
		/*Accept the OpticalPathIdentifier in String format of type SH.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */
		IDataElement objIDataElement = null;
		if(objITransferSyntax.getVRTransferSyntax() == DicomConstants.DCM_VR_IMPLICIT)
			objIDataElement = new ImplicitDE(0x0048, 0x0106, strOpticalPathIdentifier,objIDictionaryReader);
		else
			objIDataElement = new ExplicitDE(0x0048, 0x0106,DicomConstants.DCM_DT_SH, strOpticalPathIdentifier);

		addDataElement(objIDataElement);
	}

	/**
	 * Retrieves OpticalPathIdentifier.
	 * @return String - value of Optical Path Identifier.
	 */
	public String getOpticalPathIdentifier()
	{
		Object objValue = getValue(0x0048, 0x0106);
		if(objValue != null)
			return objValue.toString();
		return null;
	}
	/**
	 * Sets OpticalPathDescription.
	 * @param strOpticalPathDescription String value of Optical Path Description.
	 */
	public void setOpticalPathDescription(String strOpticalPathDescription)
	{
		/*Accept the Optical Path Description in String format of type ST.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */
		IDataElement objIDataElement = null;
		if(objITransferSyntax.getVRTransferSyntax() == DicomConstants.DCM_VR_IMPLICIT)	
			objIDataElement = new ImplicitDE(0x0048, 0x0107, strOpticalPathDescription,getDictionaryReader());
		else
			objIDataElement = new ExplicitDE(0x0048, 0x0107,DicomConstants.DCM_DT_ST, strOpticalPathDescription);

		addDataElement(objIDataElement);
	}
	/**
	 * Retrieves Optical Path Description.
	 * @return String - value of Optical Path Description.
	 */
	public String getOpticalPathDescription()
	{
		Object objValue = getValue(0x0048, 0x0107);
		if(objValue != null)
			return objValue.toString();
		return null;
	}
	/**
	 * Retrieves pre-initialized object of Illumination Color Code Sequence.If the module contains the sequence object
	 * it returns the same otherwise it creates the sequence adds to the module with proper initialization
	 * and then returns the object of sequence.
	 * @return IlluminationColorCodeSequence - instance of Illumination Color Code Sequence. 
	 */
	public IlluminationColorCodeSequence getIlluminationColorCodeSequence()
	{
		IlluminationColorCodeSequence objIlluminationColorCodeSequence = null;
		IDataElement objIDataElement =  getDataForTag(0x0048, 0x0108);
		if(objIDataElement != null)
		{
			IDicomValue objIDicomValue = objIDataElement.getDicomValue();
			if(objIDicomValue != null)
				objIlluminationColorCodeSequence = (IlluminationColorCodeSequence)objIDicomValue;
		}
		else
		{
			DicomV3Factory objDicomV3Factory = DicomV3Factory.createInstance();
			int iVRTransferSyntax = objITransferSyntax.getVRTransferSyntax();
			objIDataElement = null;
			objIlluminationColorCodeSequence = (IlluminationColorCodeSequence)objDicomV3Factory.createSequence(0x0048, 0x0108, objITransferSyntax, objIDictionaryReader);

			if(iVRTransferSyntax == DicomConstants.DCM_VR_IMPLICIT)
				objIDataElement = new ImplicitDE(0x0048, 0x0108, objIlluminationColorCodeSequence.getValue(),objIDictionaryReader);
			else
				objIDataElement = new ExplicitDE(0x0048, 0x0108, DicomConstants.DCM_DT_SQ, objIlluminationColorCodeSequence.getValue());
			objIDataElement.setTransferSyntax(objITransferSyntax);
			if(objIDataElement != null)
				addDataElement(objIDataElement);
		}
		return objIlluminationColorCodeSequence;
	}
	/**
	 * Retrieves pre-initialized object of Illumination Type Code Sequence.If the module contains the sequence object
	 * it returns the same otherwise it creates the sequence adds to the module with proper initialization
	 * and then returns the object of sequence.
	 * @return IlluminationColorCodeSequence - instance of Illumination Color Code Sequence. 
	 */
	public IlluminatorTypeCodeSequence getIlluminatorTypeCodeSequence()
	{
		IlluminatorTypeCodeSequence objIlluminatorTypeCodeSequence = null;
		IDataElement objIDataElement =  getDataForTag(0x0048, 0x0100);
		if(objIDataElement != null)
		{
			IDicomValue objIDicomValue = objIDataElement.getDicomValue();
			if(objIDicomValue != null)
				objIlluminatorTypeCodeSequence = (IlluminatorTypeCodeSequence)objIDicomValue;
		}
		else
		{
			DicomV3Factory objDicomV3Factory = DicomV3Factory.createInstance();
			int iVRTransferSyntax = objITransferSyntax.getVRTransferSyntax();
			objIDataElement = null;
			objIlluminatorTypeCodeSequence = (IlluminatorTypeCodeSequence)objDicomV3Factory.createSequence(0x0048, 0x0100, objITransferSyntax, objIDictionaryReader);

			if(iVRTransferSyntax == DicomConstants.DCM_VR_IMPLICIT)
				objIDataElement = new ImplicitDE(0x0048, 0x0100, objIlluminatorTypeCodeSequence.getValue(),objIDictionaryReader);
			else
				objIDataElement = new ExplicitDE(0x0048, 0x0100, DicomConstants.DCM_DT_SQ, objIlluminatorTypeCodeSequence.getValue());
			objIDataElement.setTransferSyntax(objITransferSyntax);
			if(objIDataElement != null)
				addDataElement(objIDataElement);
		}
		return objIlluminatorTypeCodeSequence;
	}
	/**
	 * Sets the Illumination Wave Length.
	 * @param fIlluminationWaveLength Float value of the Ratio of displayed pixels to source pixels
	 */
	public void setIlluminationWaveLength( float fIlluminationWaveLength)
	{
		/*
		 * Accept the Illumination Wave Length in String format of type FL.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */
		IDataElement objIDataElement = null;
		if(objITransferSyntax.getVRTransferSyntax() == DicomConstants.DCM_VR_IMPLICIT)	
			objIDataElement = new ImplicitDE(0x0022,0x0055, fIlluminationWaveLength,getDictionaryReader());
		else
			objIDataElement = new ExplicitDE(0x0022,0x0055,DicomConstants.DCM_DT_FL, fIlluminationWaveLength);

		addDataElement(objIDataElement);
	}
	/**
	 * Retrieves the IlluminationWaveLength.
	 * @return float - Float value of the Illumination WaveLength .
	 */
	public float getIlluminationWaveLength()
	{
		Object objValue = getValue(0x0022,0x0055);
		if(objValue != null)
			return Float.parseFloat(objValue.toString());
		return DicomConstants.DCM_NO_VALUE;
	}
	/**
	 * Retrieves pre-initialized object of Illumination Color Code Sequence.If the module contains the sequence object
	 * it returns the same otherwise it creates the sequence adds to the module with proper initialization
	 * and then returns the object of sequence.
	 * @return IlluminationColorCodeSequence - instance of Illumination Color Code Sequence. 
	 */
	public IlluminationTypeCodeSequence getIlluminationTypeCodeSequence()
	{
		IlluminationTypeCodeSequence objIlluminationTypeCodeSequence = null;
		IDataElement objIDataElement =  getDataForTag(0x0048, 0x0100);
		if(objIDataElement != null)
		{
			IDicomValue objIDicomValue = objIDataElement.getDicomValue();
			if(objIDicomValue != null)
				objIlluminationTypeCodeSequence = (IlluminationTypeCodeSequence)objIDicomValue;
		}
		else
		{
			DicomV3Factory objDicomV3Factory = DicomV3Factory.createInstance();
			int iVRTransferSyntax = objITransferSyntax.getVRTransferSyntax();
			objIDataElement = null;
			objIlluminationTypeCodeSequence = (IlluminationTypeCodeSequence)objDicomV3Factory.createSequence(0x0048, 0x0100, objITransferSyntax, objIDictionaryReader);

			if(iVRTransferSyntax == DicomConstants.DCM_VR_IMPLICIT)
				objIDataElement = new ImplicitDE(0x0048, 0x0100, objIlluminationTypeCodeSequence.getValue(),objIDictionaryReader);
			else
				objIDataElement = new ExplicitDE(0x0048, 0x0100, DicomConstants.DCM_DT_SQ, objIlluminationTypeCodeSequence.getValue());
			objIDataElement.setTransferSyntax(objITransferSyntax);
			if(objIDataElement != null)
				addDataElement(objIDataElement);
		}
		return objIlluminationTypeCodeSequence;
	}
	/**
	 * Retrieves pre-initialized object of Light Path Filter Type Stack Code Sequence.If the module contains the sequence object
	 * it returns the same otherwise it creates the sequence adds to the module with proper initialization
	 * and then returns the object of sequence.
	 * @return LightPathFilterTypeStackCodeSequence - instance of Light Path Filter Type Stack Code Sequence. 
	 */
	public LightPathFilterTypeStackCodeSequence getLightPathFilterTypeStackCodeSequence()
	{
		LightPathFilterTypeStackCodeSequence objLightPathFilterTypeStackCodeSequence = null;
		IDataElement objIDataElement =  getDataForTag(0x0022, 0x0017); 
		if(objIDataElement != null)
		{
			IDicomValue objIDicomValue = objIDataElement.getDicomValue();
			if(objIDicomValue != null)
				objLightPathFilterTypeStackCodeSequence = (LightPathFilterTypeStackCodeSequence)objIDicomValue;
		}
		else
		{
			DicomV3Factory objDicomV3Factory = DicomV3Factory.createInstance();
			int iVRTransferSyntax = objITransferSyntax.getVRTransferSyntax();
			objIDataElement = null;
			objLightPathFilterTypeStackCodeSequence = (LightPathFilterTypeStackCodeSequence)objDicomV3Factory.createSequence(0x0022, 0x0017, objITransferSyntax, objIDictionaryReader);

			if(iVRTransferSyntax == DicomConstants.DCM_VR_IMPLICIT)
				objIDataElement = new ImplicitDE(0x0022, 0x0017, objLightPathFilterTypeStackCodeSequence.getValue(),objIDictionaryReader);
			else
				objIDataElement = new ExplicitDE(0x0022, 0x0017, DicomConstants.DCM_DT_SQ, objLightPathFilterTypeStackCodeSequence.getValue());
			objIDataElement.setTransferSyntax(objITransferSyntax);
			if(objIDataElement != null)
				addDataElement(objIDataElement);
		}
		return objLightPathFilterTypeStackCodeSequence;
	}
	/**
	 * Sets Light Path Filter Pass-Through Wavelength.
	 * 
	 * @param sLightPathFilterPassThroughWavelength short value of Light Path Filter Pass-Through Wavelength.
	 */
	public void setLightPathFilterPassThroughWavelength(short sLightPathFilterPassThroughWavelength)
	{
		/* Accept Light Path Filter Pass-Through Wavelength in short format of type US.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create.
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */
		IDataElement objIDataElement = null;
		if(objITransferSyntax.getVRTransferSyntax() == DicomConstants.DCM_VR_IMPLICIT)
			objIDataElement = new ImplicitDE(0x0022,0x0001,sLightPathFilterPassThroughWavelength,getDictionaryReader());
		else
			objIDataElement = new ExplicitDE(0x0022,0x0001,DicomConstants.DCM_DT_US, sLightPathFilterPassThroughWavelength);

		addDataElement(objIDataElement);
	}

	/**
	 * Retrieves the LightPathFilterPassThroughWavelengthn.
	 * 
	 * @return short - short value of LightPathFilterPassThroughWavelength.
	 */
	public short getLightPathFilterPassThroughWavelength()
	{
		Object objValue = getValue(0x0022,0x0001);
		if(objValue != null)
			return Short.parseShort(objValue.toString());
		return DicomConstants.DCM_NO_VALUE;
	}

	/**
	 * Sets Light Path Filter Pass-Through Wavelength.
	 * 
	 * @param sLightPathFilterPassBand short value of Light Path Filter Pass-Through Wavelength.
	 */
	public void setLightPathFilterPassBand(short sLightPathFilterPassBand)
	{
		/* Accept Light Path Filter Pass-Through Wavelength in short format of type US.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create.
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */
		IDataElement objIDataElement = null;
		if(objITransferSyntax.getVRTransferSyntax() == DicomConstants.DCM_VR_IMPLICIT)
			objIDataElement = new ImplicitDE(0x0022,0x0002,sLightPathFilterPassBand,getDictionaryReader());
		else
			objIDataElement = new ExplicitDE(0x0022,0x0002,DicomConstants.DCM_DT_US, sLightPathFilterPassBand);

		addDataElement(objIDataElement);
	}

	/**
	 * Retrieves the LightPathFilterPassBand.
	 * 
	 * @return short - short value of LightPathFilterPassBand.
	 */
	public short getLightPathFilterPassBand()
	{
		Object objValue = getValue(0x0022,0x0002);
		if(objValue != null)
			return Short.parseShort(objValue.toString());
		return DicomConstants.DCM_NO_VALUE;
	}
	/**
	 * Retrieves pre-initialized object of Lenses Code Sequence.If the module contains the sequence object
	 * it returns the same otherwise it creates the sequence adds to the module with proper initialization
	 * and then returns the object of sequence.
	 * @return LensesCodeSequence - instance of Light Path Filter Type Stack Code Sequence. 
	 */
	public LensesCodeSequence getLensesCodeSequence()
	{
		LensesCodeSequence objLensesCodeSequence = null;
		IDataElement objIDataElement =  getDataForTag(0x0022, 0x0019); 
		if(objIDataElement != null)
		{
			IDicomValue objIDicomValue = objIDataElement.getDicomValue();
			if(objIDicomValue != null)
				objLensesCodeSequence = (LensesCodeSequence)objIDicomValue;
		}
		else
		{
			DicomV3Factory objDicomV3Factory = DicomV3Factory.createInstance();
			int iVRTransferSyntax = objITransferSyntax.getVRTransferSyntax();
			objIDataElement = null;
			objLensesCodeSequence = (LensesCodeSequence)objDicomV3Factory.createSequence(0x0022, 0x0019, objITransferSyntax, objIDictionaryReader);

			if(iVRTransferSyntax == DicomConstants.DCM_VR_IMPLICIT)
				objIDataElement = new ImplicitDE(0x0022, 0x0019, objLensesCodeSequence.getValue(),objIDictionaryReader);
			else
				objIDataElement = new ExplicitDE(0x0022, 0x0019, DicomConstants.DCM_DT_SQ, objLensesCodeSequence.getValue());
			objIDataElement.setTransferSyntax(objITransferSyntax);
			if(objIDataElement != null)
				addDataElement(objIDataElement);
		}
		return objLensesCodeSequence;
	}
	/**
	 * Sets Condenser Lens Power.
	 * @param strCondenserLensPower String value of Condenser Lens Power.
	 */
	public void setCondenserLensPower(String strCondenserLensPower)
	{
		/*Accept the Condenser Lens Power in String format of type DS.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */
		IDataElement objIDataElement = null;	
		if(objITransferSyntax.getVRTransferSyntax() == DicomConstants.DCM_VR_IMPLICIT)
			objIDataElement = new ImplicitDE(0x0048,0x0111, strCondenserLensPower,getDictionaryReader());
		else
			objIDataElement = new ExplicitDE(0x0048,0x0111,DicomConstants.DCM_DT_DS, strCondenserLensPower);

		addDataElement(objIDataElement);
	}
	/**
	 * Retrieves CondenserLensPower.
	 * @return String - value of CondenserLensPower.
	 */
	public String getCondenserLensPower()
	{
		Object objValue = getValue(0x0048,0x0111);
		if(objValue != null)
			return objValue.toString();
		return null;
	}
	/**
	 * Sets ObjectiveLensPower.
	 * @param strObjectiveLensPower String value of ObjectiveLensPower.
	 */
	public void setObjectiveLensPower(String strObjectiveLensPower)
	{
		/*Accept the ObjectiveLensPower in String format of type DS.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */
		IDataElement objIDataElement = null;
		if(objITransferSyntax.getVRTransferSyntax() == DicomConstants.DCM_VR_IMPLICIT)
			objIDataElement = new ImplicitDE(0x0048,0x0112, strObjectiveLensPower,getDictionaryReader());
		else
			objIDataElement = new ExplicitDE(0x0048,0x0112,DicomConstants.DCM_DT_DS, strObjectiveLensPower);

		addDataElement(objIDataElement);
	}
	/**
	 * Retrieves ObjectiveLensPower.
	 * @return String - value of ObjectiveLensPower.
	 */
	public String getObjectiveLensPower()
	{
		Object objValue = getValue(0x0048,0x0112);
		if(objValue != null)
			return objValue.toString();
		return null;
	}
	/**
	 * Sets ObjectiveLensNumericalAperture.
	 * @param strObjectiveLensNumericalAperture String value of ObjectiveLensNumericalAperture.
	 */
	public void setObjectiveLensNumericalAperture(String strObjectiveLensNumericalAperture)
	{
		/*Accept the ObjectiveLensNumericalAperture in String format of type DS.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */
		IDataElement objIDataElement = null;
		if(objITransferSyntax.getVRTransferSyntax() == DicomConstants.DCM_VR_IMPLICIT)
			objIDataElement = new ImplicitDE(0x0048,0x0113, strObjectiveLensNumericalAperture,getDictionaryReader());
		else
			objIDataElement = new ExplicitDE(0x0048,0x0113,DicomConstants.DCM_DT_DS, strObjectiveLensNumericalAperture);

		addDataElement(objIDataElement);
	}
	/**
	 * Retrieves ObjectiveLensNumericalAperture.
	 * @return String - value of ObjectiveLensNumericalAperturer.
	 */
	public String getObjectiveLensNumericalAperture()
	{
		Object objValue = getValue(0x0048,0x0113);
		if(objValue != null)
			return objValue.toString();
		return null;
	}
	/**
	 * Retrieves pre-initialized object of Channel Description CodeSequence.If the module contains the sequence object
	 * it returns the same otherwise it creates the sequence adds to the module with proper initialization
	 * and then returns the object of sequence.
	 * @return ChannelDescriptionCodeSequence - instance of Light Path Filter Type Stack Code Sequence. 
	 */
	public ChannelDescriptionCodeSequence getChannelDescriptionCodeSequence()
	{
		ChannelDescriptionCodeSequence objChannelDescriptionCodeSequence = null;
		IDataElement objIDataElement =  getDataForTag(0x0022, 0x001A); 
		if(objIDataElement != null)
		{
			IDicomValue objIDicomValue = objIDataElement.getDicomValue();
			if(objIDicomValue != null)
				objChannelDescriptionCodeSequence = (ChannelDescriptionCodeSequence)objIDicomValue;
		}
		else
		{
			DicomV3Factory objDicomV3Factory = DicomV3Factory.createInstance();
			int iVRTransferSyntax = objITransferSyntax.getVRTransferSyntax();
			objIDataElement = null;
			objChannelDescriptionCodeSequence = (ChannelDescriptionCodeSequence)objDicomV3Factory.createSequence(0x0022, 0x001A, objITransferSyntax, objIDictionaryReader);

			if(iVRTransferSyntax == DicomConstants.DCM_VR_IMPLICIT)
				objIDataElement = new ImplicitDE(0x0022, 0x001A, objChannelDescriptionCodeSequence.getValue(),objIDictionaryReader);
			else
				objIDataElement = new ExplicitDE(0x0022, 0x001A, DicomConstants.DCM_DT_SQ, objChannelDescriptionCodeSequence.getValue());
			objIDataElement.setTransferSyntax(objITransferSyntax);
			if(objIDataElement != null)
				addDataElement(objIDataElement);
		}
		return objChannelDescriptionCodeSequence;
	}
	/**
	 * Retrieves pre-initialized object of Palette Color Lookup TableSequence.If the module contains the sequence object
	 * it returns the same otherwise it creates the sequence adds to the module with proper initialization
	 * and then returns the object of sequence.
	 * @return PaletteColorLookupTableSequence - instance of Palette Color Lookup TableSequence. 
	 */
	public PaletteColorLookupTableSequence getPaletteColorLookupTableSequence()
	{
		PaletteColorLookupTableSequence objPaletteColorLookupTableSequence = null;
		IDataElement objIDataElement =  getDataForTag(0x0048, 0x0120);  
		if(objIDataElement != null)
		{
			IDicomValue objIDicomValue = objIDataElement.getDicomValue();
			if(objIDicomValue != null)
				objPaletteColorLookupTableSequence = (PaletteColorLookupTableSequence)objIDicomValue;
		}
		else
		{
			DicomV3Factory objDicomV3Factory = DicomV3Factory.createInstance();
			int iVRTransferSyntax = objITransferSyntax.getVRTransferSyntax();
			objIDataElement = null;
			objPaletteColorLookupTableSequence = (PaletteColorLookupTableSequence)objDicomV3Factory.createSequence(0x0048, 0x012, objITransferSyntax, objIDictionaryReader);

			if(iVRTransferSyntax == DicomConstants.DCM_VR_IMPLICIT)
				objIDataElement = new ImplicitDE(0x0048, 0x012, objPaletteColorLookupTableSequence.getValue(),objIDictionaryReader);
			else
				objIDataElement = new ExplicitDE(0x0048, 0x012, DicomConstants.DCM_DT_SQ, objPaletteColorLookupTableSequence.getValue());
			objIDataElement.setTransferSyntax(objITransferSyntax);
			if(objIDataElement != null)
				addDataElement(objIDataElement);
		}
		return objPaletteColorLookupTableSequence;
	}
	/**
	 * Sets the ICC Profile
	 * An ICC Profile encoding the transformation of device-dependent 
	 * stored pixel values into PCS-Values.
	 * @param vectICCProfile collection of byte array of ICC Profile values.
	 */
	public void setICCProfile(ISingleCollection<byte[]> vectICCProfile)
	{
		/*Accept the ICCProfile in vector of byte array format of type OB.
		 * Read the Transfer Syntax and check if ImplicitDE or ExplicitDE to create
		 * Set the iGroupNumber and iElementNumber to ImplicitDE object 
		 * Set the iVRType
		 * Set length from the element
		 * Add this element to the Data Set
		 */
		IDataElement objIDataElement = null;
		if(objITransferSyntax.getVRTransferSyntax() == DicomConstants.DCM_VR_IMPLICIT)
			objIDataElement = new ImplicitDE(0x0028, 0x2000, vectICCProfile,getDictionaryReader());
		else
			objIDataElement = new ExplicitDE(0x0028, 0x2000,DicomConstants.DCM_DT_OB, vectICCProfile);

		addDataElement(objIDataElement); 
	}

	/**
	 * Retrieves the ICC Profile .
	 * @return ISingleCollection<byte[]> - collection of byte array of ICC Profile.
	 */
	@SuppressWarnings("unchecked")
	public ISingleCollection<byte[]> getICCProfile()
	{
		Object objValue = getValue(0x0028, 0x2000);
		if(objValue != null)
			return (ISingleCollection<byte[]>)objValue;
		return null;
	}

}
