cdac.medinfo.sdk.hl7282.hl7streams

## Class HL7Stream

- java.lang.Object
- - cdac.medinfo.sdk.hl7282.hl7streams.HL7Stream

- All Implemented Interfaces:
    IHL7Stream
  Direct Known Subclasses:
    HL7BufferStream, HL7FileStream

      public abstract class HL7Stream
      extends java.lang.Object
      implements IHL7Stream

  This is an abstract class providing all the common functionality and refernce for all extending classes. This class facilitates reading primitive data from the stream and set in the stream.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `HL7Stream()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `available()` Returns the number of bytes available on the input stream.
    `int` | `close()` Closes the Streams.
    `boolean` | `endSend()` Checks end of Stream.
    `int` | `getReadBytes()` Tracks bytes read from the stream.
    `int` | `getStream()` Returns the stream type to which it is set to [InputStream/outputStream].
    `int` | `mark(int iReadAheadLimit)` Marks the stream for further resetting with specified readAheadLimit.
    `int` | `readBuffer(byte[] arrbyte)` Reads buffer byte by byte from stream.
    `byte` | `readByte()` Reads a single byte from the stream.
    `char` | `readChar()` Reads a char from the stream.
    `int` | `readString(java.lang.StringBuffer strBuffValue, int iCount)` Reads a string from the stream with specified length.
    `int` | `reset()` Resets the stream if stream is read further within the readAheadLimit.
    `int` | `skip(int iNumBytes)` Skips the number of bytes specified in the parameter.
    `boolean` | `startReceive()` Checks receiving of Stream.
    `int` | `writeBuffer(byte[] arrbyte, int iOffset, int iLength)` Writes Byte array to the DataOutputStream.
    `int` | `writeByte(byte byteVal)` Writes a byte to the stream.
    `int` | `writeChar(char charVal)` Writes a character with specified endianNess to the stream.
    `int` | `writeString(java.lang.String strValue)` Writes the string specified in the parameter on the stream.

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### HL7Stream

          public HL7Stream()

  - ### Method Detail

    - #### getStream

          public int getStream()

      Returns the stream type to which it is set to [InputStream/outputStream].
      Specified by:
        `getStream` in interface `IHL7Stream`
      Returns:
        int - returns the stream type which is being used.

    - #### getReadBytes

          public int getReadBytes()

      Tracks bytes read from the stream.
      Specified by:
        `getReadBytes` in interface `IHL7Stream`
      Returns:
        int - the total no of bytes read

    - #### readByte

          public byte readByte()

      Reads a single byte from the stream.
      Specified by:
        `readByte` in interface `IHL7Stream`
      Returns:
        byte - returns the byte read

    - #### readChar

          public char readChar()

      Reads a char from the stream.
      Specified by:
        `readChar` in interface `IHL7Stream`
      Returns:
        char - Character read from stream - '\0' if no character is read

    - #### readString

          public int readString(java.lang.StringBuffer strBuffValue,
                       int iCount)

      Reads a string from the stream with specified length.
      Specified by:
        `readString` in interface `IHL7Stream`
      Parameters:
        `strBuffValue` - length of the string to be read
        `iCount` - specified length
      Returns:
        int - the read string

    - #### writeString

          public int writeString(java.lang.String strValue)

      Writes the string specified in the parameter on the stream.
      Specified by:
        `writeString` in interface `IHL7Stream`
      Parameters:
        `strValue` - the String to write
      Returns:
        int - Success\Fail

    - #### readBuffer

          public int readBuffer(byte[] arrbyte)

      Reads buffer byte by byte from stream.
      Specified by:
        `readBuffer` in interface `IHL7Stream`
      Parameters:
        `arrbyte` - byte of buffer
      Returns:
        iNumberOfBytesRead - Returns the number of bytes actually read from input stream
        If no byte is available because the stream is at end of file, the value -1 is returned.

    - #### writeByte

          public int writeByte(byte byteVal)

      Writes a byte to the stream.
      Specified by:
        `writeByte` in interface `IHL7Stream`
      Parameters:
        `byteVal` - byte to write
      Returns:
        int - Success\Fail

    - #### writeChar

          public int writeChar(char charVal)

      Writes a character with specified endianNess to the stream.
      Specified by:
        `writeChar` in interface `IHL7Stream`
      Parameters:
        `charVal` - character to write
      Returns:
        int - Success\Fail

    - #### writeBuffer

          public int writeBuffer(byte[] arrbyte,
                        int iOffset,
                        int iLength)

      Writes Byte array to the DataOutputStream.
      Specified by:
        `writeBuffer` in interface `IHL7Stream`
      Parameters:
        `arrbyte` - byte array to write
        `iOffset` - the start offset in the data
        `iLength` - the number of bytes to write
      Returns:
        int - Success\Fail

    - #### startReceive

          public boolean startReceive()

      Description copied from interface: `IHL7Stream`
      Checks receiving of Stream.
      Specified by:
        `startReceive` in interface `IHL7Stream`
      Returns:
        boolean

    - #### endSend

          public boolean endSend()

      Description copied from interface: `IHL7Stream`
      Checks end of Stream.
      Specified by:
        `endSend` in interface `IHL7Stream`
      Returns:
        boolean

    - #### mark

          public int mark(int iReadAheadLimit)

      Marks the stream for further resetting with specified readAheadLimit.
      Specified by:
        `mark` in interface `IHL7Stream`
      Parameters:
        `iReadAheadLimit` -
      Returns:
        int - Success\Fail

    - #### reset

          public int reset()

      Resets the stream if stream is read further within the readAheadLimit.
      Specified by:
        `reset` in interface `IHL7Stream`
      Returns:
        int - Success\Fail

    - #### skip

          public int skip(int iNumBytes)

      Skips the number of bytes specified in the parameter.
      Parameters:
        `iNumBytes` -
      Returns:
        int - Success\Fail

    - #### available

          public int available()

      Returns the number of bytes available on the input stream.
      Specified by:
        `available` in interface `IHL7Stream`
      Returns:
        int returns the number of bytes that can be read

    - #### close

          public int close()

      Closes the Streams.
      Returns:
        int - Success\Fail