com.endeca.portal.data
Class QueryState

java.lang.Object
  extended by com.endeca.portal.data.QueryState
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable

public class QueryState
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable

QueryState is an API-agnostic representation of a query that can be executed against an MDEX engine to retrieve results. QueryState instances can be interacted with and altered via their list of QueryFunction instances.

See Also:
DataSource, QueryFunction, Serialized Form

Constructor Summary
QueryState()
          Instantiate a QueryState with empty function list.
QueryState(org.json.JSONArray serializedState)
          Instantiate a QueryState from a serialized representation.
 
Method Summary
 void addFunction(QueryFunction function)
          Add a specified QueryFunction to this QueryState, checking for duplicate multi select attribute refinements and override any single select attribute refinements
 void addFunctions(java.util.List<? extends QueryFunction> functions)
          Add a list of QueryFunctions to this QueryState
 QueryState clone()
           
static java.util.List<QueryFunction> cloneFunctionList(java.util.List<QueryFunction> list)
          Clone a List of QueryFunction instances.
 boolean equivalent(QueryState q)
          Convenience method to check equivalence of query states A QueryState is equivalent to another if they contain the same non-QueryConfig QueryFunctions, in the same order.
 java.util.List<QueryFunction> getFunctions()
          Get direct access to the QueryFunction list.
<T extends QueryFunction>
java.util.List<T>
getFunctions(java.lang.Class<T> klass)
          Get a list of all query functions of the specified class (determined using .isInstance).
 void removeAllFunctions()
          Clear all query functions from this query state
 void removeFunction(QueryFunction function)
          Remove particular function based on .equals() equality
 void removeFunctions(java.lang.Class<? extends QueryFunction> klass)
          Removes each filter in the list of a given type (determined using .isInstance).
 void removeFunctions(java.util.List<? extends QueryFunction> functions)
          Remove each function in the given list based on .equals() equality
 org.json.JSONArray toJSON()
          Create a JSON representation of this query state and its query functions.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

QueryState

public QueryState()
Instantiate a QueryState with empty function list.


QueryState

public QueryState(org.json.JSONArray serializedState)
Instantiate a QueryState from a serialized representation.

Parameters:
serializedState -
See Also:
toJSON()
Method Detail

addFunction

public void addFunction(QueryFunction function)
Add a specified QueryFunction to this QueryState, checking for duplicate multi select attribute refinements and override any single select attribute refinements

Parameters:
function - the function to add

addFunctions

public void addFunctions(java.util.List<? extends QueryFunction> functions)
Add a list of QueryFunctions to this QueryState

Parameters:
functions - the list of functions to add

removeFunction

public void removeFunction(QueryFunction function)
Remove particular function based on .equals() equality

Parameters:
function - The function to remove

removeFunctions

public void removeFunctions(java.util.List<? extends QueryFunction> functions)
Remove each function in the given list based on .equals() equality

Parameters:
functions - The functions to remove

removeFunctions

public void removeFunctions(java.lang.Class<? extends QueryFunction> klass)
Removes each filter in the list of a given type (determined using .isInstance).

Parameters:
klass - The class of filters to remove

removeAllFunctions

public void removeAllFunctions()
Clear all query functions from this query state


getFunctions

public java.util.List<QueryFunction> getFunctions()
Get direct access to the QueryFunction list.

Returns:
the query function list

getFunctions

public <T extends QueryFunction> java.util.List<T> getFunctions(java.lang.Class<T> klass)
Get a list of all query functions of the specified class (determined using .isInstance).

Type Parameters:
T -
Parameters:
klass - The class, extending from QueryFunction, to match against
Returns:
The list of query functions

toJSON

public org.json.JSONArray toJSON()
Create a JSON representation of this query state and its query functions.

Returns:
the JSON representation

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

clone

public QueryState clone()
Overrides:
clone in class java.lang.Object

cloneFunctionList

public static java.util.List<QueryFunction> cloneFunctionList(java.util.List<QueryFunction> list)
Clone a List of QueryFunction instances.

Parameters:
list - the list to clone
Returns:
a List that is equivalent to the passed in list

equivalent

public boolean equivalent(QueryState q)
Convenience method to check equivalence of query states A QueryState is equivalent to another if they contain the same non-QueryConfig QueryFunctions, in the same order.

Parameters:
q - The query state to compare against
Returns:
true if the query states are equivalent, false otherwise.