/** * Returns the Java charset for the HL7 charset name * @param hl7EncodingName * @return Java charset * @throws EncodingNotSupportedException if encoding name is unknown */ public static Charset getCharsetForHL7Encoding(String hl7EncodingName) throws EncodingNotSupportedException { if (hl7EncodingName == null || hl7EncodingName.length() == 0) return HL7Charsets.ASCII.charset; for (HL7Charsets encoding : HL7Charsets.values()) { if (hl7EncodingName.equals(encoding.hl7EncodingName)) return encoding.charset; } throw new EncodingNotSupportedException(hl7EncodingName); }
e.printStackTrace(); return; } catch (HL7Exception e) {
/** * Formats a Message object into an HL7 message string using the given encoding. * * @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. */ protected String doEncode(Message source, String encoding) throws HL7Exception { if (!encoding.equals("XML")) throw new EncodingNotSupportedException("XMLParser supports only XML encoding"); return encode(source); }
/** * Formats a Message object into an HL7 message string using the given encoding. * * @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. */ protected String doEncode(Message source, String encoding) throws HL7Exception { if (!encoding.equals("XML")) throw new EncodingNotSupportedException("XMLParser supports only XML encoding"); return encode(source); }
/** * Returns the Java charset for the HL7 charset name * @param hl7EncodingName * @return Java charset * @throws EncodingNotSupportedException if encoding name is unknown */ public static Charset getCharsetForHL7Encoding(String hl7EncodingName) throws EncodingNotSupportedException { if (hl7EncodingName == null || hl7EncodingName.length() == 0) return HL7Charsets.ASCII.charset; for (HL7Charsets encoding : HL7Charsets.values()) { if (hl7EncodingName.equals(encoding.hl7EncodingName)) return encoding.charset; } throw new EncodingNotSupportedException(hl7EncodingName); }
/** * Formats a Message object into an HL7 message string using the given encoding. * * @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. */ protected String doEncode(Message source, String encoding) throws HL7Exception, EncodingNotSupportedException { String ret = null; if (encoding == null) encoding = ""; // prevent null pointer exception if (encoding.equalsIgnoreCase("VB")) { ret = pipeParser.doEncode(source); } else if (encoding.equalsIgnoreCase("XML")) { ret = xmlParser.doEncode(source); } else { throw new EncodingNotSupportedException("The encoding " + encoding + " is not supported by " + this.getClass().getName()); } return ret; }
/** * Formats a Message object into an HL7 message string using the given encoding. * * @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. */ protected String doEncode(Message source, String encoding) throws HL7Exception, EncodingNotSupportedException { String ret = null; if (encoding == null) encoding = ""; // prevent null pointer exception if (encoding.equalsIgnoreCase("VB")) { ret = pipeParser.doEncode(source); } else if (encoding.equalsIgnoreCase("XML")) { ret = xmlParser.doEncode(source); } else { throw new EncodingNotSupportedException("The encoding " + encoding + " is not supported by " + this.getClass().getName()); } return ret; }
/** * Formats a Message object into an HL7 message string using the given * encoding. * @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. */ protected String doEncode(Message source, String encoding) throws HL7Exception, EncodingNotSupportedException { if (!this.supportsEncoding(encoding)) throw new EncodingNotSupportedException("This parser does not support the " + encoding + " encoding"); return encode(source); }
/** * Formats a Message object into an HL7 message string using the given * encoding. * @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. */ protected String doEncode(Message source, String encoding) throws HL7Exception, EncodingNotSupportedException { if (!this.supportsEncoding(encoding)) throw new EncodingNotSupportedException("This parser does not support the " + encoding + " encoding"); return encode(source); }
/** * Formats a Message object into an HL7 message string using the given * encoding. * * @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. */ protected String doEncode(Message source, String encoding) throws HL7Exception { if (!this.supportsEncoding(encoding)) throw new EncodingNotSupportedException("This parser does not support the " + encoding + " encoding"); return encode(source); }
/** * Formats a Message object into an HL7 message string using the given * encoding. * * @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. */ protected String doEncode(Message source, String encoding) throws HL7Exception { if (!this.supportsEncoding(encoding)) throw new EncodingNotSupportedException("This parser does not support the " + encoding + " encoding"); return encode(source); }
/** * 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; }
startOfMessage = message.substring(0, Math.min(message.length(), 50)); throw new EncodingNotSupportedException("Determine encoding for message. The following is the first 50 chars of the message for reference, although this may not be where the issue is: " + startOfMessage);
startOfMessage = message.substring(0, Math.min(message.length(), 50)); throw new EncodingNotSupportedException("Determine encoding for message. The following is the first 50 chars of the message for reference, although this may not be where the issue is: " + startOfMessage);