/* * Creates a new item and adds it to the HighScores domain. */ public void addHighScore(HighScore score) { String paddedScore = SimpleDBUtils.encodeZeroPadding(score.getScore(), 10); ReplaceableAttribute playerAttribute = new ReplaceableAttribute(PLAYER_ATTRIBUTE, score.getPlayer(), Boolean.TRUE); ReplaceableAttribute scoreAttribute = new ReplaceableAttribute(SCORE_ATTRIBUTE, paddedScore, Boolean.TRUE); List<ReplaceableAttribute> attrs = new ArrayList<ReplaceableAttribute>(2); attrs.add(playerAttribute); attrs.add(scoreAttribute); PutAttributesRequest par = new PutAttributesRequest(HIGH_SCORES_DOMAIN, score.getPlayer(), attrs); try { this.sdbClient.putAttributes(par); } catch (Exception exception) { System.out.println("EXCEPTION = " + exception); } }
/* * Removes the item from the HighScores domain. * The item removes is the item whose 'player' matches the theHighScore submitted. */ public void removeHighScore(HighScore score) { DeleteAttributesRequest dar = new DeleteAttributesRequest(HIGH_SCORES_DOMAIN, score.getPlayer()); this.sdbClient.deleteAttributes(dar); this.count = -1; // To force count refresh. }