public DefaultHapiContext(ModelClassFactory modelClassFactory) { this(new ParserConfiguration(), ValidationContextFactory.defaultValidation(), modelClassFactory); }
boolean determineForcedEncodeIncludesTerserPath(String theTerserPath) { for (String next : getForcedEncode()) { if (next.startsWith(theTerserPath)) { return true; } } return false; }
/** * Checks if <code>Node</code> content should be kept as original (ie.: whitespaces won't be * removed) * * @param node The target <code>Node</code> * @return boolean <code>true</code> if whitespaces should not be removed from node content, * <code>false</code> otherwise */ protected boolean keepAsOriginal(Node node) { if (getParserConfiguration().isXmlDisableWhitespaceTrimmingOnAllNodes()) { return true; } return (node.getNodeName() != null) && getParserConfiguration().getXmlDisableWhitespaceTrimmingOnNodeNames().contains(node.getNodeName()); }
forceUpToFieldNum = parserConfig.determineForcedFieldNumForTerserPath(currentTerserPath); for (String nextPath : parserConfig.getForcedEncode()) { if (nextPath.startsWith(nextFieldTerserPath + "-")) { try { fieldText = parserConfig.getEscaping().unescape(fieldText, encodingChars); result.append(fieldText); if (j < reps.length - 1)
throw new IllegalArgumentException("Expected OBX segment, but was: " + segment.getName()); String defaultOBX2Type = parserConfiguration.getDefaultObx2Type(); if (defaultOBX2Type == null) { defaultOBX2Type = System.getProperty(DEFAULT_OBX2_TYPE_PROP); String invalidOBX2Type = parserConfiguration.getInvalidObx2Type(); if (invalidOBX2Type == null) { invalidOBX2Type = System.getProperty(INVALID_OBX2_TYPE_PROP);
for (int j = 1; j <= Terser.numSubComponents(source, i); j++) { Primitive p = Terser.getPrimitive(source, i, j); comp.append(encodePrimitive(p, parserConfig.getEscaping(), encodingChars)); comp.append(encodingChars.getSubcomponentSeparator()); for (String nextPath : parserConfig.getForcedEncode()) { if (nextPath.startsWith(currentTerserPath + "-") && nextPath.length() > currentTerserPath.length()) { int endOfFieldDef = nextPath.indexOf('-', currentTerserPath.length());
boolean encodeEmptySegments = parserConfiguration.determineForcedEncodeIncludesTerserPath(nextTerserPath); String segString = encode((Segment) rep, encodingChars, parserConfiguration, nextTerserPath); if (segString.length() >= 4 || encodeEmptySegments) { if (firstMandatorySegmentName != null && !haveHadMandatorySegment && !haveHadSegmentBeforeMandatorySegment && haveEncounteredContent && parserConfiguration.isEncodeEmptyMandatorySegments()) { return firstMandatorySegmentName.substring(0, 3) + encodingChars.getFieldSeparator() + SEGMENT_DELIMITER + result; } else {
/** * Fills a field with values from an unparsed string representing the field. * * @param destinationField * the field Type * @param data * the field string (including all components and subcomponents; * not including field delimiters) * @param encodingCharacters * the encoding characters used in the message */ @Override public void parse(Type destinationField, String data, EncodingCharacters encodingCharacters) throws HL7Exception { String[] components = split(data, String.valueOf(encodingCharacters.getComponentSeparator())); for (int i = 0; i < components.length; i++) { String[] subcomponents = split(components[i], String.valueOf(encodingCharacters.getSubcomponentSeparator())); for (int j = 0; j < subcomponents.length; j++) { String val = subcomponents[j]; if (val != null) { val = getParserConfiguration().getEscaping().unescape(val, encodingCharacters); } Terser.getPrimitive(destinationField, i + 1, j + 1).setValue(val); } } }
Terser.set(msh, 9, 0, 1, 1, messageCode); Terser.set(msh, 9, 0, 2, 1, messageTriggerEvent); Terser.set(msh, 10, 0, 1, 1, getParser().getParserConfiguration().getIdGenerator().getID()); Terser.set(msh, 11, 0, 1, 1, processingId); Terser.set(msh, 12, 0, 1, 1, getVersion());
/** * Sets the <i>keepAsOriginalNodes<i> * * @deprecated Use {@link ParserConfiguration#getXmlDisableWhitespaceTrimmingOnNodeNames()} instead */ @Deprecated public String[] getKeepAsOriginalNodes() { return getParserConfiguration().getXmlDisableWhitespaceTrimmingOnNodeNames().toArray(new String[getParserConfiguration().getXmlDisableWhitespaceTrimmingOnNodeNames().size()]); }
Group parentStructure; switch (myMessage.getParser().getParserConfiguration().getUnexpectedSegmentBehaviour()) { case ADD_INLINE: default:
forceUpToFieldNum = parserConfig.determineForcedFieldNumForTerserPath(currentTerserPath); for (String nextPath : parserConfig.getForcedEncode()) { if (nextPath.startsWith(nextFieldTerserPath + "-")) { try { fieldText = parserConfig.getEscaping().unescape(fieldText, encodingChars); result.append(fieldText); if (j < reps.length - 1)
throw new IllegalArgumentException("Expected OBX segment, but was: " + segment.getName()); String defaultOBX2Type = parserConfiguration.getDefaultObx2Type(); if (defaultOBX2Type == null) { defaultOBX2Type = System.getProperty(DEFAULT_OBX2_TYPE_PROP); String invalidOBX2Type = parserConfiguration.getInvalidObx2Type(); if (invalidOBX2Type == null) { invalidOBX2Type = System.getProperty(INVALID_OBX2_TYPE_PROP);
for (int j = 1; j <= Terser.numSubComponents(source, i); j++) { Primitive p = Terser.getPrimitive(source, i, j); comp.append(encodePrimitive(p, parserConfig.getEscaping(), encodingChars)); comp.append(encodingChars.getSubcomponentSeparator()); for (String nextPath : parserConfig.getForcedEncode()) { if (nextPath.startsWith(currentTerserPath + "-") && nextPath.length() > currentTerserPath.length()) { int endOfFieldDef = nextPath.indexOf('-', currentTerserPath.length());
boolean encodeEmptySegments = parserConfiguration.determineForcedEncodeIncludesTerserPath(nextTerserPath); String segString = encode((Segment) rep, encodingChars, parserConfiguration, nextTerserPath); if (segString.length() >= 4 || encodeEmptySegments) { if (firstMandatorySegmentName != null && !haveHadMandatorySegment && !haveHadSegmentBeforeMandatorySegment && haveEncounteredContent && parserConfiguration.isEncodeEmptyMandatorySegments()) { return firstMandatorySegmentName.substring(0, 3) + encodingChars.getFieldSeparator() + SEGMENT_DELIMITER + result; } else {
/** * Fills a field with values from an unparsed string representing the field. * * @param destinationField * the field Type * @param data * the field string (including all components and subcomponents; * not including field delimiters) * @param encodingCharacters * the encoding characters used in the message */ @Override public void parse(Type destinationField, String data, EncodingCharacters encodingCharacters) throws HL7Exception { String[] components = split(data, String.valueOf(encodingCharacters.getComponentSeparator())); for (int i = 0; i < components.length; i++) { String[] subcomponents = split(components[i], String.valueOf(encodingCharacters.getSubcomponentSeparator())); for (int j = 0; j < subcomponents.length; j++) { String val = subcomponents[j]; if (val != null) { val = getParserConfiguration().getEscaping().unescape(val, encodingCharacters); } Terser.getPrimitive(destinationField, i + 1, j + 1).setValue(val); } } }
Terser.set(msh, 9, 0, 1, 1, messageCode); Terser.set(msh, 9, 0, 2, 1, messageTriggerEvent); Terser.set(msh, 10, 0, 1, 1, getParser().getParserConfiguration().getIdGenerator().getID()); Terser.set(msh, 11, 0, 1, 1, processingId); Terser.set(msh, 12, 0, 1, 1, getVersion());
/** * Sets the <i>keepAsOriginalNodes<i> * * @deprecated Use {@link ParserConfiguration#getXmlDisableWhitespaceTrimmingOnNodeNames()} instead */ @Deprecated public String[] getKeepAsOriginalNodes() { return getParserConfiguration().getXmlDisableWhitespaceTrimmingOnNodeNames().toArray(new String[getParserConfiguration().getXmlDisableWhitespaceTrimmingOnNodeNames().size()]); }
Group parentStructure; switch (myMessage.getParser().getParserConfiguration().getUnexpectedSegmentBehaviour()) { case ADD_INLINE: default:
/** * Checks if <code>Node</code> content should be kept as original (ie.: whitespaces won't be * removed) * * @param node The target <code>Node</code> * @return boolean <code>true</code> if whitespaces should not be removed from node content, * <code>false</code> otherwise */ protected boolean keepAsOriginal(Node node) { if (getParserConfiguration().isXmlDisableWhitespaceTrimmingOnAllNodes()) { return true; } return (node.getNodeName() != null) && getParserConfiguration().getXmlDisableWhitespaceTrimmingOnNodeNames().contains(node.getNodeName()); }