com.sap.ip.me.api.persist.query
Class QueryRuntime

java.lang.Object
  extended bycom.sap.ip.me.api.persist.query.QueryRuntime
All Implemented Interfaces:
InternalQueryRuntime

public final class QueryRuntime
extends java.lang.Object
implements InternalQueryRuntime

QueryRuntime creates Query instances and components of Query instances which the application programmer can then use to obtain entities from persistence by query. A Query instance consists of a Condition and (optionally) of a SortOrder instance. The application programmer will use QueryRuntime to first create a Condition instance, then optionally create a SortOrder instance and finally with these two (or only * with condition) create a Query instance. Condition instances as well as SortOrder instances can be nested.

Author:
SAP

Method Summary
 Condition createCondition(AttributeDescriptor attribute, RelationalOperatorType relationalOperator, java.lang.Object value)
          Creates a Condition which is used to create a Query.
 Condition createCondition(Condition[] conditions, LogicalOperatorType logicalOperator)
          Creates a Condition which is used to create a Query.
 Query createQuery(java.lang.String classtype, Condition condition)
          Creates a Query out of a classtype (represented as a String) and a Condition
 Query createQuery(java.lang.String classtype, Condition condition, int maxCount)
          Creates a Query out of a classtype (represented as a String), a Condition and a size-limitation of the result set.
 Query createQuery(java.lang.String classtype, Condition condition, SortOrder sortOrder)
          Creates a Query out of a classtype (represented as a String), a Condition and a SortOrder
 Query createQuery(java.lang.String classtype, Condition condition, SortOrder sortOrder, int maxCount)
          Creates a Query out of a classtype (represented as a String), a Condition and a size-limitation of the result set.
 Query createQuery(java.lang.String classtype, Condition condition, SortOrder sortOrder, int startIdx, int maxCount)
          Creates a Query out of a classtype (represented as a String), a Condition and a size-limitation of the result set.
 Query createQuery(java.lang.String classtype, SortOrder sortOrder, int startIdx, int maxCount)
          Creates a Query out of a classtype (represented as a String), a Condition and a size-limitation of the result set.
 SortOrder createSortOrder(AttributeDescriptor attrib, boolean isAscending)
          Creates a SortOrder instance.
 SortOrder createSortOrder(SortOrder[] sortOrders)
          Creates a SortOrder instance out of multiple SingleSortOrder and / or MultipleSortOrder instances.
static QueryRuntime getInstance()
          Returns the QueryRuntime singleton
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static QueryRuntime getInstance()
Returns the QueryRuntime singleton

Returns:
The instance value

createCondition

public Condition createCondition(AttributeDescriptor attribute,
                                 RelationalOperatorType relationalOperator,
                                 java.lang.Object value)
Creates a Condition which is used to create a Query. The returned Condition instance is a SingleCondition instance. Multiple SingleConditions can be grouped as a CompositeCondition instance.

Specified by:
createCondition in interface InternalQueryRuntime
Parameters:
relationalOperator - operator for comparison to a value
value - the value to compare
attribute - the attribute to compare
Returns:
Condition for the comparison

createCondition

public Condition createCondition(Condition[] conditions,
                                 LogicalOperatorType logicalOperator)
Creates a Condition which is used to create a Query. The returned Condition instance is a CompositeCondition instance, created out of multiple SingleCondition and / or CompositeCondition. Multiple CompositeCondition can be grouped as a CompositeCondition instance again.

Specified by:
createCondition in interface InternalQueryRuntime
Parameters:
conditions - a Condition array
logicalOperator - to combine the delivered conditions
Returns:
a composite Condition

createSortOrder

public SortOrder createSortOrder(AttributeDescriptor attrib,
                                 boolean isAscending)
Creates a SortOrder instance. The returned instance is a SingleSortOrder instance. Multiple SingleSortOrder instances can be grouped as a MultipleSortOrder instance.

Make sure you haven marked the AttributeDescriptor as index for best performance!

