org.apache.shindig.protocol
Class BaseRequestItem

java.lang.Object
  extended by org.apache.shindig.protocol.BaseRequestItem
All Implemented Interfaces:
RequestItem

public class BaseRequestItem
extends Object
implements RequestItem

Default implementation of RequestItem


Field Summary
protected  SecurityToken token
           
 
Fields inherited from interface org.apache.shindig.protocol.RequestItem
APP_ID, APP_SUBSTITUTION_TOKEN, COUNT, DEFAULT_COUNT, DEFAULT_START_INDEX, FIELDS, FILTER_BY, FILTER_OPERATION, FILTER_VALUE, SORT_BY, SORT_ORDER, START_INDEX
 
Constructor Summary
BaseRequestItem(org.json.JSONObject parameters, Map<String,FormDataItem> formItems, SecurityToken token, BeanConverter converter, BeanJsonConverter jsonConverter)
           
BaseRequestItem(Map<String,String[]> parameters, SecurityToken token, BeanConverter converter, BeanJsonConverter jsonConverter)
           
 
Method Summary
 String getAppId()
          Gets the Opensocial App ID for this request
 Object getAttribute(String val)
          Gets an attribute for this request.
 int getCount()
          Gets the value of the count parameter
 Set<String> getFields()
          Gets the unique set of fields from the request
 Set<String> getFields(Set<String> defaultValue)
          Get the unique set of fields from the request with defaults
 String getFilterBy()
          Gets the value of the filterBy parameter
 FilterOperation getFilterOperation()
          Gets the value of the filterOperation parameter
 String getFilterValue()
          Gets the value of the filterValue parameter
 FormDataItem getFormMimePart(String partName)
          Returns MIME content data for multipart/mixed form submissions
 List<String> getListParameter(String paramName)
          Tries to get a list of values for a specified parameter.
 String getParameter(String paramName)
          Gets the specified parameter as a string
 String getParameter(String paramName, String defaultValue)
          Gets the specified parameter as a string, with a default value
 String getSortBy()
          Gets the value of the sortBy parameter
 SortOrder getSortOrder()
          Gets the value of the sortOrder parameter
 int getStartIndex()
          Gets the value of the startIndex parameter
 SecurityToken getToken()
          Returns the security token of this request
<T> T
getTypedParameter(String parameterName, Class<T> dataTypeClass)
          Converts a parameter into an object using a converter
<T> T
getTypedRequest(Class<T> dataTypeClass)
          Assume that all the parameters in the request belong to single aggregate type and convert to it.
 Date getUpdatedSince()
          Gets the value of the updatedSince parameter
 void setAttribute(String val, Object obj)
          Sets an attribute on this request object
 void setParameter(String paramName, Object paramValue)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

token

protected final SecurityToken token
Constructor Detail

BaseRequestItem

public BaseRequestItem(Map<String,String[]> parameters,
                       SecurityToken token,
                       BeanConverter converter,
                       BeanJsonConverter jsonConverter)

BaseRequestItem

public BaseRequestItem(org.json.JSONObject parameters,
                       Map<String,FormDataItem> formItems,
                       SecurityToken token,
                       BeanConverter converter,
                       BeanJsonConverter jsonConverter)
Method Detail

getAppId

public String getAppId()
Description copied from interface: RequestItem
Gets the Opensocial App ID for this request

Specified by:
getAppId in interface RequestItem
Returns:
an app ID

getUpdatedSince

public Date getUpdatedSince()
Description copied from interface: RequestItem
Gets the value of the updatedSince parameter

Specified by:
getUpdatedSince in interface RequestItem
Returns:
A Date representing the updatedSince value

getSortBy

public String getSortBy()
Description copied from interface: RequestItem
Gets the value of the sortBy parameter

Specified by:
getSortBy in interface RequestItem
Returns:
the value of the sortBy parameter

getSortOrder

public SortOrder getSortOrder()
Description copied from interface: RequestItem
Gets the value of the sortOrder parameter

Specified by:
getSortOrder in interface RequestItem
Returns:
a SortOrder enum value representing the sortOrder parameter

getFilterBy

public String getFilterBy()
Description copied from interface: RequestItem
Gets the value of the filterBy parameter

