GraphObject
最新版本的 SDK 已不再提供此課程。
有此級別的更新版本。前往查看 最新版本。

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)
參數說明
graphObjectClassThe type of GraphObject to return
Returns
A new instance of the GraphObject-derived-type that references the same underlying data
asMap()

Returns a Java Collections map of names and properties. Modifying the returned map modifies the inner JSON representation.

public Map asMap()
Returns
A Java Collections map representing the GraphObject state
getInnerJSONObject()

Gets the underlying JSONObject representation of this graph object.

public JSONObject getInnerJSONObject()
Returns
The underlying JSONObject representation of this graph object
getProperty(String)

Gets a property of the GraphObject

public Object getProperty(String propertyName)
參數說明
propertyNameThe name of the property to get
Returns
The value of the named property
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)
參數說明
propertyNameThe name of the property to get
graphObjectClassThe 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)
參數說明
propertyNameThe name of the property to get
graphObjectClassThe 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)
參數說明
propertyNameThe name of the property to set
propertyValueThe value of the named property to set
removeProperty(String)

Removes a property of the GraphObject

public void removeProperty(String propertyName)
參數說明
propertyNameThe name of the property to remove