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

http://facebook-java-api.googlecode.com/ · Java · 57 lines · 41 code · 11 blank · 5 comment · 2 complexity · 30fdc1652dd6b14eb0c5646d83bbfb8f MD5 · raw file

  1. package com.google.code.facebookapi;
  2. import org.json.JSONException;
  3. import org.json.JSONObject;
  4. /**
  5. * A simple data structure for image media type used by Attachment.
  6. *
  7. * @see {@link http://wiki.developers.facebook.com/index.php/Attachment_(Streams)}
  8. */
  9. public class AttachmentMediaImage extends AttachmentMedia {
  10. private String src;
  11. private String href;
  12. public AttachmentMediaImage() {
  13. super( "image" );
  14. }
  15. public AttachmentMediaImage( String src, String href ) {
  16. this();
  17. this.src = src;
  18. this.href = href;
  19. }
  20. @Override
  21. public JSONObject toJson() {
  22. try {
  23. JSONObject json = super.toJson();
  24. json.put( "src", src );
  25. if ( href != null ) {
  26. json.put( "href", href );
  27. }
  28. return json;
  29. }
  30. catch ( JSONException ex ) {
  31. throw BasicClientHelper.runtimeException( ex );
  32. }
  33. }
  34. public String getSrc() {
  35. return src;
  36. }
  37. public void setSrc( String src ) {
  38. this.src = src;
  39. }
  40. public String getHref() {
  41. return href;
  42. }
  43. public void setHref( String href ) {
  44. this.href = href;
  45. }
  46. }