/** * Sets the string value of the Primitive at the given location. * * @param segment the segment from which to get the primitive * @param field the field number (indexed from 1) * @param rep the field repetition (indexed from 0) * @param component the component number (indexed from 1, use 1 for primitive field) * @param subcomponent the subcomponent number (indexed from 1, use 1 for primitive component) * @param value value to be set * @throws HL7Exception if the value could not be set */ public static void set(Segment segment, int field, int rep, int component, int subcomponent, String value) throws HL7Exception { if (segment == null) { throw new NullPointerException("segment may not be null"); } if (rep < 0) { throw new IllegalArgumentException("rep must not be negative"); } if (component < 1) { throw new IllegalArgumentException( "component must be 1 or more (note that this parameter is 1-indexed, not 0-indexed)"); } if (subcomponent < 1) { throw new IllegalArgumentException( "subcomponent must be 1 or more (note that this parameter is 1-indexed, not 0-indexed)"); } Primitive prim = getPrimitive(segment, field, rep, component, subcomponent); prim.setValue(value); }
/** * Sets the string value of the Primitive at the given location. * * @param segment the segment from which to get the primitive * @param field the field number (indexed from 1) * @param rep the field repetition (indexed from 0) * @param component the component number (indexed from 1, use 1 for primitive field) * @param subcomponent the subcomponent number (indexed from 1, use 1 for primitive component) * @param value value to be set * @throws HL7Exception if the value could not be set */ public static void set(Segment segment, int field, int rep, int component, int subcomponent, String value) throws HL7Exception { if (segment == null) { throw new NullPointerException("segment may not be null"); } if (rep < 0) { throw new IllegalArgumentException("rep must not be negative"); } if (component < 1) { throw new IllegalArgumentException( "component must be 1 or more (note that this parameter is 1-indexed, not 0-indexed)"); } if (subcomponent < 1) { throw new IllegalArgumentException( "subcomponent must be 1 or more (note that this parameter is 1-indexed, not 0-indexed)"); } Primitive prim = getPrimitive(segment, field, rep, component, subcomponent); prim.setValue(value); }
datatypeObject.setValue(builder.toString());
datatypeObject.setValue(builder.toString());
/** This method validates the <code>String</code> value passed in to be no greater then the * maximum allowable length for the extending class. If the <code>String</code> value is valid, this * method will set the underlying HAPI class's value. If the data passed in is invalid for the given * data type, a ConfDataException is thrown. * @throws ConformaceException * @param value the value of the Data Type */ protected void setValue(java.lang.String value) throws ConfDataException { if ((this.getMaxLength() > 0) && (value.length() > this.getMaxLength())) { throw new ConfDataException("DataType length exceeds the Maximum allowable length"); } try { this.hapiPrimitive.setValue(value); } catch (DataTypeException e) { throw new ConfDataException("Invalid Data Populated"); } }
/** This method validates the <code>String</code> value passed in to be no greater then the * maximum allowable length for the extending class. If the <code>String</code> value is valid, this * method will set the underlying HAPI class's value. If the data passed in is invalid for the given * data type, a ConfDataException is thrown. * @throws ConformaceException * @param value the value of the Data Type */ protected void setValue(java.lang.String value) throws ConfDataException { if ((this.getMaxLength() > 0) && (value.length() > this.getMaxLength())) { throw new ConfDataException("DataType length exceeds the Maximum allowable length"); } try { this.hapiPrimitive.setValue(value); } catch (DataTypeException e) { throw new ConfDataException("Invalid Data Populated"); } }
/** * 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 */ 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 = Escape.unescape(val, encodingCharacters); } Terser.getPrimitive(destinationField, i+1, j+1).setValue(val); } } }
/** * 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 */ 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 = Escape.unescape(val, encodingCharacters); } Terser.getPrimitive(destinationField, i+1, j+1).setValue(val); } } }
private static void setFirstComponentPrimitiveValue(Type theFirstComponent, String theValue) throws DataTypeException { if (theFirstComponent instanceof Varies) { Varies firstComponentVaries = (Varies)theFirstComponent; if (((Varies) theFirstComponent).getData() instanceof Composite) { Type[] subComponents = ((Composite)firstComponentVaries.getData()).getComponents(); setFirstComponentPrimitiveValue(subComponents[0], theValue); for (int i = 1; i < subComponents.length; i++) { setFirstComponentPrimitiveValue(subComponents[i], ""); } } else { Primitive p = (Primitive) firstComponentVaries.getData(); p.setValue(theValue); } } else if (theFirstComponent instanceof Composite) { Type[] subComponents = ((Composite)theFirstComponent).getComponents(); setFirstComponentPrimitiveValue(subComponents[0], theValue); for (int i = 1; i < subComponents.length; i++) { setFirstComponentPrimitiveValue(subComponents[i], ""); } } else { ((Primitive)theFirstComponent).setValue(theValue); } }
/** * 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); } } }
/** * 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); } } }
private static void setFirstComponentPrimitiveValue(Type theFirstComponent, String theValue) throws DataTypeException { if (theFirstComponent instanceof Varies) { Varies firstComponentVaries = (Varies)theFirstComponent; if (((Varies) theFirstComponent).getData() instanceof Composite) { Type[] subComponents = ((Composite)firstComponentVaries.getData()).getComponents(); setFirstComponentPrimitiveValue(subComponents[0], theValue); for (int i = 1; i < subComponents.length; i++) { setFirstComponentPrimitiveValue(subComponents[i], ""); } } else { Primitive p = (Primitive) firstComponentVaries.getData(); p.setValue(theValue); } } else if (theFirstComponent instanceof Composite) { Type[] subComponents = ((Composite)theFirstComponent).getComponents(); setFirstComponentPrimitiveValue(subComponents[0], theValue); for (int i = 1; i < subComponents.length; i++) { setFirstComponentPrimitiveValue(subComponents[i], ""); } } else { ((Primitive)theFirstComponent).setValue(theValue); } }
/** * Copies data from the "from" Type into the "to" Type. Either Type may be * a Primitive, Composite, or Varies. If a Varies is provided, the operation is * performed on the result of calling its getData() method. A Primitive may be * copied into a Composite, in which case the value is copied into the first * component of the Composite. A Composite may be copied into a Primitive, * in which case the first component is copied. Given Composites with different * numbers of components, the first components are copied, up to the length * of the smaller one. * * @param from type to copy from * @param to type to copy to * @throws DataTypeException if the types are not compatible */ public static void copy(Type from, Type to) throws DataTypeException { for (int i = 1; i <= Terser.numComponents(from); i++) { for (int j = 1; j <= Terser.numSubComponents(from, i); j++) { String val = Terser.getPrimitive(from, i, j).getValue(); Terser.getPrimitive(to, i, j).setValue(val); } } }
/** * Copies data from the "from" Type into the "to" Type. Either Type may be * a Primitive, Composite, or Varies. If a Varies is provided, the operation is * performed on the result of calling its getData() method. A Primitive may be * copied into a Composite, in which case the value is copied into the first * component of the Composite. A Composite may be copied into a Primitive, * in which case the first component is copied. Given Composites with different * numbers of components, the first components are copied, up to the length * of the smaller one. * * @param from type to copy from * @param to type to copy to * @throws DataTypeException if the types are not compatible */ public static void copy(Type from, Type to) throws DataTypeException { for (int i = 1; i <= Terser.numComponents(from); i++) { for (int j = 1; j <= Terser.numSubComponents(from, i); j++) { String val = Terser.getPrimitive(from, i, j).getValue(); Terser.getPrimitive(to, i, j).setValue(val); } } }
Terser.getPrimitive(field, 1, 1).setValue(reps[j]); } else { parse(field, reps[j], encodingChars);
Terser.getPrimitive(field, 1, 1).setValue(reps[j]); } else { parse(field, reps[j], encodingChars);
Type field = destination.getField(i + fieldOffset, j); if (isMSH2) { Terser.getPrimitive(field, 1, 1).setValue(reps[j]); } else { parse(field, reps[j], encodingChars);
Type field = destination.getField(i + fieldOffset, j); if (isMSH2) { Terser.getPrimitive(field, 1, 1).setValue(reps[j]); } else { parse(field, reps[j], encodingChars);
if (defaultType != null) { LOG.debug("setting default {}-{} type to {}", new Object[] {segment.getName(), typeField, defaultType}); type.setValue(defaultType);
if (defaultType != null) { LOG.debug("setting default {}-{} type to {}", new Object[] {segment.getName(), typeField, defaultType}); type.setValue(defaultType);