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

import java.io.IOException;

import cdac.medinfo.sdk.dcm30_04.commoninterface.IDicomStream;
import cdac.medinfo.sdk.dcm30_04.commoninterface.IDicomValue;
import cdac.medinfo.sdk.dcm30_04.commoninterface.ITag;
import cdac.medinfo.sdk.dcm30_04.commoninterface.ITransferSyntax;
import cdac.medinfo.sdk.dcm30_04.exceptions.InvalidDataElementException;
import cdac.medinfo.sdk.dcm30_04.exceptions.InvalidDataTypeException;

/**
 * This interface needs to be implemented by all classes which implements
 * functioning of CommandElement.
 */
public interface ICommandElement
{
	/**
	 * The implementation of this method serializes the Command Element from the
	 * given Stream.
	 * @param objIDicomStream   Stream on which the DICOM data is available
	 * @return int - shows status as success or failure.
	 * @throws InvalidDataTypeException  If DataType validation fails.
	 * @throws IOException  If Input/Output operation fails.
	 */
	int serialize(IDicomStream objIDicomStream) throws InvalidDataTypeException, IOException;

	/**
	 * The implementation of this method parses the Command Element from the
	 * given Stream.
	 * @param objIDicomStream Stream on which the DICOM data is available
	 * @return int - shows status as success or failure.
	 * @throws InvalidDataElementException  If Data Element fails to satisfy Validation Criteria.
	 * @throws IOException  If Input/Output operation fails.
	 * @throws InvalidCommandElementException the invalid command element exception
	 */
	int parse(IDicomStream objIDicomStream) throws InvalidCommandElementException, IOException;;

	/**
	 * The implementation of this method sets length of the CommandElement.
	 * @param iLength 4 bytes Length of Value in the Command Element.
	 */
	void setLength(int iLength);

	/**
	 * The implementation of this method retrieves the length of value for a
	 * CommandElement.
	 * @return int - Integer value of length.
	 */
	int getValueLength();

	/**
	 * The implementation of this method retrieves the length of CommandElement.
	 * @return int - Integer value of length.
	 */
	int getCommandElementLength();

	/**
	 * The implementation of this method retrieves the length part of the
	 * Command Element.
	 * @return int - Integer value of length.
	 */
	int getLength();

	/**
	 * The implementation of this method retrieves the value multiplicity of the
	 * value in CommandElement.
	 * @return integer - returns the actual value multiplicity of value in the
	 *         CommandElement
	 */
	public int getValueMultiplicity();

	/**
	 * The implementation of this method sets the value multiplicity of the
	 * value of CommandElement.
	 * @param iVM value multiplicity of the value
	 */
	void setValueMultiplicity(int iVM);

	/**
	 * The implementation of this method sets the GroupNumber and ElementNumber
	 * of the Command Element.
	 * @param iGroupNumber  specifies the Group Number.
	 * @param iElementNumber specifies the Element Number.
	 */
	void setTag(int iGroupNumber,int iElementNumber);

	/**
	 * The implementation of this method sets the length of CommandElement.
	 */
	void setCommandElementLength();

	/**
	 * The implementation of this method retrieves the Tag part of the Command
	 * Element.
	 * @return ITag - Tag containing Group Number and Element Number.
	 */
	ITag getTag();

	/**
	 * The implementation of this method retrieves the value part of the Command Element.
	 * @return IDicomValue - instance containing the value of the Command Element.
	 */
	IDicomValue getDicomValue();

	/**
	 * The implementation of this method sets the DicomValue as a value in the
	 * CommandElement.
	 * @param objIDicomValue object of DicomValue representing the value of CommandElement
	 */
	void setDicomValue(IDicomValue objIDicomValue);


	/**
	 * The implementation of this method retrieves the TransferSyntax set in the
	 * CommandElement object.
	 * @return ITransferSyntax object of TransferSyntax set in the  CommandElement object.
	 */
	ITransferSyntax getTransferSyntax();


	/**
	 * The implementation of this method Check for the equality of two objects.
	 * @param objTempObject the object to compare with.
	 * @return boolean - true if the objects are the same; false otherwise.
	 */
	public boolean equals(Object objTempObject);
}
