/*******************************************************************************
 *  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.EnumPDUType;
import cdac.medinfo.sdk.dcm30_04.exceptions.ParseException;
import cdac.medinfo.sdk.dcm30_04.exceptions.SerializeException;




/**
 * The Class represents AReleaseRQ or RP PDU.
 */
public class AReleaseRQorRPPDU extends PDU 
{

	/** The Constant ARelease RQ or RP PDU. */
	public static final int ARELEASE_RQORRP_LENGTH = 4;

	/**
	 * Instantiates a new ARelease RQ or RP PDU.
	 * @param enumPDUType enum value of PDU Type.
	 */
	public AReleaseRQorRPPDU(EnumPDUType enumPDUType)
	{
		this.enumPDUType = enumPDUType;
	}


	/**
	 * Parses the ARelease RQ or RP PDU.
	 * @param objIDicomStream object of dicom stream on which data is available.
	 * @throws IOException Signals that IO Exception has occurred.
	 * @throws ParseException Signals that Parse Exception has occurred.
	 */
	public void parse(IDicomStream objIDicomStream)throws IOException,ParseException
	{
		super.parse(objIDicomStream);
		// reading four reserve bytes
		objIDicomStream.readInt();
	}


	/**
	 * This method writes the Data Value to the given Stream.
	 * @param objIDicomStream  object of the stream onto which this PDU is to be  written.
	 * @throws IOException Signals that IO Exception has occurred.
	 * @throws SerializeException Signals that Serialize Exception has occurred.
	 */
	public void serialize(IDicomStream objIDicomStream) throws IOException,SerializeException
	{
		super.serialize(objIDicomStream);
		objIDicomStream.writeInt(0);
	}

	/**
	 * This function gets the length of this PDU.
	 * @return int - int value of length of this PDU>
	 */
	public int getLength()
	{
		return ARELEASE_RQORRP_LENGTH;
	}
}
