/facebook-java-api/src/main/java/com/google/code/facebookapi/DashboardItem.java

http://facebook-java-api.googlecode.com/ · Java · 64 lines · 33 code · 13 blank · 18 comment · 2 complexity · 450630d74f2a0c8c3a0fdfe732b374f9 MD5 · raw file

  1. package com.google.code.facebookapi;
  2. import java.io.Serializable;
  3. import org.json.JSONException;
  4. import org.json.JSONObject;
  5. /**
  6. * Base class for common news and activity dashboard news items.
  7. */
  8. public abstract class DashboardItem implements Serializable {
  9. private String message;
  10. private BundleActionLink actionLink;
  11. /**
  12. * Returns the message associated with news item.
  13. */
  14. public String getMessage() {
  15. return message;
  16. }
  17. /**
  18. * Sets the message associated with news item.
  19. */
  20. public void setMessage( String message ) {
  21. this.message = message;
  22. }
  23. /**
  24. * Returns the action link associated with news item.
  25. */
  26. public BundleActionLink getActionLink() {
  27. return actionLink;
  28. }
  29. /**
  30. * Sets the action link assaciated with news item.
  31. */
  32. public void setActionLink( BundleActionLink actionLink ) {
  33. this.actionLink = actionLink;
  34. }
  35. /**
  36. * Creates a JSONObject corresponding to contents of object.
  37. */
  38. public JSONObject toJSON() {
  39. JSONObject itemJSON = new JSONObject();
  40. try {
  41. itemJSON.put( "message", getMessage() );
  42. if (getActionLink() != null) {
  43. itemJSON.put( "action_link", getActionLink().toJson() );
  44. }
  45. }
  46. catch ( JSONException exception ) {
  47. throw BasicClientHelper.runtimeException( exception );
  48. }
  49. return itemJSON;
  50. }
  51. }