Class SegmentFinder

java.lang.Object
ca.uhn.hl7v2.util.MessageNavigator
ca.uhn.hl7v2.util.SegmentFinder

public class SegmentFinder extends MessageNavigator
A tool for getting segments by name within a message or part of a message.
Author:
Bryan Tripp
  • Constructor Details

    • SegmentFinder

      public SegmentFinder(Group root)
      Creates a new instance of SegmentFinder.
      Parameters:
      root - the scope of searches -- may be a whole message or only a branch
  • Method Details

    • findSegment

      public Segment findSegment(String namePattern, int rep) throws HL7Exception
      Returns the first segment with a name that matches the given pattern, in a depth-first search. Repeated searches are initiated from the location just AFTER where the last segment was found. Call reset() is this is not desired. Note: this means that the current location will not be found.
      Parameters:
      namePattern - the name of the segment to find. The wildcard * means any number of arbitrary characters; the wildcard ? one arbitrary character (eg "P*" or "*ID" or "???" or "P??" would match on PID).
      rep - the repetition of the segment to return
      Throws:
      HL7Exception
    • findGroup

      public Group findGroup(String namePattern, int rep) throws HL7Exception
      As findSegment(), but will only return a group.
      Throws:
      HL7Exception
    • getSegment

      public Segment getSegment(String namePattern, int rep) throws HL7Exception
      Returns the first segment with a name matching the given pattern that is a sibling of the structure at the current location. Other parts of the message are not searched (in contrast to findSegment). As a special case, if the pointer is at the root, the children of the root are searched.
      Parameters:
      namePattern - the name of the segment to get. The wildcad * means any number of arbitrary characters; the wildard ? one arbitrary character (eg "P*" or "*ID" or "???" or "P??" would match on PID).
      rep - the repetition of the segment to return
      Throws:
      HL7Exception
    • getGroup

      public Group getGroup(String namePattern, int rep) throws HL7Exception
      As getSegment() but will only return a group.
      Throws:
      HL7Exception