/** * Returns an instance of encoding characters with the standard ER7 encoding characters * defined: |^~\& * * @return a default instance of encoding characters */ public static EncodingCharacters defaultInstance() { return new EncodingCharacters('|', null); }
public HapiField(final Type type) { this.value = PipeParser.encode(type, EncodingCharacters.defaultInstance()); final List<HL7Component> componentList = new ArrayList<>(); if (type instanceof Composite) { final Composite composite = (Composite) type; for (final Type component : composite.getComponents()) { componentList.add(new HapiField(component)); } } final ExtraComponents extra = type.getExtraComponents(); if (extra != null && extra.numComponents() > 0) { final String singleFieldValue; if (type instanceof Primitive) { singleFieldValue = ((Primitive) type).getValue(); } else { singleFieldValue = this.value; } componentList.add(new SingleValueField(singleFieldValue)); for (int i = 0; i < extra.numComponents(); i++) { componentList.add(new HapiField(extra.getComponent(i))); } } this.components = Collections.unmodifiableList(componentList); }
/** @see java.lang.Object#hashCode */ public int hashCode() { return 7 * (int) this.getComponentSeparator() * (int) this.getEscapeCharacter() * (int) this.getFieldSeparator() * (int) this.getRepetitionSeparator() * (int) this.getSubcomponentSeparator() * (int) this.getTruncationCharacter(); }
/** copies contents of "other" */ public EncodingCharacters(EncodingCharacters other) { this.fieldSep = other.getFieldSeparator(); this.encChars = new char[5]; setComponentSeparator(other.getComponentSeparator()); setRepetitionSeparator(other.getRepetitionSeparator()); setEscapeCharacter(other.getEscapeCharacter()); setSubcomponentSeparator(other.getSubcomponentSeparator()); setTruncationCharacter(other.getTruncationCharacter()); }
encodingChars.setFieldSeparator(segment.charAt(3)); List<Integer> nodeKey = new ArrayList<Integer>(); nodeKey.add(new Integer(0)); handler.putDatum(nodeKey, String.valueOf(encodingChars.getFieldSeparator())); encodingChars.setComponentSeparator(segment.charAt(4)); encodingChars.setRepetitionSeparator(segment.charAt(5)); encodingChars.setEscapeCharacter(segment.charAt(6)); encodingChars.setSubcomponentSeparator(segment.charAt(7)); nodeKey.set(0, new Integer(1)); handler.putDatum(nodeKey, encodingChars.toString()); if(segment.charAt(8) == encodingChars.getFieldSeparator()) { ret = true;
/** * Encodes the given Type, using the given encoding characters. * It is assumed that the Type represents a complete field rather than a component. */ public static String encode(Type source, EncodingCharacters encodingChars) { StringBuffer field = new StringBuffer(); for (int i = 1; i <= Terser.numComponents(source); i++) { StringBuffer comp = new StringBuffer(); for (int j = 1; j <= Terser.numSubComponents(source, i); j++) { Primitive p = Terser.getPrimitive(source, i, j); comp.append(encodePrimitive(p, encodingChars)); comp.append(encodingChars.getSubcomponentSeparator()); } field.append(stripExtraDelimiters(comp.toString(), encodingChars.getSubcomponentSeparator())); field.append(encodingChars.getComponentSeparator()); } return stripExtraDelimiters(field.toString(), encodingChars.getComponentSeparator()); //return encode(source, encodingChars, false); }
setComponentSeparator('^'); setRepetitionSeparator('~'); setEscapeCharacter('\\'); setSubcomponentSeparator('&'); setTruncationCharacter('#'); } else { encodingCharacters.getChars(0, 4, this.encChars, 0); char extraChar = encodingCharacters.charAt(4); if (extraChar != fieldSeparator) { setTruncationCharacter(extraChar);
public static String encode(Segment source, EncodingCharacters encodingChars) { StringBuffer result = new StringBuffer(); result.append(source.getName()); result.append(encodingChars.getFieldSeparator()); result.append(fieldText); if (j < reps.length - 1) result.append(encodingChars.getRepetitionSeparator()); log.error("Error while encoding segment: ", e); result.append(encodingChars.getFieldSeparator()); return stripExtraDelimiters(result.toString(), encodingChars.getFieldSeparator());
try { String[] fields = split(message.substring(0, Math.max(message.indexOf(segDelim), message.length())), String.valueOf(ec.getFieldSeparator())); wholeFieldNine = fields[8]; String[] comps = split(wholeFieldNine, String.valueOf(ec.getComponentSeparator())); if (comps.length >= 3) { messageStructure = comps[2];
EncodingCharacters encodingCharacters = EncodingCharacters.getInstance(getMessage()); char subc = encodingCharacters.getSubcomponentSeparator(); char cmpc = encodingCharacters.getComponentSeparator();
/** * {@inheritDoc } */ public String encode() throws HL7Exception { return getMessage().getParser().doEncode(this, EncodingCharacters.getInstance(getMessage())); }
&& ESCAPE_NODENAME.equals(child.getLocalName())) { assertNamespaceURI(child.getNamespaceURI()); EncodingCharacters ec = EncodingCharacters.getInstance(datatypeObject .getMessage()); Element elem = (Element) child; String attr = elem.getAttribute(ESCAPE_ATTRNAME).trim(); if (attr.length() > 0) { builder.append(ec.getEscapeCharacter()).append(attr) .append(ec.getEscapeCharacter());
for (Type stype : subComponentsInFirstField) { if (firstComponentValue.length() != 0) { char subComponentSeparator = EncodingCharacters.getInstance(segment.getMessage()).getSubcomponentSeparator(); firstComponentValue.append(subComponentSeparator);
/** * Tests for extra components (i.e. any not defined in the profile) */ protected List<ValidationException> checkUndefinedComponents(Composite comp, int numInProfile) { List<ValidationException> exList = new ArrayList<>(); StringBuilder extra = new StringBuilder(); for (int i = numInProfile; i < comp.getComponents().length; i++) { try { String s = comp.getComponent(i).encode(); if (s.length() > 0) { extra.append(s).append(enc.getComponentSeparator()); } } catch (HL7Exception de) { exList.add(new ValidationException(de)); } } profileViolatedWhen(extra.toString().length() > 0, exList, COMPONENT_NOT_DEFINED_IN_PROFILE, extra.toString()); return exList; }
parseThisSegment = maskIt.next().startsWith(segmentIdAsDatumPath); if(parseThisSegment && (segment.charAt(3) == encodingChars.getFieldSeparator())) { ER7SegmentHandler handler = new ER7SegmentHandler(); handler.m_props = props;
char escapeChar = encChars.getEscapeCharacter(); boolean foundEscapeChar = false; for (int i = 0; i < text.length(); i++) {
/** copies contents of "other" */ public EncodingCharacters(EncodingCharacters other) { this.fieldSep = other.getFieldSeparator(); this.encChars = new char[5]; setComponentSeparator(other.getComponentSeparator()); setRepetitionSeparator(other.getRepetitionSeparator()); setEscapeCharacter(other.getEscapeCharacter()); setSubcomponentSeparator(other.getSubcomponentSeparator()); setTruncationCharacter(other.getTruncationCharacter()); }
encodingChars.setFieldSeparator(segment.charAt(3)); List<Integer> nodeKey = new ArrayList<Integer>(); nodeKey.add(new Integer(0)); handler.putDatum(nodeKey, String.valueOf(encodingChars.getFieldSeparator())); encodingChars.setComponentSeparator(segment.charAt(4)); encodingChars.setRepetitionSeparator(segment.charAt(5)); encodingChars.setEscapeCharacter(segment.charAt(6)); encodingChars.setSubcomponentSeparator(segment.charAt(7)); nodeKey.set(0, new Integer(1)); handler.putDatum(nodeKey, encodingChars.toString()); if(segment.charAt(8) == encodingChars.getFieldSeparator()) { ret = true;
/** * Encodes the given Type, using the given encoding characters. * It is assumed that the Type represents a complete field rather than a component. */ public static String encode(Type source, EncodingCharacters encodingChars) { StringBuffer field = new StringBuffer(); for (int i = 1; i <= Terser.numComponents(source); i++) { StringBuffer comp = new StringBuffer(); for (int j = 1; j <= Terser.numSubComponents(source, i); j++) { Primitive p = Terser.getPrimitive(source, i, j); comp.append(encodePrimitive(p, encodingChars)); comp.append(encodingChars.getSubcomponentSeparator()); } field.append(stripExtraDelimiters(comp.toString(), encodingChars.getSubcomponentSeparator())); field.append(encodingChars.getComponentSeparator()); } return stripExtraDelimiters(field.toString(), encodingChars.getComponentSeparator()); //return encode(source, encodingChars, false); }
setComponentSeparator('^'); setRepetitionSeparator('~'); setEscapeCharacter('\\'); setSubcomponentSeparator('&'); setTruncationCharacter('#'); } else { encodingCharacters.getChars(0, 4, this.encChars, 0); char extraChar = encodingCharacters.charAt(4); if (extraChar != fieldSeparator) { setTruncationCharacter(extraChar);