/** * Checks the encoding of the message using getEncoding(), and returns the corresponding parser * (either pipeParser or xmlParser). If the encoding is not recognized an HL7Exception is * thrown. */ private Parser getAppropriateParser(String message) throws HL7Exception { String encoding = getEncoding(message); if ("VB".equalsIgnoreCase(encoding)) return pipeParser; if ("XML".equalsIgnoreCase(encoding)) return xmlParser; throw new HL7Exception("Can't find appropriate parser - encoding not recognized"); }
/** * Checks the encoding of the message using getEncoding(), and returns the corresponding parser * (either pipeParser or xmlParser). If the encoding is not recognized an HL7Exception is * thrown. */ private Parser getAppropriateParser(String message) throws HL7Exception { String encoding = getEncoding(message); if ("VB".equalsIgnoreCase(encoding)) return pipeParser; if ("XML".equalsIgnoreCase(encoding)) return xmlParser; throw new HL7Exception("Can't find appropriate parser - encoding not recognized"); }
/** * Returns a "standardized" equivalent of the given message string. For delimited * messages, the returned value is the shortest string that has an equivalent * meaning in HL7. For XML-encoded messages, the returned value is equivalent XML output * using a standard pretty-print format. An automatic determination is made about whether * the given string is XML or ER7 (i.e. traditionally) encoded. * @param message an XML-encoded or ER7-encoded message string */ public static String standardize(String message) throws SAXException { String result = null; String encoding = parser.getEncoding(message); if (encoding.equals("XML")) { result = standardizeXML(message); } else { result = standardizeER7(message); } return result; }
/** * Returns a "standardized" equivalent of the given message string. For delimited * messages, the returned value is the shortest string that has an equivalent * meaning in HL7. For XML-encoded messages, the returned value is equivalent XML output * using a standard pretty-print format. An automatic determination is made about whether * the given string is XML or ER7 (i.e. traditionally) encoded. * @param message an XML-encoded or ER7-encoded message string */ public static String standardize(String message) throws SAXException { String result = null; String encoding = parser.getEncoding(message); if (encoding.equals("XML")) { result = standardizeXML(message); } else { result = standardizeER7(message); } return result; }
static Pair<String> standardize(String message1, String message2) throws HL7Exception { String encoding1 = parser.getEncoding(message1); String encoding2 = parser.getEncoding(message2); if (!encoding1.equals(encoding2)) { if (encoding1.equals("XML")) { message1 = safeER7Conversion(message1); } else { message2 = safeER7Conversion(message2); } } String std1, std2; try { std1 = standardize(message1); std2 = standardize(message2); } catch (SAXException e) { throw new HL7Exception("Equivalence check failed due to SAXException: " + e.getMessage()); } return new Pair<String>(std1, std2); }
static Pair<String> standardize(String message1, String message2) throws HL7Exception { String encoding1 = parser.getEncoding(message1); String encoding2 = parser.getEncoding(message2); if (!encoding1.equals(encoding2)) { if (encoding1.equals("XML")) { message1 = safeER7Conversion(message1); } else { message2 = safeER7Conversion(message2); } } String std1, std2; try { std1 = standardize(message1); std2 = standardize(message2); } catch (SAXException e) { throw new HL7Exception("Equivalence check failed due to SAXException: " + e.getMessage()); } return new Pair<String>(std1, std2); }