/** * Formats a Message object into an HL7 message string using the given encoding. * * @param source a Message object from which to construct an encoded message string * @param encoding the name of the HL7 encoding to use (eg "XML"; most implementations support * only one encoding) * @return the encoded message * @throws HL7Exception if the data fields in the message do not permit encoding (e.g. required * fields are null) * @throws EncodingNotSupportedException if the requested encoding is not supported by this * parser. */ public String encode(Message source, String encoding) throws HL7Exception { assertMessageValidates(source); String result = doEncode(source, encoding); assertMessageValidates(result, encoding, source.getVersion()); return result; }
/** * Formats a Message object into an HL7 message string using the given encoding. * * @param source a Message object from which to construct an encoded message string * @param encoding the name of the HL7 encoding to use (eg "XML"; most implementations support * only one encoding) * @return the encoded message * @throws HL7Exception if the data fields in the message do not permit encoding (e.g. required * fields are null) * @throws EncodingNotSupportedException if the requested encoding is not supported by this * parser. */ public String encode(Message source, String encoding) throws HL7Exception { assertMessageValidates(source); String result = doEncode(source, encoding); assertMessageValidates(result, encoding, source.getVersion()); return result; }
/** * Formats a Message object into an HL7 message string using this parser's default encoding. * * @param source a Message object from which to construct an encoded message string * @return the encoded message * @throws HL7Exception if the data fields in the message do not permit encoding (e.g. required * fields are null) */ public String encode(Message source) throws HL7Exception { assertMessageValidates(source); String result = doEncode(source); assertMessageValidates(result, getDefaultEncoding(), source.getVersion()); return result; }
/** * Formats a Message object into an HL7 message string using this parser's default encoding. * * @param source a Message object from which to construct an encoded message string * @return the encoded message * @throws HL7Exception if the data fields in the message do not permit encoding (e.g. required * fields are null) */ public String encode(Message source) throws HL7Exception { assertMessageValidates(source); String result = doEncode(source); assertMessageValidates(result, getDefaultEncoding(), source.getVersion()); return result; }
/** * Parse a message using a specific model package instead of the default, using * {@link ModelClassFactory#getMessageClassInASpecificPackage(String, String, boolean, String)} * . * * <b>WARNING: This method is only implemented in some parser implementations</b>. Currently it * will only work with the PipeParser parser implementation. Use with caution. * * @param message message string * @param packageName name of the package of the models * @return parsed message * @throws HL7Exception if an error occurred while parsing */ public Message parseForSpecificPackage(String message, String packageName) throws HL7Exception { String encoding = getEncoding(message); if (!supportsEncoding(encoding)) { throw new EncodingNotSupportedException("Can't parse message beginning " + message.substring(0, Math.min(message.length(), 50))); } String version = getVersion(message); assertVersionExists(version); assertMessageValidates(message, encoding, version); Message result = doParseForSpecificPackage(message, version, packageName); assertMessageValidates(result); result.setParser(this); return result; }
/** * Parse a message using a specific model package instead of the default, using * {@link ModelClassFactory#getMessageClassInASpecificPackage(String, String, boolean, String)} * . * * <b>WARNING: This method is only implemented in some parser implementations</b>. Currently it * will only work with the PipeParser parser implementation. Use with caution. * * @param message message string * @param packageName name of the package of the models * @return parsed message * @throws HL7Exception if an error occurred while parsing */ public Message parseForSpecificPackage(String message, String packageName) throws HL7Exception { String encoding = getEncoding(message); if (!supportsEncoding(encoding)) { throw new EncodingNotSupportedException("Can't parse message beginning " + message.substring(0, Math.min(message.length(), 50))); } String version = getVersion(message); assertVersionExists(version); assertMessageValidates(message, encoding, version); Message result = doParseForSpecificPackage(message, version, packageName); assertMessageValidates(result); result.setParser(this); return result; }
assertMessageValidates(message, encoding, version); Message result = doParse(message, version); assertMessageValidates(result);
assertMessageValidates(message, encoding, version); Message result = doParse(message, version); assertMessageValidates(result);