Class FragmentationUtils


  • public class FragmentationUtils
    extends Object
    Helper methods for segment fragmentation, unsolicited request fragmentation, and interactive response continuation in HL7v2-based transactions.
    Author:
    Dmytro Rud
    • Constructor Detail

      • FragmentationUtils

        public FragmentationUtils()
    • Method Detail

      • splitString

        public static List<String> splitString​(String s,
                                               char c)
        Splits the given String at occurrences of the given character.
      • ensureMaximalSegmentsLength

        public static String ensureMaximalSegmentsLength​(String message,
                                                         int maxLength)
        Ensures that all segments in the given HL7 message string representation are not longer than the given value (-1 means positive infinity). If needed, splits long segments by means of ADD segments, as described in paragraph 2.10.2.1 of the HL7 v.2.5 specification.

        '\r' characters are not considered in the length computation.

        Parameters:
        message - string representation of the source HL7 message.
        maxLength - maximal segment length, must be either -1 or greater than 4.
        Returns:
        string representation of a semantically equivalent message, whose segments are not longer than the given value.
      • appendSplitSegment

        public static void appendSplitSegment​(StringBuilder sb,
                                              List<String> fields,
                                              char fieldSeparator)
        Appends a split segment to the given StringBuilder.
      • appendSegments

        public static void appendSegments​(StringBuilder sb,
                                          List<String> segments,
                                          int startIndex,
                                          int endIndex)
        Appends segments from startIndex to endIndex-1 to the given StringBuilder.
      • joinSegments

        public static CharSequence joinSegments​(List<String> segments,
                                                int startIndex,
                                                int endIndex)
        Joins segments from startIndex to endIndex-1.
      • keyString

        public static String keyString​(String... pieces)
        Creates a single key string from the given key pieces.
      • uniqueId

        public static String uniqueId()
        Returns an unique value which can be used, for example, as an HL7v2 message ID.