コード例 #1
0
  public List<Team> loadLeaugeTeams(String leaugeid) {
    List<Team> result = null;
    ObjectMapper mapper = new ObjectMapper();
    Map<String, Object> userData;
    Map<String, Object> params;
    Map<String, Object> league;
    int curr = 0;

    String response2 =
        conn.requestData(
            "http://fantasysports.yahooapis.com/fantasy/v2/league/"
                + leaugeid
                + "/teams/standings?format=json",
            Verb.GET);
    try {

      userData = mapper.readValue(response2, Map.class);
      params = (Map<String, Object>) userData.get("fantasy_content");
      league =
          ((List<Map<String, Map<String, Object>>>) (params.get("league"))).get(1).get("teams");
      int count;
      count = (Integer) league.get("count");
      while (curr < count) {
        List<Object> lmpTeams =
            (List<Object>)
                (((Map<String, List<Object>>) league.get((new Integer(curr)).toString()))
                    .get("team")
                    .get(0));
        Team tempTeam = convertToTeam(lmpTeams);
        if (result == null) {
          result = new LinkedList<Team>();
        }
        // tempTeam = loadTeamStandings(tempTeam);
        Map<String, Map> ts =
            (Map<String, Map>)
                ((Map<String, List<Object>>) league.get((new Integer(curr)).toString()))
                    .get("team")
                    .get(1);
        TeamStandings tempStand =
            mapper.readValue(
                JacksonPojoMapper.toJson(ts.get("team_standings"), false), TeamStandings.class);
        tempTeam.setStandings(tempStand);
        result.add(tempTeam);
        curr++;
      }

    } catch (IOException ex) {
      Logger.getLogger(TeamService.class.getName()).log(Level.SEVERE, null, ex);
    }
    return result;
  }
コード例 #2
0
  public Team loadTeamStandings(Team team) {
    Map<String, Object> userData;
    Map<String, List<Map<String, Object>>> params;
    ObjectMapper mapper = new ObjectMapper();
    try {
      String response2 =
          conn.requestData(
              "http://fantasysports.yahooapis.com/fantasy/v2/team/"
                  + team.getTeam_key()
                  + "/standings?format=json",
              Verb.GET);
      userData = mapper.readValue(response2, Map.class);
      params = (Map<String, List<Map<String, Object>>>) userData.get("fantasy_content");

      Map standing = (Map) params.get("team").get(1).get("team_standings");
      TeamStandings tempStand =
          mapper.readValue(JacksonPojoMapper.toJson(standing, false), TeamStandings.class);
      team.setStandings(tempStand);
    } catch (IOException ex) {
      Logger.getLogger(TeamService.class.getName()).log(Level.SEVERE, null, ex);
    }

    return team;
  }