package cdac.medinfo.sdk.hl7282.hl7net.commons;

import java.io.IOException;

import cdac.medinfo.sdk.hl7282.commoninterface.ISingleCollection;
import cdac.medinfo.sdk.hl7282.hl7streams.HL7BufferStream;

/**
 * The IFragmentProcessor interface should be implemented by any class 
 * whose instances are intended to perform the fragmentation and defragmentation for HL7 messages. 
 * The class must define the fragment and defragment methods to fragment and reassembling the fragments. 
 */
public interface IFragmentProcessor
{
	/**
	 * Fragments The HL7BufferStream and returns Fragmented HL7BufferStream.
	 * It adds required segments in fragments specified by HL7 standard.
	 * @param objHL7BufferStream - HL7BufferStream to fragment.
	 * @return ISingleCollection&lt;HL7BufferStream&gt; - Collection of Fragmented HL7BufferStream.
	 * @throws IOException Thrown when IO operation fails.  
	 */
	public ISingleCollection<HL7BufferStream> fragment(HL7BufferStream objHL7BufferStream) throws IOException;
	
	/**
	 * Defragments The HL7BufferStream and returns Defragmented HL7BufferStream.
	 * Removes additional segments from fragments and generates the original HL7 Message.
	 * @param objHL7BufferStream - HL7BufferStream to defragment.
	 * @return HL7BufferStream - Defragmented HL7BufferStream .
	 * @throws IOException Thrown when IO operation fails.
	 */
	public HL7BufferStream defragment(HL7BufferStream objHL7BufferStream) throws IOException;
	
	/**
	 * Sets maximum length for fragments.
	 * @param iLength value of maximum fragment length.
	 */
	public void setMaxLength(int iLength);
}
