PageRenderTime 11ms CodeModel.GetById 2ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

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