/*******************************************************************************
 *  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;




/**
 * The Class RQUserInfoItem.
 */
public class RQUserInfoItem extends UserInfoItem 
{


	/** The object of SOP Class Common Extended Negotiation Item */
	SOPClassCommonExtNegotItem objSOPClassCommonExtNegotItem =null;

	/**
	 * Instantiates a new RQ user info item.
	 */
	public RQUserInfoItem()
	{

	}

	/**
	 * Gets the SOP class common extended negotiation item.
	 * @return SOPClassCommonExtNegotItem - object of the SOP class common extended negotiation item.
	 */
	public SOPClassCommonExtNegotItem getSOPClassCommonExtNegotItem() 
	{
		return objSOPClassCommonExtNegotItem;
	}

	/**
	 * Sets the SOP class common extended negotiation item.
	 * @param objSOPClassCommonExtNegotItem object of SOP Class Common Extended Negotiation Item.
	 */
	public void setSOPClassCommonExtNegotItem(SOPClassCommonExtNegotItem objSOPClassCommonExtNegotItem) 
	{
		this.objSOPClassCommonExtNegotItem = objSOPClassCommonExtNegotItem;
	}

	/**
	 * Parses RQ User Info Item.
	 * @param objIDicomStream object of stream on which dicom data resides.
	 * @throws IOException Signals that an I/O exception has occurred.
	 */
	public void parse(IDicomStream objIDicomStream)throws IOException
	{
		super.parse(objIDicomStream);
		if(objIDicomStream.available() != 0)
		{
			objIDicomStream.mark(1);
			byte iTempItemValue = objIDicomStream.readByte();
			if(iTempItemValue == EnumItemType.SOP_CLASS_COMMON_EXTENDED_NEGOTIATION_ITEM.getValue())
			{
				objSOPClassCommonExtNegotItem = new SOPClassCommonExtNegotItem();
				objIDicomStream.reset();
				objSOPClassCommonExtNegotItem.parse(objIDicomStream);
			}
		}
	}

	/**
	 * This method writes the Data Value to the given Stream.
	 * @param objIDicomStream object of the stream onto which the Request User Info 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);
		if(objSOPClassCommonExtNegotItem != null)
			objSOPClassCommonExtNegotItem.serialize(objIDicomStream);
	}
}
