org.springframework.social.facebook.api
Class FqlResult

java.lang.Object
  extended by org.springframework.social.facebook.api.FqlResult

public class FqlResult
extends Object

Represents a single result item from an FQL query. Given to an FqlResultMapper, in a way that is analogous to how a ResultSet is given to a RowMapper in Spring's JdbcTemplate.


Constructor Summary
FqlResult(Map<String,Object> resultMap)
          Constructs an FqlResult instance from a map.
 
Method Summary
 Boolean getBoolean(String fieldName)
          Returns the value of the identified field as a Boolean.
 Float getFloat(String fieldName)
          Returns the value of the identified field as a Float.
 Integer getInteger(String fieldName)
          Returns the value of the identified field as an Integer.
<T> List<T>
getList(String fieldName, FqlResultMapper<T> mapper)
          Returns the value of the identified field as an object mapped by a given FqlResultMapper.
 Long getLong(String fieldName)
          Returns the value of the identified field as a Long.
 Object getObject(String fieldName)
          Returns the value of the identified field as a simple Object.
<T> T
getObject(String fieldName, FqlResultMapper<T> mapper)
          Returns the value of the identified field as an object mapped by a given FqlResultMapper.
 String getString(String fieldName)
          Returns the value of the identified field as a String.
 Date getTime(String fieldName)
          Returns the value of the identified field as a Date.
 boolean hasField(String fieldName)
          Checks for the existence of a field in the result set, whether null or non-null.
 boolean hasValue(String fieldName)
          Checks that a field exists and contains a non-null value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FqlResult

public FqlResult(Map<String,Object> resultMap)
Constructs an FqlResult instance from a map.

Method Detail

getString

public String getString(String fieldName)
Returns the value of the identified field as a String.

Parameters:
fieldName - the name of the field
Returns:
the value of the field as a String

getInteger

public Integer getInteger(String fieldName)
Returns the value of the identified field as an Integer.

Parameters:
fieldName - the name of the field
Returns:
the value of the field as an Integer
Throws:
FqlException - if the field cannot be expressed as an Integer

getLong

public Long getLong(String fieldName)
Returns the value of the identified field as a Long.

Parameters:
fieldName - the name of the field
Returns:
the value of the field as a Long
Throws:
FqlException - if the field cannot be expressed as an Long

getFloat

public Float getFloat(String fieldName)
Returns the value of the identified field as a Float.

Parameters:
fieldName - the name of the field
Returns:
the value of the field as a Float
Throws:
FqlException - if the field cannot be expressed as an Float

getBoolean

public Boolean getBoolean(String fieldName)
Returns the value of the identified field as a Boolean.

Parameters:
fieldName - the name of the field
Returns:
the value of the field as a Boolean

getTime

public Date getTime(String fieldName)
Returns the value of the identified field as a Date. Time fields returned from an FQL query are expressed in terms of seconds since midnight, January 1, 1970 UTC.

Parameters:
fieldName - the name of the field
Returns:
the value of the field as a Date
Throws:
FqlException - if the field's value cannot be expressed as a long value from which a Date object can be constructed.

getObject

public Object getObject(String fieldName)
Returns the value of the identified field as a simple Object.

Parameters:
fieldName - the name of the field
Returns:
the value of the field as an Object

getObject

public <T> T getObject(String fieldName,
                       FqlResultMapper<T> mapper)
Returns the value of the identified field as an object mapped by a given FqlResultMapper.

Parameters:
fieldName - the name of the field
mapper - an FqlResultMapper used to map the object date into a specific type.
Returns:
the value of the field as an object of a type the same as the parameterized type of the given FqlResultMapper.
Throws:
FqlException - if the value of the field is not a nested object.

getList

public <T> List<T> getList(String fieldName,
                           FqlResultMapper<T> mapper)
Returns the value of the identified field as an object mapped by a given FqlResultMapper.

Parameters:
fieldName - the name of the field
mapper - an FqlResultMapper used to map the object date into a specific type.
Returns:
the value of the field as list of objects whose type is the same as the parameterized type of the given FqlResultMapper.
Throws:
FqlException - if the value of the field is not a list.

hasField

public boolean hasField(String fieldName)
Checks for the existence of a field in the result set, whether null or non-null.

Parameters:
fieldName - the name of the field to check existence of.
Returns:
true if the field exists in the result set, even if the value is null; false if the field is not in the result set.

hasValue

public boolean hasValue(String fieldName)
Checks that a field exists and contains a non-null value.

Parameters:
fieldName - the name of the field to check existence/value of.
Returns:
true if the field exists in the result set and has a non-null value; false otherwise.