ca.uhn.hl7v2.util
Class SegmentFinder

java.lang.Object
  extended by ca.uhn.hl7v2.util.MessageNavigator
      extended by 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 Summary
SegmentFinder(Group root)
          Creates a new instance of SegmentFinder.
 
Method Summary
 Group findGroup(java.lang.String namePattern, int rep)
          As findSegment(), but will only return a group.
 Segment findSegment(java.lang.String namePattern, int rep)
          Returns the first segment with a name that matches the given pattern, in a depth-first search.
 Group getGroup(java.lang.String namePattern, int rep)
          As getSegment() but will only return a group.
 Segment getSegment(java.lang.String namePattern, int rep)
          Returns the first segment with a name matching the given pattern that is a sibling of the structure at the current location.
 
Methods inherited from class ca.uhn.hl7v2.util.MessageNavigator
drillDown, drillDown, drillUp, getCurrentChildReps, getCurrentGroup, getCurrentStructure, getRoot, hasNextChild, iterate, nextChild, reset, toChild
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

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 Detail

findSegment

public Segment findSegment(java.lang.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:
segmentName - the name of the segment to find. 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

findGroup

public Group findGroup(java.lang.String namePattern,
                       int rep)
                throws HL7Exception
As findSegment(), but will only return a group.

Throws:
HL7Exception

getSegment

public Segment getSegment(java.lang.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:
segmentName - 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(java.lang.String namePattern,
                      int rep)
               throws HL7Exception
As getSegment() but will only return a group.

Throws:
HL7Exception


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