示例#1
0
  /**
   * Returns the list of teams
   *
   * @return list of teams
   */
  public ArrayList<Team> getTeamList() {

    if (teamList == null || teamList.size() < 1) {
      // if the list is empty or null, add the first item that will be used to add new team objects
      teamList = new ArrayList<Team>();
      Team firstObject = new Team();
      firstObject.setName("Add new Team");
      firstObject.setToken("");
      teamList.add(firstObject);
    }

    return teamList;
  }
示例#2
0
  /**
   * Parses a team xml element into a team object
   *
   * @param teamElement team element
   * @return parsed team object
   */
  public Team parseTeamElement(Element teamElement) {

    Team team = new Team();

    Iterator teamComponents = teamElement.getDescendants();
    // iterate through the Team components (token/name)
    while (teamComponents.hasNext()) {

      Object elementComponents = teamComponents.next();

      if (!(elementComponents instanceof Element)) {
        continue;
      }

      Element component = (Element) elementComponents;

      if (component.getName().equals(XML_TEAM_MANAGER_NAME)) {
        // if the name is found, set the name of the team
        team.setName(component.getText());

      } else if (component.getName().equals(XML_TEAM_MANAGER_TOKEN)) {
        // if the token is found, set the token of the team
        team.setToken(component.getText());

      } else if (component.getName().equals(XML_TEAM_MANAGER_DISTRIBUTION_LIST)) {
        // if the token is found, set the token of the team
        team.setDistributionList(component.getText());
      }
    }

    if (team.getName() != null) {
      // add the parsed team to the list
      return team;
    }

    return null;
  }