Class Unmodifiable

java.lang.Object
ca.uhn.hl7v2.model.Unmodifiable

public final class Unmodifiable extends Object
A static helper class that allows to obtain unmodifiable message wrappers, i.e. all modification to these wrappers result in an UnsupportedOperationException or IllegalArgumentException.

Note that these wrappers have no HL7-specific type information, e.g. an Unmodifiable.UnmodifiableMessage just implements Message but not some concrete event type. It is possible to use the Terser, generic Getter methods, message iterators or visitors. All structures or types returned by these methods will be unmodifiable as well.

Also note that the original message does not automatically become immutable.

  • Method Details

    • unmodifiableMessage

      public static Message unmodifiableMessage(Message msg)
      Returns an unmodifiable wrapper around the message. When accessing structures or types of the Unmodifiable.UnmodifiableMessage, they will be unmodifiable as well. Copying these message parts into a regular message should therefore be done using DeepCopy.
      Parameters:
      msg - message to be wrapped
      Returns:
      unmodifiable message wrapper
    • unmodifiableMessage

      public static Message unmodifiableMessage(HapiContext context, String s) throws HL7Exception
      Parses the string to an Unmodifiable.UnmodifiableMessage using the specific HapiContext. When accessing structures or types of the returned message, they will be unmodifiable as well. The returned message caches the original message string, which is returned when calling Message.encode() or Message#toString().
      Parameters:
      context - HapiContext
      s - message string
      Returns:
      unmodifiable message wrapper
      Throws:
      HL7Exception - if parsing fails
    • isUnmodifiable

      public static boolean isUnmodifiable(Object o)
      Returns true if the message instance (or a part thereof) is unmodifiable
      Parameters:
      o - something HAPI-related
      Returns:
      true if unmodifiable