GraphObject is the primary interface used by the Facebook SDK for Android to represent objects in the Facebook Social Graph and the Facebook Open Graph (OG). It is the base interface for all typed access to graph objects in the SDK. No concrete classes implement GraphObject or its derived interfaces. Rather, they are implemented as proxies (see the Factory class) that provide strongly-typed property getters and setters to access the underlying data. Since the primary use case for graph objects is sending and receiving them over the wire to/from Facebook services, they are represented as JSONObjects. No validation is done that a graph object is actually of a specific type -- any graph object can be treated as any GraphObject-derived interface, and the presence or absence of specific properties determines its suitability for use as that particular type of object.
パッケージ: | model |
cast(Class)
Returns a new proxy that treats this graph object as a different GraphObject-derived type.
public GraphObject cast(Class graphObjectClass)
パラメーター | 説明 |
---|---|
graphObjectClass | The type of GraphObject to return |
asMap()
Returns a Java Collections map of names and properties. Modifying the returned map modifies the inner JSON representation.
public Map asMap()
getInnerJSONObject()
Gets the underlying JSONObject representation of this graph object.
public JSONObject getInnerJSONObject()
getProperty(String)
Gets a property of the GraphObject
public Object getProperty(String propertyName)
パラメーター | 説明 |
---|---|
propertyName | The name of the property to get |
getPropertyAs(String, Class)
Gets a property of the GraphObject, cast to a particular GraphObject-derived interface. This gives some of the benefits of having a property getter defined to return a GraphObject-derived type without requiring explicit definition of an interface to define the getter.
public GraphObject getPropertyAs(String propertyName, Class graphObjectClass)
パラメーター | 説明 |
---|---|
propertyName | The name of the property to get |
graphObjectClass | The GraphObject-derived interface to cast the property to |
getPropertyAsList(String, Class)
Gets a property of the GraphObject, cast to a a list of instances of a particular GraphObject-derived interface. This gives some of the benefits of having a property getter defined to return a GraphObject-derived type without requiring explicit definition of an interface to define the getter.
public GraphObjectList getPropertyAsList(String propertyName, Class graphObjectClass)
パラメーター | 説明 |
---|---|
propertyName | The name of the property to get |
graphObjectClass | The GraphObject-derived interface to cast the property to a list of |
setProperty(String, Object)
Sets a property of the GraphObject
public void setProperty(String propertyName, Object propertyValue)
パラメーター | 説明 |
---|---|
propertyName | The name of the property to set |
propertyValue | The value of the named property to set |
removeProperty(String)
Removes a property of the GraphObject
public void removeProperty(String propertyName)
パラメーター | 説明 |
---|---|
propertyName | The name of the property to remove |