Package com.framed.interop.hl7.mllp
Class MllpCodec
java.lang.Object
com.framed.interop.hl7.mllp.MllpCodec
Minimal Lower Layer Protocol (MLLP) framing.
An HL7 message is wrapped as <VT> message <FS><CR>, i.e. a start-block byte
(0x0B), the message bytes, an end-block byte (0x1C) and a carriage return
(0x0D). This is the de-facto transport framing for HL7 v2 over TCP.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intTrailing carriage return (0x0D).static final intEnd-of-block marker (file separator,0x1C).static final intStart-of-block marker (vertical tab,0x0B). -
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]Frames an HL7 message for MLLP transport.static StringReads a single MLLP-framed message from a stream, blocking until a full frame arrives.
-
Field Details
-
START_BLOCK
public static final int START_BLOCKStart-of-block marker (vertical tab,0x0B).- See Also:
-
END_BLOCK
public static final int END_BLOCKEnd-of-block marker (file separator,0x1C).- See Also:
-
CARRIAGE_RETURN
public static final int CARRIAGE_RETURNTrailing carriage return (0x0D).- See Also:
-
-
Method Details
-
frame
Frames an HL7 message for MLLP transport.- Parameters:
message- the HL7 message text- Returns:
- the MLLP-framed bytes
-
readMessage
Reads a single MLLP-framed message from a stream, blocking until a full frame arrives.Leading bytes before
START_BLOCKare skipped. The terminatingEND_BLOCK(and the trailingCARRIAGE_RETURN, if present) are consumed but not returned. Tolerant of fragmented reads, since the stream is consumed one byte at a time until the frame completes.- Parameters:
in- the input stream- Returns:
- the message text, or
nullon clean EOF / truncated frame (connection closed) - Throws:
IOException- if the underlying stream fails
-
