Interface Group

All Superinterfaces:
Serializable, Structure, Visitable
All Known Subinterfaces:
Message, SuperStructure
All Known Implementing Classes:
AbstractGroup, AbstractMessage, AbstractSuperMessage, GenericGroup, GenericMessage, GenericMessage.UnknownVersion, GenericMessage.V21, GenericMessage.V22, GenericMessage.V23, GenericMessage.V231, GenericMessage.V24, GenericMessage.V25, GenericMessage.V251, GenericMessage.V26, GenericMessage.V27, GenericMessage.V271, GenericMessage.V28, GenericMessage.V281

public interface Group extends Structure
An abstraction representing >1 message parts which may repeated together. An implementation of Group should enforce contraints about on the contents of the group and throw an exception if an attempt is made to add a Structure that the Group instance does not recognize.
Author:
Bryan Tripp (bryan_tripp@sourceforge.net)
  • Method Details

    • getAll

      Returns an array of Structure objects by name. For example, if the Group contains an MSH segment and "MSH" is supplied then this call would return a 1-element array containing the MSH segment. Multiple elements are returned when the segment or group repeats. The array may be empty if no repetitions have been accessed yet using the get(...) methods.
      Parameters:
      name - of the structure
      Returns:
      array of Structure objects
      Throws:
      HL7Exception - if the named Structure is not part of this Group.
    • get

      Returns the named structure. If this Structure is repeating then the first repetition is returned. Creates the Structure if necessary.
      Parameters:
      name - of the structure
      Returns:
      first (or only) structure object
      Throws:
      HL7Exception - if the named Structure is not part of this Group.
    • get

      Structure get(String name, int rep) throws HL7Exception
      Returns a particular repetition of the named Structure. If the given repetition number is one greater than the existing number of repetitions then a new Structure is created.
      Parameters:
      name - name of the structure
      rep - repetition (zero-based)
      Returns:
      particular repetition of the named structure
      Throws:
      HL7Exception - if the named Structure is not part of this group, if the structure is not repeatable and the given rep is > 0, or if the given repetition number is more than one greater than the existing number of repetitions.
    • isRequired

      boolean isRequired(String name) throws HL7Exception
      Returns true if the named structure is required.
      Parameters:
      name - name of the structure nested in this group
      Returns:
      true if structure is required
      Throws:
      HL7Exception - if the named Structure is not part of this group
    • isRepeating

      boolean isRepeating(String name) throws HL7Exception
      Returns true if the named structure is repeating.
      Parameters:
      name - name of the structure nested in this group
      Returns:
      true if structure is repeating
      Throws:
      HL7Exception - if the named Structure is not part of this group
    • isChoiceElement

      boolean isChoiceElement(String name) throws HL7Exception
      Returns true if the named structure is a "choice element". Some HL7 structures (e.g. ORM_O01 in v2.5) have groups that have several possible first segments. In these structures, one of these "choice elements" must be present, but not more than one.
      Parameters:
      name - name of the structure nested in this group
      Returns:
      true if structure is a choice element
      Throws:
      HL7Exception - if the named Structure is not part of this group
    • isGroup

      boolean isGroup(String name) throws HL7Exception
      Returns true if the named structure is a group.
      Parameters:
      name - name of the structure nested in this group
      Returns:
      true if structure is a choice element
      Throws:
      HL7Exception - if the named Structure is not part of this group
      Since:
      1.2
    • getNames

      Returns an ordered array of the names of the Structures in this Group. These names can be used to iterate through the group using repeated calls to get(name).
      Returns:
      an ordered array of the names of the Structures in this Group
    • getClass

      Class<? extends Structure> getClass(String name)
      Returns the Class of the Structure at the given name index.
      Parameters:
      name - name of the structure nested in this group
      Returns:
      class of the structure or null if the class does not exist
    • addNonstandardSegment

      Expands the group definition to include a segment that is not defined by HL7 to be part of this group (eg an unregistered Z segment). The new segment is slotted at the end of the group. Thenceforward if such a segment is encountered it will be parsed into this location. If the segment name is unrecognized a GenericSegment is used. The segment is defined as repeating and not required.
      Parameters:
      name - name of the segment
      Returns:
      the final name of the segment (may be renamed if a segment of this name already exists.
      Throws:
      HL7Exception - if the segment could not be added
    • addNonstandardSegment

      String addNonstandardSegment(String name, int theIndex) throws HL7Exception
      Expands the group definition to include a segment that is not defined by HL7 to be part of this group (eg an unregistered Z segment).
      Parameters:
      name - name of the segment
      theIndex - index (zero-based) at which to insert this segment
      Returns:
      the name used to index the structure (may be appended with a number if name already used)
      Throws:
      HL7Exception - if the segment could not be added