/** * Parses the string to an {@link 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 {@link Message#encode()} or {@link Message#toString()}. * * @param context HapiContext * @param s message string * @return unmodifiable message wrapper * @throws HL7Exception if parsing fails */ public static Message unmodifiableMessage(HapiContext context, String s) throws HL7Exception { Message msg = context.getGenericParser().parse(s); return new UnmodifiableMessage(msg, s); }
/** * Parses the string to an {@link 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 {@link Message#encode()} or {@link Message#toString()}. * * @param context HapiContext * @param s message string * @return unmodifiable message wrapper * @throws HL7Exception if parsing fails */ public static Message unmodifiableMessage(HapiContext context, String s) throws HL7Exception { Message msg = context.getGenericParser().parse(s); return new UnmodifiableMessage(msg, s); }
@SuppressWarnings("unchecked") private static <T extends Structure> T unmodifiableStructure(T structure) { if (isUnmodifiable(structure)) return structure; if (structure instanceof Message) return (T) new UnmodifiableMessage((Message) structure); if (structure instanceof Group) return (T) new UnmodifiableGroup((Group) structure); return (T) new UnmodifiableSegment((Segment) structure); }
/** * Returns an unmodifiable wrapper around the message. When accessing structures or types of the * {@link UnmodifiableMessage}, they will be unmodifiable as well. Copying these message parts into a regular * message should therefore be done using {@link ca.uhn.hl7v2.util.DeepCopy}. * * @param msg message to be wrapped * @return unmodifiable message wrapper */ public static Message unmodifiableMessage(Message msg) { return isUnmodifiable(msg) ? msg : new UnmodifiableMessage(msg); }
/** * Returns an unmodifiable wrapper around the message. When accessing structures or types of the * {@link UnmodifiableMessage}, they will be unmodifiable as well. Copying these message parts into a regular * message should therefore be done using {@link ca.uhn.hl7v2.util.DeepCopy}. * * @param msg message to be wrapped * @return unmodifiable message wrapper */ public static Message unmodifiableMessage(Message msg) { return isUnmodifiable(msg) ? msg : new UnmodifiableMessage(msg); }
@SuppressWarnings("unchecked") private static <T extends Structure> T unmodifiableStructure(T structure) { if (isUnmodifiable(structure)) return structure; if (structure instanceof Message) return (T) new UnmodifiableMessage((Message) structure); if (structure instanceof Group) return (T) new UnmodifiableGroup((Group) structure); return (T) new UnmodifiableSegment((Segment) structure); }