/*******************************************************************************
 *  Copyright 2017 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.hl7282.utils;

import cdac.medinfo.sdk.hl7282.commoninterface.ISegmentKey;

/**
 * IMessageMap needs to be implemented by class which provides Structure for a HL7 Message.
 * Implementor class should provide definition to all methods which are defined to represent HL7 message structure.
 */
public interface IMap
{
	/**
	 * Retrieves ISegmentItem from given index.
	 * @param index value of index
	 * @return ISegmentItem instance of ISegmentItem
	 */
	ISegmentItem getSegmentItem(int index);

	/**
	 * Adds a ISegmentItem to Map at current available index.
	 * @param objSegmentItem Specified Sequence Item. 
	 */
	void addSegmentItem(ISegmentItem objSegmentItem);

	/**
	 * Adds a Segment Item to Map at given index according to the modification mode.
	 * @param objSegmentItem Specified Sequence Item. 
	 */
	void addSegmentItem(ISegmentItem objSegmentItem,int index,EnumMapModifyMode enumModifyMode);

	/**
	 * This method returns the size of Message Map
	 * @return int - number of SegmentItem available in MessageMap 
	 */
	int size();

	/**
	 * Verifies whether Segment or Group is present at the first level of HL7 message structure or not.
	 * @param enumSearchSegment Object of ISegmentKey provides name of Segment or Group.
	 * @return True - if Given Segment or Group is present at first level of HL7 message Structur else returns false.
	 */
	boolean isFirstLevelMember(ISegmentKey enumSearchSegment);

	/**
	 * Verifies whether Segment or Group is member of HL7 Message or not according to Message Structure. 
	 * @param enumSearchSegment Object of ISegmentKey provides name of Segment or Group.
	 * @param objMessageMap Object of IMessageMap.
	 * @return True - if Given Segment or Group is part of HL7 message Structur else returns false.
	 */
	boolean isMember(ISegmentKey enumSearchSegment);

	/**
	 * Generates clone of MessageMap
	 * @return IMessageMap - instance of MessageMap
	 */
	IMap clone();

	/**
	 * Sets lock on IMessageMap.
	 * If lock is set then new SegmentItem can not be added in IMessageMap
	 * @param bLock value of lock
	 */
	void setLock(boolean bLock);
	
	/**
	 * Retrieves current status of lock for IMessageMap
	 * @return boolean - status of lock
	 */
	boolean getLock();
	
	/**
	 * Retrieves Map of specified Group name
	 * @param enumGroupName Object of ISegmentKey provides name of Group.
	 * @return IMessageMap Object of IMessageMap.
	 */
	IMap getGroupMap(ISegmentKey enumGroupName);
}
