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); }
/** * Returns the datatype and attempts to pipe-encode it. For example, a string implementation * might return "ST[Value^Value2]". This is only intended for logging/debugging purposes. */ static String toString(Type theType) { StringBuilder b = new StringBuilder(); b.append(theType.getClass().getSimpleName()); b.append("["); b.append(PipeParser.encode(theType, EncodingCharacters.defaultInstance())); b.append("]"); return b.toString(); }
/** * Returns the datatype and attempts to pipe-encode it. For example, a string implementation * might return "ST[Value^Value2]". This is only intended for logging/debugging purposes. */ static String toString(Type theType) { StringBuilder b = new StringBuilder(); b.append(theType.getClass().getSimpleName()); b.append("["); b.append(PipeParser.encode(theType, EncodingCharacters.defaultInstance())); b.append("]"); return b.toString(); }