/*******************************************************************************
 *  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.services.pdu;

import java.io.IOException;

import cdac.medinfo.sdk.dcm30_04.commoninterface.IDicomStream;
import cdac.medinfo.sdk.dcm30_04.enums.EnumItemType;




/**
 * This class represents Implementation-class-uid Item.
 * The Implementation Class UID Sub-Item shall be made of a sequence of mandatory fixed length fields
 * followed by a variable field. Only one Implementation Class UID Sub-Item shall be present in the User
 */
public class ImplClassUIDItem extends AssociationItem 
{


	/** The Implementation-class-uid */
	String strImplClassUID;

	/**
	 * Instantiates a new Implementation-class-uid item.
	 */
	public ImplClassUIDItem()
	{
		super(EnumItemType.USER_INFO_IMPL_CLASS_UID_ITEM.getValue());
	}

	/**
	 * Gets Implementation-class-uid of the Association-acceptor
	 * @return String - String value of  Implementation-class-uid of the Association-acceptor
	 */
	public String getImplClassUID() 
	{
		return strImplClassUID;
	}

	/**
	 * Sets Implementation-class-uid of the Association-acceptor
	 * @param strImplClassUID String value of  Implementation-class-uid of the Association-acceptor
	 */
	public void setImplClassUID(String strImplClassUID) 
	{
		this.strImplClassUID = strImplClassUID;
	}

	/**
	 * This method gets the length of Implementation Class UID Item.
	 * @return short -short value of Implementation Class UID Item.
	 */
	public short getItemLength() 
	{
		return (short)strImplClassUID.length();
	}

	/**
	 * Parses the Implementation class UID Item.
	 * @param objIDicomStream object of the stream containing the dicom data.
	 * @throws IOException Signals that an I/O exception has occurred.
	 */
	public void parse(IDicomStream objIDicomStream)throws IOException
	{
		super.parse(objIDicomStream);
		short shItemLength = objIDicomStream.readShort();
		strImplClassUID = objIDicomStream.readString(shItemLength);
	}

	/**
	 * This method writes the Data Value to the given Stream.
	 * @param objIDicomStream object of the stream onto which the Implementation Class UID Item is to be written.
	 * @throws IOException Signals that an I/O exception has occurred.
	 */
	public void serialize(IDicomStream objIDicomStream) throws IOException
	{
		super.serialize(objIDicomStream);
		objIDicomStream.writeShort(getItemLength());
		objIDicomStream.writeString(strImplClassUID);
	}
}
