/** * Returns true if the message is ER7 (pipe-and-hat) encoded * * @param theMessage message to be examined * @return true if message is ER7-encoded */ public static boolean isEr7Encoded(String theMessage) { try { assertEr7Encoded(theMessage); return true; } catch (Exception e) { return false; } }
/** * Returns true if the message is XML encoded. Note that this * message does not perform a very robust check, and does not * validate for well-formedness. It is only intended to perform * a simple check for XML vs. ER7 messages. * * @param theMessage message to be examined * @return true if message is XML-encoded */ public static boolean isXmlEncoded(String theMessage) { try { assertXmlEncoded(theMessage); return true; } catch (Exception e) { return false; } }
/** * Gets selected fields from a message, as with String[] arg version but * using DatumPaths. */ private static String[] getFields(String theMessageText, DatumPath[] thePaths) throws HL7Exception { String[] fields = new String[thePaths.length]; Properties props = new Properties(); List<DatumPath> mask = Arrays.asList(thePaths); boolean OK = false; if (EncodingDetector.isEr7Encoded(theMessageText)) { OK = ER7.parseMessage(props, mask, theMessageText); } else if (EncodingDetector.isXmlEncoded(theMessageText)) { OK = XML.parseMessage(props, theMessageText, null); } else { throw new HL7Exception("Message encoding is not recognized"); } if (!OK) { throw new HL7Exception("Parse failed"); } for (int i = 0; i < fields.length; i++) { fields[i] = props.getProperty(thePaths[i].toString()); } return fields; }
/** * Returns a String representing the encoding of the given message, if the * encoding is recognized. For example if the given message appears to be * encoded using HL7 2.x XML rules then "XML" would be returned. If the * encoding is not recognized then null is returned. That this method * returns a specific encoding does not guarantee that the message is * correctly encoded (e.g. well formed XML) - just that it is not encoded * using any other encoding than the one returned. */ public String getEncoding(String message) { return EncodingDetector.isEr7Encoded(message) ? getDefaultEncoding() : null; }
/** * Returns a String representing the encoding of the given message, if the encoding is * recognized. For example if the given message appears to be encoded using HL7 2.x XML rules * then "XML" would be returned. If the encoding is not recognized then null is returned. That * this method returns a specific encoding does not guarantee that the message is correctly * encoded (e.g. well formed XML) - just that it is not encoded using any other encoding than * the one returned. Returns null if the encoding is not recognized. */ public String getEncoding(String message) { return EncodingDetector.isXmlEncoded(message) ? getDefaultEncoding() : null; }
/** * Gets selected fields from a message, as with String[] arg version but * using DatumPaths. */ private static String[] getFields(String theMessageText, DatumPath[] thePaths) throws HL7Exception { String[] fields = new String[thePaths.length]; Properties props = new Properties(); List<DatumPath> mask = Arrays.asList(thePaths); boolean OK = false; if (EncodingDetector.isEr7Encoded(theMessageText)) { OK = ER7.parseMessage(props, mask, theMessageText); } else if (EncodingDetector.isXmlEncoded(theMessageText)) { OK = XML.parseMessage(props, theMessageText, null); } else { throw new HL7Exception("Message encoding is not recognized"); } if (!OK) { throw new HL7Exception("Parse failed"); } for (int i = 0; i < fields.length; i++) { fields[i] = props.getProperty(thePaths[i].toString()); } return fields; }
/** * Returns a String representing the encoding of the given message, if the * encoding is recognized. For example if the given message appears to be * encoded using HL7 2.x XML rules then "XML" would be returned. If the * encoding is not recognized then null is returned. That this method * returns a specific encoding does not guarantee that the message is * correctly encoded (e.g. well formed XML) - just that it is not encoded * using any other encoding than the one returned. */ public String getEncoding(String message) { return EncodingDetector.isEr7Encoded(message) ? getDefaultEncoding() : null; }
/** * Returns a String representing the encoding of the given message, if the encoding is * recognized. For example if the given message appears to be encoded using HL7 2.x XML rules * then "XML" would be returned. If the encoding is not recognized then null is returned. That * this method returns a specific encoding does not guarantee that the message is correctly * encoded (e.g. well formed XML) - just that it is not encoded using any other encoding than * the one returned. Returns null if the encoding is not recognized. */ public String getEncoding(String message) { return EncodingDetector.isXmlEncoded(message) ? getDefaultEncoding() : null; }
/** * Returns true if the message is ER7 (pipe-and-hat) encoded * * @param theMessage message to be examined * @return true if message is ER7-encoded */ public static boolean isEr7Encoded(String theMessage) { try { assertEr7Encoded(theMessage); return true; } catch (Exception e) { return false; } }
/** * Returns true if the message is XML encoded. Note that this * message does not perform a very robust check, and does not * validate for well-formedness. It is only intended to perform * a simple check for XML vs. ER7 messages. * * @param theMessage message to be examined * @return true if message is XML-encoded */ public static boolean isXmlEncoded(String theMessage) { try { assertXmlEncoded(theMessage); return true; } catch (Exception e) { return false; } }