ca.uhn.hl7v2.util

Class Terser

    • Constructor Summary

      Constructors 
      Constructor and Description
      Terser(Message message)
      Creates a new instance of Terser
    • Method Summary

      Methods 
      Modifier and Type Method and Description
      static String get(Segment segment, int field, int rep, int component, int subcomponent)
      Returns the string value of the Primitive at the given location.
      String get(String spec)
      Gets the string value of the field specified.
      SegmentFinder getFinder()
      Returns the segment finder used by this Terser.
      static int[] getIndices(String spec)
      Given a Terser path, returns an array containing field num, field rep, component, and subcomponent.
      static Primitive getPrimitive(Type type, int component, int subcomponent)
      Returns the Primitive object at the given location in the given field.
      Segment getSegment(String segSpec)
      Returns the segment specified in the given segment_path_spec.
      static int numComponents(Type type)
      Returns the number of components in the given type, i.e.
      static int numSubComponents(Type type, int component)
      Returns the number of sub-components in the specified component, i.e.
      static void set(Segment segment, int field, int rep, int component, int subcomponent, String value)
      Sets the string value of the Primitive at the given location.
      void set(String spec, String value)
      Sets the string value of the field specified.
    • Constructor Detail

      • Terser

        public Terser(Message message)
        Creates a new instance of Terser
    • Method Detail

      • get

        public static String get(Segment segment,
                 int field,
                 int rep,
                 int component,
                 int subcomponent)
                          throws HL7Exception
        Returns the string value of the Primitive at the given location.
        Parameters:
        segment - the segment from which to get the primitive
        field - the field number (indexed from 1)
        rep - the field repetition (indexed from 0)
        component - the component number (indexed from 1, use 1 for primitive field)
        subcomponent - the subcomponent number (indexed from 1, use 1 for primitive component)
        Throws:
        HL7Exception
      • set

        public static void set(Segment segment,
               int field,
               int rep,
               int component,
               int subcomponent,
               String value)
                        throws HL7Exception
        Sets the string value of the Primitive at the given location.
        Parameters:
        segment - the segment from which to get the primitive
        field - the field number (indexed from 1)
        rep - the field repetition (indexed from 0)
        component - the component number (indexed from 1, use 1 for primitive field)
        subcomponent - the subcomponent number (indexed from 1, use 1 for primitive component)
        Throws:
        HL7Exception
      • getPrimitive

        public static Primitive getPrimitive(Type type,
                             int component,
                             int subcomponent)
        Returns the Primitive object at the given location in the given field. It is intended that the given type be at the field level, although extra components will be added blindly if, for example, you provide a primitive subcomponent instead and specify component or subcomponent > 1
        Parameters:
        type - the type from which to get the primitive
        component - the component number (indexed from 1, use 1 for primitive field)
        subcomponent - the subcomponent number (indexed from 1, use 1 for primitive component)
      • get

        public String get(String spec)
                   throws HL7Exception

        Gets the string value of the field specified. See the class docs for syntax of the location spec.

        If a repetition is omitted for a repeating segment or field, the first rep is used. If the component or subcomponent is not specified for a composite field, the first component is used (this allows one to write code that will work with later versions of the HL7 standard).

        Throws:
        HL7Exception
      • getIndices

        public static int[] getIndices(String spec)
                                throws HL7Exception
        Given a Terser path, returns an array containing field num, field rep, component, and subcomponent.
        Throws:
        HL7Exception
      • numSubComponents

        public static int numSubComponents(Type type,
                           int component)
        Returns the number of sub-components in the specified component, i.e. the number of standard sub-components (e.g. 6 for CE) plus any extra components that that have been added at runtime.
        Parameters:
        component - numbered from 1
      • numComponents

        public static int numComponents(Type type)
        Returns the number of components in the given type, i.e. the number of standard components (e.g. 6 for CE) plus any extra components that have been added at runtime.
      • getFinder

        public SegmentFinder getFinder()
        Returns the segment finder used by this Terser. Navigating the finder will influence the behaviour of the Terser accordingly. Ie when the full path of the segment is not specified the segment will be sought beginning at the current location of the finder.

Copyright © 2001-2012 University Health Network. All Rights Reserved.