public class MessageIterator extends Object implements Iterator<Structure>
next()
for details on how
this is handled.
This implementation assumes that the first segment in each group is present
(as per HL7 rules). Specifically, when looking for a segment location, an
empty group that has a spot for the segment will be overlooked if there is
anything else before that spot. This may result in surprising (but sensible)
behaviour if a message is missing the first segment in a group.Modifier and Type | Class and Description |
---|---|
static class |
MessageIterator.Position
A structure position within a message.
|
Constructor and Description |
---|
MessageIterator(Message start,
IStructureDefinition startDefinition,
String direction,
boolean handleUnexpectedSegments)
Creates a new instance of MessageIterator
|
Modifier and Type | Method and Description |
---|---|
String |
getDirection() |
int |
getNextIndexWithinParent()
Must be called after
next() |
boolean |
hasNext()
Returns true if another object exists in the iteration sequence.
|
Structure |
next()
Returns the next node in the message.
|
void |
remove()
Not supported
|
void |
setDirection(String direction) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEachRemaining
public MessageIterator(Message start, IStructureDefinition startDefinition, String direction, boolean handleUnexpectedSegments)
public boolean hasNext()
public Structure next()
Returns the next node in the message. Sometimes the next node is ambiguous. For example at the end of a repeating group, the next node may be the first segment in the next repetition of the group, or the next sibling, or an undeclared segment locally added to the group's end. Cases like this are disambiguated using getDirection(), which returns the name of the structure that we are "iterating towards". Usually we are "iterating towards" a segment of a certain name because we have a segment string that we would like to parse into that node. Here are the rules:
public String getDirection()
public void setDirection(String direction)
public int getNextIndexWithinParent()
next()
Copyright © 2001–2017 University Health Network. All rights reserved.