Group group = structure.getParent(); Group rootGroup = structure.getMessage(); new HL7Value( message.getVersion(), rootGroup.getName(), group.getName(), structure.getName(), structureNumber, names[n - 1], coordinates, types[t].getName(), description, string ); values.add( value );
public boolean evaluate(Structure obj) { return desired.equals(obj.getName()); }
/** * 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; }
private StructureDefinition createStructureDefinition(Structure theStructure, Holder<StructureDefinition> thePreviousLeaf, String theStructureName) throws HL7Exception { retVal.setName(theStructure.getName()); Map<String, String> evtMap = new DefaultModelClassFactory().getEventMapForVersion(Version.versionOf(theStructure.getMessage().getVersion())); if (evtMap.containsKey(struct)) { struct = evtMap.get(struct);
public Group getParent() { return unmodifiableStructure(getDelegate().getParent()); }
/** * {@inheritDoc} */ public boolean isEmpty() throws HL7Exception { for (String name : getNames()) { if (!get(name).isEmpty()) return false; } return true; }
public Message getMessage() { return getDelegate().getMessage(); }
protected void visitNestedStructures(MessageVisitor visitor, Location location) throws HL7Exception { for (String name : getNames()) { Structure[] structures = getAll(name); for (int j=0; j < structures.length; j++) { int rep = isRepeating(name) ? j : -1; Location nextLocation = structures[j].provideLocation(location, -1, rep); if (!structures[j].accept(visitor, nextLocation)) break; } } }
public boolean evaluate(Structure obj) { return desired.equals(obj.getName()); }
/** * 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; }
private StructureDefinition createStructureDefinition(Structure theStructure, Holder<StructureDefinition> thePreviousLeaf, String theStructureName) throws HL7Exception { retVal.setName(theStructure.getName()); Map<String, String> evtMap = new DefaultModelClassFactory().getEventMapForVersion(Version.versionOf(theStructure.getMessage().getVersion())); if (evtMap.containsKey(struct)) { struct = evtMap.get(struct);
public Group getParent() { return unmodifiableStructure(getDelegate().getParent()); }
/** * {@inheritDoc} */ public boolean isEmpty() throws HL7Exception { for (String name : getNames()) { if (!get(name).isEmpty()) return false; } return true; }
public Message getMessage() { return getDelegate().getMessage(); }
protected void visitNestedStructures(MessageVisitor visitor, Location location) throws HL7Exception { for (String name : getNames()) { Structure[] structures = getAll(name); for (int j=0; j < structures.length; j++) { int rep = isRepeating(name) ? j : -1; Location nextLocation = structures[j].provideLocation(location, -1, rep); if (!structures[j].accept(visitor, nextLocation)) break; } } }
public String getName() { return getDelegate().getName(); }
Stack<MessageIterator.Index> indexStack = new Stack<MessageIterator.Index>(); do { MessageIterator.Index index = MessageIterator.getIndex(pathElem.getParent(), pathElem); indexStack.push(index); pathElem = pathElem.getParent(); pathStack.push(pathElem); } while (!root.equals(pathElem) && !Message.class.isAssignableFrom(pathElem.getClass()));
private void apply(Group theStructure, List<ValidationException> theExceptions) { Set<String> choicesWithContent = null; for (String nextName : theStructure.getNames()) { try { boolean nextIsChoiceElement = theStructure.isChoiceElement(nextName); for (Structure nextStruct : theStructure.getAll(nextName)) { if (nextIsChoiceElement && !nextStruct.isEmpty()) { if (choicesWithContent == null) { choicesWithContent = new HashSet<String>(); } choicesWithContent.add(nextName); } if (nextStruct instanceof Group) { apply((Group) nextStruct, theExceptions); } } } catch (HL7Exception e) { throw new Error("Failed to find " + nextName + " in structure. This is probably a HAPI bug."); } } if (choicesWithContent != null && choicesWithContent.size() > 1) { theExceptions.add(new ValidationException("Structure '" + theStructure.getName() + "' must have content only in one of the following choices: " + choicesWithContent.toString())); } }
/** * Inserts a repetition of a given Structure into repetitions of that structure by name. For * example, if the Group contains 10 repetitions an OBX segment and an OBX is supplied with an * index of 2, then this call would insert the new repetition at index 2. (Note that in this * example, the Set ID field in the OBX segments would also need to be renumbered manually). * * @throws HL7Exception if the named Structure is not part of this Group. */ protected void insertRepetition(String name, Structure structure, int index) throws HL7Exception { if (structure == null) { throw new NullPointerException("Structure may not be null"); } if (structure.getMessage() != this.getMessage()) { throw new HL7Exception("Structure does not belong to this message"); } List<Structure> list = structures.get(name); if (list == null) { throw new HL7Exception("The structure " + name + " does not exist in the group " + this.getClass().getName()); } if (list.size() < index) { throw new HL7Exception("Invalid index: " + index + ", structure " + name + " must be between 0 and " + (list.size())); } list.add(index, structure); }
public String getName() { return getDelegate().getName(); }