/*******************************************************************************
 *  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.commoninterface;
/**
 * Declares all the methods Used for the HL7 stream. IHL7Stream is Input/Output operation interface 
 * used for message parsing & serialization. It provides with method that read/write primitive data types. 
 */
public interface IHL7Stream 
{
	/**
	 * Returns the stream type to which it is set to [InputStream/outputStream].
	 * @return int - returns the stream type which is being used
	 */
	int getStream();
	
	/**
	 * Tracks bytes read from the stream.
	 * @return int - the total no of bytes read
	 */
	int getReadBytes();
	
	/**
	 * Reads a single byte from the stream.
	 * @return int - returns the byte read
	 */
	byte readByte();
	
	/**
	 * Reads a char from the stream.
	 * @return int - returns the character which is read
	 */
	char readChar();
	
	/**
	 * Reads a string from the stream with specified length.
	 * @param iCount length of the string to be read
	 * @param strBuffValue String buffer holds the data read
	 * @return String - the read string 
	 */
	int readString(StringBuffer strBuffValue, int iCount);
	
	/**
	 * Writes the string specified in the parameter to the stream.
	 * @param strValue the String to write
	 * @return int - Success\Fail
	 */
	int writeString(String strValue);
	
	/**
	 * Reads buffer byte by byte from stream.
	 * @param arrbyte byte to read
	 * @return iNumberOfBytesRead - Returns the number of bytes actually read from input stream <br>
	 * If no byte is available because the stream is at end of file, the value -1 is returned
	 */
	int readBuffer(byte[] arrbyte);
	
	/**
	 * Writes a byte on the stream.
	 * @param byteVal byte to write
	 * @return int - Success\Fail
	 */
	int writeByte(byte byteVal);
	
	/**
	 * Writes a character with specified endianNess to the stream.
	 * @param charVal character to write
	 * @return int - Success\Fail
	 */
	int writeChar(char charVal);
	
	/** 
	 * Writes Byte array to the DataOutputStream. 
	 * @param arrbyte byte array to write
	 * @param iOffset the start offset in the data
	 * @param iLength the number of bytes to write
	 * @return int - Success\Fail
	 */
	int writeBuffer(byte[] arrbyte,int iOffset,int iLength);
	
	/**
	 * Checks receiving of Stream. 
	 * @return boolean - true/false 
	 */
	boolean startReceive();
	
	/**
	 * Checks end of Stream.
	 * @return boolean - true/false.
	 */
	boolean endSend();
	
	/**
	 * Marks Stream with Read Ahead Limit specified.
	 * @param iReadAheadLimit number of streams
	 * @return int - number of streams
	 */
	int mark(int iReadAheadLimit);
	
	/**
	 * Resets the Stream to previously marked position.
	 * @return int - number of streams
	 */
	int reset();
	
	/**
	 * Returns available number of Bytes in IHL7Stream.
	 * @return int - number of Bytes in HL7 Stream
	 */
	int available();	
}
