Exemplo n.º 1
0
  /**
   * Filters out <code>Authors</code> that are deactivated. It returns a group of all the <code>
   * Authors</code> which are active.
   *
   * @param authorGroup Specifies the group of authors on which to apply the filter
   * @return the group of all the authors in the group that are active
   */
  public static AuthorGroup getAllActiveAuthors(AuthorGroup authorGroup) {
    Iterator iterator;
    Author author;
    AuthorGroup result;

    result = new DefaultAuthorGroup();
    iterator = authorGroup.getIterator();

    while (iterator.hasNext()) {
      author = (DefaultAuthor) iterator.next();

      if (author.isActive()) result.addAuthor(author);
    }

    return result;
  }
Exemplo n.º 2
0
  /**
   * Filters based on the <code>Topic</code> of <code>Author</code> on the conditions of equality
   * with the specified <code>Topic</code>. It returns a group of all the <code>Authors</code> which
   * have the specified <code>Topic</code>.
   *
   * @param authorGroup Specifies the group of authors on which to apply the filter
   * @param topic Specifies the topic of author to be equated against
   * @return the group of authors which belong to the specified topic
   */
  public static AuthorGroup filterOnTopicEquality(AuthorGroup authorGroup, Topic topic) {
    Iterator iterator;
    Author author;
    AuthorGroup result;

    result = new DefaultAuthorGroup();
    iterator = authorGroup.getIterator();

    while (iterator.hasNext()) {
      author = (DefaultAuthor) iterator.next();

      if (topic.equals(author.getTopic())) result.addAuthor(author);
    }

    return result;
  }