Skip navigation links

Oracle® Coherence Java API Reference
Release 3.6.1.0

E18814-01


com.tangosol.util
Class QueryHelper

java.lang.Object
  extended by com.tangosol.util.QueryHelper


public class QueryHelper
extends java.lang.Object

QueryHelper is a utility class that provides a set of factory methods used for building instances of Filter or ValueExtractor.

The QueryHelper API accepts a String that specifies the creation of rich Filters in a format similar to SQL WHERE clauses. For example, the String "street = 'Main' and state = 'TX'" will create a tree of Filters similar to the following Java code:

new AndFilter(
  new EqualsFilter("getStreet","Main"),
  new EqualsFilter("getState","TX"));

The following keywords are curently supported (words between brackets are optional):

Each argument to an operator is converted into a ReflectionExtractor. Additionally, the "." operator will use ChainedExtractor. Pseudo functions key() and value() may be used to specify the use of a key as in "key() between 10 and 50". The value() pseudo function is a shorthand for IdentityExtractor.

Query bind variables are supported in two forms. One form is a "?" followed by a position number; for example: "dept = ?1 and serviceCode in [10,20,30]". For this usage, supply an Object array of parameters to createFilter(String, Object[]). Note: this scheme treats 1 as the starting index into the array.

Additionally, named bind parameters are supported. The above example could be: "dept = :deptNum and serviceCode in :myList". This style requires the use of a Map with createFilter(String, Map). Both forms can be used in the same specification.

The factory methods catch a number of Exceptions from the implementation stages and subsequently may throw an unchecked FilterBuildingException.

Author:
djl 2009.9.3

Constructor Summary
QueryHelper()
           

 

Method Summary
static ValueExtractor createExtractor(java.lang.String s)
          Make a new ValueExtracter from the given String.
static Filter createFilter(java.lang.String s)
          Make a new Filter from the given String.
static Filter createFilter(java.lang.String s, java.util.Map mapBindings)
          Make a new Filter from the given String.
static Filter createFilter(java.lang.String s, java.lang.Object[] aBindings)
          Make a new Filter from the given String.
static Filter createFilter(java.lang.String s, java.lang.Object[] aBindings, java.util.Map mapBindings)
          Make a new Filter from the given String.

 

Constructor Detail

QueryHelper

public QueryHelper()

Method Detail

createFilter

public static Filter createFilter(java.lang.String s)
Make a new Filter from the given String.
Parameters:
s - a String in the Coherence Query Language representing a Filter
Returns:
the constructed Filter
Throws:
FilterBuildingException - may be thrown

createFilter

public static Filter createFilter(java.lang.String s,
                                  java.lang.Object[] aBindings)
Make a new Filter from the given String.
Parameters:
s - a String in the Coherence Query Language representing a Filter
aBindings - the array of Objects to use for Bind vars
Returns:
the constructed Filter
Throws:
FilterBuildingException - may be thrown

createFilter

public static Filter createFilter(java.lang.String s,
                                  java.util.Map mapBindings)
Make a new Filter from the given String.
Parameters:
s - a String in the Coherence Query Language representing a Filter
mapBindings - the Map of Objects to use for Bind vars
Returns:
the constructed Filter
Throws:
FilterBuildingException - may be thrown

createFilter

public static Filter createFilter(java.lang.String s,
                                  java.lang.Object[] aBindings,
                                  java.util.Map mapBindings)
Make a new Filter from the given String.
Parameters:
s - a String in the Coherence Query Language representing a Filter
aBindings - the array of Objects to use for Bind vars
mapBindings - the Map of Objects to use for Bind vars
Returns:
the constructed Filter
Throws:
FilterBuildingException - may be thrown

createExtractor

public static ValueExtractor createExtractor(java.lang.String s)
Make a new ValueExtracter from the given String.
Parameters:
s - a String in the Coherence Query Language representing a ValueExtractor
Returns:
the constructed ValueExtractor
Throws:
FilterBuildingException - may be thrown

Skip navigation links

Oracle® Coherence Java API Reference
Release 3.6.1.0

E18814-01


Copyright © 2000, 2010, Oracle and/or its affiliates. All rights reserved.