com.force.sdk.jpa.query
Class CollectionParameter

java.lang.Object
  extended by com.force.sdk.jpa.query.CollectionParameter

public class CollectionParameter
extends Object

Use this class to encapsulate collection parameters. The toString() method is overridden to return a properly serialized String representation of the collection, appropriate for SOQL queries. String collections get all members wrapped. So [AAA,BBB] --> ('AAA', 'BBB') Date/Calendar collections get serialized according to SOQLDateFormatUtil formatting methods. All other collection types rely on their respective toString() methods. So [1,2,3] --> (1,2,3)

Author:
Saptarshi Roy

Constructor Summary
CollectionParameter(Collection<?> collection)
          Stores off the given collection for use with the toString() method later.
 
Method Summary
 String toString()
          Given a collection of unknown type, return a serialized String representation of the collection appropriate to inclusion in SOQL queries.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CollectionParameter

public CollectionParameter(Collection<?> collection)
Stores off the given collection for use with the toString() method later.

Parameters:
collection - the collection that will be formatted as a String for SOQL queries
Method Detail

toString

public String toString()
Given a collection of unknown type, return a serialized String representation of the collection appropriate to inclusion in SOQL queries. Empty arrays return the value NULL, resulting in queries like '... WHERE Id IN (NULL). This works in SOQL independent of type. Strings are wrapped in single quotes. All other types are returned as simple comma separated lists.

Overrides:
toString in class Object
Returns:
A serialized String representation of the collection appropriate for SOQL IN clause queries.


Copyright © 2011. All Rights Reserved.