/** * Sets the next location to the next sibling of the given * index. */ private void nextSibling(Position pos) { String[] names = pos.parent.getNames(); int i = 0; for (; i < names.length && !names[i].equals(pos.index.name); i++) {} String nextName = names[i+1]; this.next = new Position(pos.parent, nextName, 0); }
/** * Sets the next location to the next sibling of the given * index. */ private void nextSibling(Position pos) { String[] names = pos.parent.getNames(); int i = 0; for (; i < names.length && !names[i].equals(pos.index.name); i++) {} String nextName = names[i+1]; this.next = new Position(pos.parent, nextName, 0); }
/** * Returns true if another object exists in the iteration sequence. */ public boolean hasNext() { boolean has = true; if (next == null) { if (Group.class.isAssignableFrom(currentStructure.getClass())) { groupNext((Group) currentStructure); } else { Group parent = currentStructure.getParent(); Index i = getIndex(parent, currentStructure); Position currentPosition = new Position(parent, i); try { if (parent.isRepeating(i.name) && currentStructure.getName().equals(direction)) { nextRep(currentPosition); } else { has = nextPosition(currentPosition, this.direction, this.handleUnexpectedSegments); } } catch (HL7Exception e) { throw new Error("HL7Exception arising from bad index: " + e.getMessage()); } } } log.debug("MessageIterator.hasNext() in direction {}? {}", direction, has); return has; }
Position parentPos = new Position(grandparent, getIndex(grandparent, pos.parent)); matchExists = matchExistsAfterPosition(parentPos, name, firstDescendentsOnly, upToFirstRequired);
Position parentPos = new Position(grandparent, getIndex(grandparent, pos.parent)); matchExists = matchExistsAfterPosition(parentPos, name, firstDescendentsOnly, upToFirstRequired);
Group grandparent = currPos.parent.getParent(); Index parentIndex = getIndex(grandparent, currPos.parent); Position parentPos = new Position(grandparent, parentIndex);
/** * Returns true if another object exists in the iteration sequence. */ public boolean hasNext() { boolean has = true; if (next == null) { if (Group.class.isAssignableFrom(currentStructure.getClass())) { groupNext((Group) currentStructure); } else { Group parent = currentStructure.getParent(); Index i = getIndex(parent, currentStructure); Position currentPosition = new Position(parent, i); try { if (parent.isRepeating(i.name) && currentStructure.getName().equals(direction)) { nextRep(currentPosition); } else { has = nextPosition(currentPosition, this.direction, this.handleUnexpectedSegments); } } catch (HL7Exception e) { throw new Error("HL7Exception arising from bad index: " + e.getMessage()); } } } log.debug("MessageIterator.hasNext() in direction {}? {}", direction, has); return has; }
Group grandparent = currPos.parent.getParent(); Index parentIndex = getIndex(grandparent, currPos.parent); Position parentPos = new Position(grandparent, parentIndex);
/** * Sets next to the next repetition of the current structure. */ private void nextRep(Position current) { next = new Position(current.parent, current.index.name, current.index.rep + 1); }
/** * Sets next to the first child of the given group (iteration * always proceeds from group to first child). */ private void groupNext(Group current) { next = new Position(current, current.getNames()[0], 0); }
/** * Sets the next position to a new segment of the given name, within the * given group. */ private void newSegment(Group parent, String name) throws HL7Exception { log.info("MessageIterator creating new segment: {}", name); parent.addNonstandardSegment(name); next = new Position(parent, parent.getNames()[parent.getNames().length-1], 0); }
/** * Sets the next position to a new segment of the given name, within the * given group. */ private void newSegment(Group parent, String name) throws HL7Exception { log.info("MessageIterator creating new segment: {}", name); parent.addNonstandardSegment(name); next = new Position(parent, parent.getNames()[parent.getNames().length-1], 0); }
/** * Sets next to the next repetition of the current structure. */ private void nextRep(Position current) { next = new Position(current.parent, current.index.name, current.index.rep + 1); }
/** * Sets next to the first child of the given group (iteration * always proceeds from group to first child). */ private void groupNext(Group current) { next = new Position(current, current.getNames()[0], 0); }