Specified by:
getFilterBy in interface RequestItem
Returns:
the value of the filterBy parameter

getStartIndex

public int getStartIndex()
Description copied from interface: RequestItem
Gets the value of the startIndex parameter

Specified by:
getStartIndex in interface RequestItem
Returns:
An integer containing the value of startIndex

getCount

public int getCount()
Description copied from interface: RequestItem
Gets the value of the count parameter

Specified by:
getCount in interface RequestItem
Returns:
An integer containing the value of count

getFilterOperation

public FilterOperation getFilterOperation()
Description copied from interface: RequestItem
Gets the value of the filterOperation parameter

Specified by:
getFilterOperation in interface RequestItem
Returns:
a SortOrder enum value representing the filterOperation parameter

getFilterValue

public String getFilterValue()
Description copied from interface: RequestItem
Gets the value of the filterValue parameter

Specified by:
getFilterValue in interface RequestItem
Returns:
the value of the filterValue parameter

getFields

public Set<String> getFields()
Description copied from interface: RequestItem
Gets the unique set of fields from the request

Specified by:
getFields in interface RequestItem
Returns:
Set of field names, empty if no fields specified.

getFields

public Set<String> getFields(Set<String> defaultValue)
Description copied from interface: RequestItem
Get the unique set of fields from the request with defaults

Specified by:
getFields in interface RequestItem
Parameters:
defaultValue - returned if no fields are specified in the request.
Returns:
specified set of fields or default value

getToken

public SecurityToken getToken()
Description copied from interface: RequestItem
Returns the security token of this request

Specified by:
getToken in interface RequestItem
Returns:
the token

getTypedParameter

public <T> T getTypedParameter(String parameterName,
                               Class<T> dataTypeClass)
Description copied from interface: RequestItem
Converts a parameter into an object using a converter

Specified by:
getTypedParameter in interface RequestItem
Type Parameters:
T - The type of this object
Parameters:
parameterName - the name of the parameter with data to convert
dataTypeClass - The class to make
Returns:
A Valid Object of the given type

getTypedRequest

public <T> T getTypedRequest(Class<T> dataTypeClass)
Description copied from interface: RequestItem
Assume that all the parameters in the request belong to single aggregate type and convert to it.

Specified by:
getTypedRequest in interface RequestItem
Parameters:
dataTypeClass - the class to convert to
Returns:
Typed request object

getParameter

public String getParameter(String paramName)
Description copied from interface: RequestItem
Gets the specified parameter as a string

Specified by:
getParameter in interface RequestItem
Parameters:
paramName - the param name to get
Returns:
the paramName value or null if the parameter is not found

getParameter

public String getParameter(String paramName,
                           String defaultValue)
Description copied from interface: RequestItem
Gets the specified parameter as a string, with a default value

Specified by:
getParameter in interface RequestItem
Parameters:
paramName - the param name to get
defaultValue - the default value of the parameter
Returns:
the paramName value or defaultValue if the parameter is not found

getListParameter

public List<String> getListParameter(String paramName)
Description copied from interface: RequestItem
Tries to get a list of values for a specified parameter. This can include splitting text on commas, dereferencing a json array and more.

Specified by:
getListParameter in interface RequestItem
Parameters:
paramName - The parameter
Returns:
A list of strings for the given parameter

setParameter

public void setParameter(String paramName,
                         Object paramValue)

getFormMimePart

public FormDataItem getFormMimePart(String partName)
Description copied from interface: RequestItem
Returns MIME content data for multipart/mixed form submissions

Specified by:
getFormMimePart in interface RequestItem
Parameters:
partName - the part name to retrieve
Returns:
The FormDataItem for this part.

getAttribute

public Object getAttribute(String val)
Description copied from interface: RequestItem
Gets an attribute for this request. Attributes are a place to store per-request values that persist across the life cycle.

Specified by:
getAttribute in interface RequestItem
Parameters:
val - the localized string variable for this request
Returns:
the object associated with this requested string value or null if not found

setAttribute

public void setAttribute(String val,
                         Object obj)
Description copied from interface: RequestItem
Sets an attribute on this request object

Specified by:
setAttribute in interface RequestItem
Parameters:
val - string value
obj - an object


Copyright © 2007-2012. All Rights Reserved.