Рубрики
Uncategorized

Как получить Футбольные данные

Автор оригинала: David Wong.

Обновлен Официальный Сайт Электронных Данных Соревнований Nikon https://www.xxe.io/New дебютный импорт javax.xml.bind.JAXBContext; импорт javax.xml.bind.Unmarshaller; импорт javax.xml.привязки.аннотации.XmlElement; импорт javax.xml.привязки.аннотации.XmlRootElement; импорт java.io.ByteArrayInputStream; импорт java.nio.кодировки.Стандартные наборы символов; импортируйте файл java.nio.Файлы; импортируйте java.nio.файл.Пути; импорт java.util.List;

/**

  • @ API: 4. Запланируйте результаты
  • @Веб-сайт: https://www.xxe.io/

*/*/Результат по футболу в общественном классе {

public static void main(String[] args) {
    try {
        String content = getContent();

        JAXBContext jaxbContext = JAXBContext.newInstance(MatchList.class);
        Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();

        MatchList matchList = (MatchList) unmarshaller.unmarshal(new ByteArrayInputStream(content.getBytes()));
        matchList.getMatchList().forEach(item -> System.out.println(item));

    } catch (Throwable t) {
        t.printStackTrace();
    }
}

/**
 * Get API return content
 *
 * Note: Here I use a local file for testing purposes, which should be replaced by a real interface to return content.
 */
private static String getContent() {
    try {
        StringBuilder builder = new StringBuilder();
        List lines = Files.readAllLines(Paths.get("./src/main/resources/FootballResult.xml"), StandardCharsets.UTF_8);
        lines.forEach(line -> builder.append(line));
        return builder.toString();
    } catch (Throwable t) {
        t.printStackTrace();
        return "";
    }
}

@XmlRootElement(name = "list")
public static class MatchList {
    private List matchList;

    @XmlElement(name = "match")
    public List getMatchList() {
        return matchList;
    }

    public void setMatchList(List matchList) {
        this.matchList = matchList;
    }
}

@XmlRootElement
public static class Match{
    @XmlElement(name = "a")
    private int matchId;
    @XmlElement(name = "c")
    private String leagueInfo;
    @XmlElement(name = "d")
    private String matchTime;
    @XmlElement(name = "e")
    private int subType;
    @XmlElement(name = "f")
    private int matchStatus;
    @XmlElement(name = "h")
    private String homeTeamInfo;
    @XmlElement(name = "i")
    private String awayTeamInfo;
    @XmlElement(name = "j")
    private int homeScore;
    @XmlElement(name = "k")
    private int awayScore;
    @XmlElement(name = "l")
    private int homeScoreFirstHalf;
    @XmlElement(name = "m")
    private int awayScroeFirstHalf;
    @XmlElement(name = "n")
    private int homeRed;
    @XmlElement(name = "o")
    private int awayRed;
    @XmlElement(name = "p")
    private int homeRank;
    @XmlElement(name = "q")
    private int awayRank;
    @XmlElement(name = "s")
    private String round;
    @XmlElement(name = "t")
    private String address;
    @XmlElement(name = "x")
    private String season;
    @XmlElement(name = "y")
    private String group;
    @XmlElement(name = "z")
    private String isNeutral;
    @XmlElement(name = "subID")
    private String subLeagueId;
    @XmlElement(name = "yellow")
    private int yellow;

    @Override
    public String toString() {
        return "Match{" +
                "matchId=" + matchId +
                ", leagueInfo='" + leagueInfo + '\'' +
                ", matchTime='" + matchTime + '\'' +
                ", subType=" + subType +
                ", matchStatus=" + matchStatus +
                ", homeTeamInfo='" + homeTeamInfo + '\'' +
                ", awayTeamInfo='" + awayTeamInfo + '\'' +
                ", homeScore=" + homeScore +
                ", awayScore=" + awayScore +
                ", homeScoreFirstHalf=" + homeScoreFirstHalf +
                ", awayScroeFirstHalf=" + awayScroeFirstHalf +
                ", homeRed=" + homeRed +
                ", awayRed=" + awayRed +
                ", homeRank=" + homeRank +
                ", awayRank=" + awayRank +
                ", round='" + round + '\'' +
                ", address='" + address + '\'' +
                ", season='" + season + '\'' +
                ", group='" + group + '\'' +
                ", isNeutral='" + isNeutral + '\'' +
                ", subLeagueId='" + subLeagueId + '\'' +
                ", yellow=" + yellow +
                '}';
    }

    public int getMatchId() {
        return matchId;
    }

    public String getLeagueInfo() {
        return leagueInfo;
    }

    public String getMatchTime() {
        return matchTime;
    }

    public int getSubType() {
        return subType;
    }

    public int getMatchStatus() {
        return matchStatus;
    }

    public String getHomeTeamInfo() {
        return homeTeamInfo;
    }

    public String getAwayTeamInfo() {
        return awayTeamInfo;
    }

    public int getHomeScore() {
        return homeScore;
    }

    public int getAwayScore() {
        return awayScore;
    }

    public int getHomeScoreFirstHalf() {
        return homeScoreFirstHalf;
    }

    public int getAwayScroeFirstHalf() {
        return awayScroeFirstHalf;
    }

    public int getHomeRed() {
        return homeRed;
    }

    public int getAwayRed() {
        return awayRed;
    }

    public int getHomeRank() {
        return homeRank;
    }

    public int getAwayRank() {
        return awayRank;
    }

    public String getRound() {
        return round;
    }

    public String getAddress() {
        return address;
    }

    public String getSeason() {
        return season;
    }

    public String getGroup() {
        return group;
    }

    public String getIsNeutral() {
        return isNeutral;
    }

    public String getSubLeagueId() {
        return subLeagueId;
    }

    public int getYellow() {
        return yellow;
    }
}

}