Class Hl7v2MarshalUtils

java.lang.Object
org.openehealth.ipf.platform.camel.ihe.hl7v2.Hl7v2MarshalUtils

public class Hl7v2MarshalUtils extends Object
Various helper methods for data transformation.
Author:
Dmytro Rud
  • Method Details

    • typeSupported

      public static boolean typeSupported(Object body)
      Determines whether the given object belongs to the predefined set of supported data types.
      Parameters:
      body - The object to check.
      Returns:
      true when the type of the object is supported by the HL7v2 adapter out-of-the-box, false otherwise.
    • convertBodyToString

      public static String convertBodyToString(Message message, String charsetName, boolean defragmentSegments) throws Exception
      Converts message contents to a String using the given character set (statically or in MSH-18) and replaces all '\n''s with '\r''s.

      If requested, segments will be defragmented as well.

      Parameters:
      message - Camel message
      charsetName - charset name
      Returns:
      string
      Throws:
      Exception
    • convertMessageToByteArray

      public static byte[] convertMessageToByteArray(Message message, String charsetName) throws Exception
      Converts Camel message to a Byte Array using the given character set (statically or in MSH-18). This is necessary before a HL7 message object or string is remotely transferred to have full control over the encoding.
      Parameters:
      message - Camel message
      charsetName - charset name
      Returns:
      byte array
      Throws:
      Exception
    • convertBodyToByteArray

      public static byte[] convertBodyToByteArray(Object body, String charsetName) throws Exception
      Converts HL7 object to a Byte Array using the given character set (statically or in MSH-18). This is necessary before a HL7 message object or string is remotely transferred to have full control over the encoding.
      Parameters:
      body - HL7 object
      charsetName - charset name
      Returns:
      byte array
      Throws:
      Exception
    • convertBodyToMessage

      public static Message convertBodyToMessage(Message message, String defaultCharsetName, Parser parser) throws Exception
      Converts the contents of the given Camel message to a Message. This is necessary when either a transferred HL7 message is unmarshalled or we need to access message details for further processing in interceptors.
      Parameters:
      message - Camel message to be converted.
      defaultCharsetName - default character set.
      parser - HL7 parser.
      Returns:
      a Message or null when it was impossible to get or create one.
      Throws:
      Exception