Specified by:
createSortOrder in interface InternalQueryRuntime
Parameters:
isAscending - set true for ascending sort order (default)
attrib - the attribute to sort by (should be indexed!)
Returns:
a SortOrder

createSortOrder

public SortOrder createSortOrder(SortOrder[] sortOrders)
Creates a SortOrder instance out of multiple SingleSortOrder and / or MultipleSortOrder instances. The returned instance is a MultipleSortOrder instance. Multiple MultipleSortOrder instances can be grouped as a MultipleSortOrder instance again.

Specified by:
createSortOrder in interface InternalQueryRuntime
Parameters:
sortOrders - a multiple SortOrder
Returns:
a combined SortOrder

createQuery

public Query createQuery(java.lang.String classtype,
                         Condition condition)
                  throws PersistenceException
Creates a Query out of a classtype (represented as a String) and a Condition

Specified by:
createQuery in interface InternalQueryRuntime
Parameters:
condition - Condition instance
classtype - Classtype to which this Query belongs
Returns:
an executable Query instance
Throws:
PersistenceException - on errors

createQuery

public Query createQuery(java.lang.String classtype,
                         Condition condition,
                         SortOrder sortOrder)
                  throws PersistenceException
Creates a Query out of a classtype (represented as a String), a Condition and a SortOrder

Specified by:
createQuery in interface InternalQueryRuntime
Parameters:
condition - Condition instance
sortOrder - SortOrder instance
classtype - Classtype to which this Query belongs
Returns:
an executable Query instance
Throws:
PersistenceException - on errors

createQuery

public Query createQuery(java.lang.String classtype,
                         Condition condition,
                         int maxCount)
                  throws PersistenceException
Creates a Query out of a classtype (represented as a String), a Condition and a size-limitation of the result set.

Specified by:
createQuery in interface InternalQueryRuntime
Parameters:
condition - Condition instance
maxCount - maximum number of returned results
classtype - Classtype to which this Query belongs
Returns:
an executable Query instance
Throws:
PersistenceException - on errors

createQuery

public Query createQuery(java.lang.String classtype,
                         SortOrder sortOrder,
                         int startIdx,
                         int maxCount)
                  throws PersistenceException
Creates a Query out of a classtype (represented as a String), a Condition and a size-limitation of the result set. Use this to reduce memory conumption with scrollable screens.

Specified by:
createQuery in interface InternalQueryRuntime
Parameters:
sortOrder - SortOrder instance
startIdx - Offset of the returned results
maxCount - maximum number of returned results
classtype - Classtype to which this Query belongs
Returns:
an executable Query instance
Throws:
PersistenceException - on errors

createQuery

public Query createQuery(java.lang.String classtype,
                         Condition condition,
                         SortOrder sortOrder,
                         int maxCount)
                  throws PersistenceException
Creates a Query out of a classtype (represented as a String), a Condition and a size-limitation of the result set.

Specified by:
createQuery in interface InternalQueryRuntime
Parameters:
condition - Condition instance
sortOrder - SortOrder instance
maxCount - maximum number of returned results
classtype - Classtype to which this Query belongs
Returns:
an executable Query instance
Throws:
PersistenceException - on errors

createQuery

public Query createQuery(java.lang.String classtype,
                         Condition condition,
                         SortOrder sortOrder,
                         int startIdx,
                         int maxCount)
                  throws PersistenceException
Creates a Query out of a classtype (represented as a String), a Condition and a size-limitation of the result set. Use this to reduce memory conumption with scrollable screens.

Specified by:
createQuery in interface InternalQueryRuntime
Parameters:
condition - Condition instance
sortOrder - SortOrder instance
startIdx - Offset of the returned results
maxCount - maximum number of returned results
classtype - Classtype to which this Query belongs
Returns:
an executable Query instance
Throws:
PersistenceException - on errors


Copyright © 2005 SAP AG. All Rights Reserved.