private void init(XMLParser parser) { contributorId = parser.getLong("response/result/contributor_fact/contributor_id/text()"); analysisId = parser.getLong("response/result/contributor_fact/analysis_id/text()"); accountId = parser.getLong("response/result/contributor_fact/account_id/text()"); contributorName = parser.getString("response/result/contributor_fact/contributor_name/text()"); primaryLanguageId = parser.getInt("response/result/contributor_fact/primary_language_id/text()"); primaryLanguageNiceName = parser.getString("response/result/contributor_fact/primary_language_nice_name/text()"); commentRatio = parser.getFloat("response/result/contributor_fact/comment_ratio/text()"); firstCommitTime = parser.getDate("response/result/contributor_fact/first_commit_time/text()"); lastCommitTime = parser.getDate("response/result/contributor_fact/last_commit_time/text()"); manMonths = parser.getInt("response/result/contributor_fact/man_months/text()"); commits = parser.getInt("response/result/contributor_fact/commits/text()"); medianCommits = parser.getInt("response/result/contributor_fact/median_commits/text()"); contributorLanguageFact = createContLangFact( parser.getNodeList( "response/result/contributor_fact/contributor_language_facts/contributor_language_fact")); }
public static ResponseList<ContributorFact> createContributorFactList(HttpResponse res) { if (null == res) { return null; } XMLParser parser = new XMLParser(res.asString()); NodeList nodelist = parser.getNodeList("response/result/contributor_fact"); ResponseList<ContributorFact> list = new ResponseListImpl<ContributorFact>(nodelist.getLength(), res); for (int i = 0; i < nodelist.getLength(); i++) { Node node = nodelist.item(i); try { XMLParser childParser = new XMLParser(XMLParser.getXmlStringFromNode(node)); ContributorFact contributorFact = new ContributorFactImpl(childParser, true); list.add(contributorFact); } catch (TransformerFactoryConfigurationError e) { e.printStackTrace(); } catch (TransformerException e) { e.printStackTrace(); } } return list; }