PageRenderTime 18ms CodeModel.GetById 9ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

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