Package ca.uhn.hl7v2.util
Class SegmentFinder
java.lang.Object
ca.uhn.hl7v2.util.MessageNavigator
ca.uhn.hl7v2.util.SegmentFinder
A tool for getting segments by name within a message or part of a message.
- Author:
- Bryan Tripp
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAs findSegment(), but will only return a group.findSegment(String namePattern, int rep) Returns the first segment with a name that matches the given pattern, in a depth-first search.As getSegment() but will only return a group.getSegment(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
-
Constructor Details
-
SegmentFinder
Creates a new instance of SegmentFinder.- Parameters:
root- the scope of searches -- may be a whole message or only a branch
-
-
Method Details
-
findSegment
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
As findSegment(), but will only return a group.- Throws:
HL7Exception
-
getSegment
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
As getSegment() but will only return a group.- Throws:
HL7Exception
-