Пример #1
0
  /**
   * SAFELY adds given group into this container, checking duplicities in group names.
   *
   * <p>This used to be the default in JQTI, but wastes processor cycles for the implementation of
   * the core QTI spec. I've kept it in in case it might be useful for someone adding a
   * (non-standard) extension to the spec.
   *
   * @param group given group
   * @throws QtiNodeGroupException if container already contains group with same name
   */
  public void addSafe(final int index, final NodeGroup<?, ?> group) {
    for (final NodeGroup<?, ?> child : groups) {
      if (child.getName().equals(group.getName())) {
        throw new QtiNodeGroupException("Duplicate node group name: " + group.computeXPath());
      }
    }

    groups.add(index, group);
  }
Пример #2
0
 /**
  * Gets group with given name.
  *
  * @param name name of requested group
  * @return group with given name
  * @throws QtiNodeGroupException if group is not found
  */
 public NodeGroup<?, ?> get(final String name) {
   for (final NodeGroup<?, ?> child : groups) {
     if (child.getName().equals(name) || child.supportsQtiClass(name)) {
       return child;
     }
   }
   throw new QtiNodeGroupException("Cannot find node group with name " + name);
 }