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

/**
 * This class represents RELATED-GENERAL-SOP-CLASS-IDENTIFICATION SUB-FIELDS.
 */
public class RelGenSOPClassID  
{


	/** The Related-general-sop-class-uid-length */
	short shRelGenServiceClassUidLen;

	/** The Related-general-sop-class-uid */
	String strRelGenServiceClassUid;

	public short getLength()
	{
		return (short)(strRelGenServiceClassUid.length() + 2 );
	}
	
	/**
	 * Gets The Related-general-sop-class-uid-length.
	 * @return short - short value of Related-general-sop-class-uid-length
	 */
	public short getRelGenServiceClassUidLen() 
	{
		return shRelGenServiceClassUidLen;
	}

	/**
	 * Sets The Related-general-sop-class-uid-length i.e. number of bytes in the Related-general-sop-class-uid sub
	 * field.It shall be encoded as an unsigned binary number.
	 * @param shRelGenServiceClassUidLen short value of Related-general-sop-class-uid-length.
	 */
	public void setRelGenServiceClassUidLen(short shRelGenServiceClassUidLen) 
	{
		this.shRelGenServiceClassUidLen = shRelGenServiceClassUidLen;
	}

	/**
	 * Gets The Related General SOP Class identifier encoded as a UID
	 * @return String - value of Related General SOP Class identifier encoded as a UID.
	 */
	public String getRelGenServiceClassUid() 
	{
		return strRelGenServiceClassUid;
	}

	/**
	 * Sets The Related General SOP Class identifier encoded as a UID
	 * @param strRelGenServiceClassUid The Related General SOP Class identifier encoded as a UID
	 */
	public void setRelGenServiceClassUid(String strRelGenServiceClassUid) 
	{
		this.strRelGenServiceClassUid = strRelGenServiceClassUid;
	}

	/**
	 * Parses the RELATED-GENERAL-SOP-CLASS-IDENTIFICATION item.
	 * @param objIDicomStream Stream on which dicom data resides.
	 * @throws IOException Signals that an I/O exception has occurred.
	 */
	public void parse(IDicomStream objIDicomStream)throws IOException
	{
		shRelGenServiceClassUidLen = objIDicomStream.readShort();
		strRelGenServiceClassUid = objIDicomStream.readString(shRelGenServiceClassUidLen);
	}

	/**
	 * This method writes the Data Value to the given Stream.
	 * @param objIDicomStream object of the stream onto which the RELATED-GENERAL-SOP-CLASS-IDENTIFICATION Item is to be written.
	 * @throws IOException Signals that an I/O exception has occurred.
	 */
	public void serialize(IDicomStream objIDicomStream) throws IOException
	{
		objIDicomStream.writeShort(shRelGenServiceClassUidLen);
		objIDicomStream.writeString(strRelGenServiceClassUid);
	}
}
