*
* @param scrobbleElement DomElement containing scrobble or now playing response data.
* @param scrobbleResult ScrobbleResult to add the response data to.
*/
private static void parseIntoScrobbleResult(DomElement scrobbleElement, ScrobbleResult scrobbleResult) {
DomElement trackElement = scrobbleElement.getChild("track");
scrobbleResult.setTrack(trackElement.getText());
scrobbleResult.setArtistCorrected(StringUtilities.convertToBoolean(trackElement.getAttribute("corrected")));
DomElement artistElement = scrobbleElement.getChild("artist");
scrobbleResult.setArtist(artistElement.getText());
scrobbleResult.setArtistCorrected(StringUtilities.convertToBoolean(artistElement.getAttribute("corrected")));
DomElement albumElement = scrobbleElement.getChild("album");
scrobbleResult.setAlbum(albumElement.getText());
scrobbleResult.setAlbumCorrected(StringUtilities.convertToBoolean(albumElement.getAttribute("corrected")));
DomElement albumArtistElement = scrobbleElement.getChild("albumArtist");
scrobbleResult.setAlbumArtist(albumArtistElement.getText());
scrobbleResult.setAlbumArtistCorrected(StringUtilities.convertToBoolean(albumArtistElement.getAttribute("corrected")));
String timeString = scrobbleElement.getChildText("timestamp");
if (timeString != null) {
// will be non-null for scrobble results only
scrobbleResult.setTimestamp(Integer.parseInt(timeString));
}
DomElement ignoredMessageElement = scrobbleElement.getChild("ignoredMessage");
int ignoredMessageCode = Integer.parseInt(ignoredMessageElement.getAttribute("code"));
if (ignoredMessageCode > 0) {
scrobbleResult.setIgnored(true);
scrobbleResult.setIgnoredMessageCode(IgnoredMessageCode.valueOfCode(ignoredMessageCode));
scrobbleResult.setIgnoredMessage(ignoredMessageElement.getText());
}
}