Project Wonder 5.0.0.8795

er.extensions.eof
Class ERXQ

java.lang.Object
  extended by er.extensions.eof.ERXQ

public class ERXQ
extends Object

ERXQ provides lots of much shorter methods of constructing EOQualifiers than the very verbose style that you normally have to use. For instance ...

EOQualifier qualifier = new ERXAndQualifier(new NSArray(new Object[] { new ERXKeyValueQualifier("name", EOQualifier.QualifierOperatorsEquals, "Mike"), new ERXKeyValueQualifier("admin", EOQualifier.QualifierOperatorsEquals, Boolean.TRUE) }));

... becomes ...

EOQualifier qualifier = ERXQ.and(ERXQ.equals("name", "Mike"), ERXQ.isTrue("admin"));

Author:
mschrag

Field Summary
static NSSelector CONTAINS
          Equivalent to EOQualifier.QualifierOperatorContains
static NSSelector EQ
          Equivalent to EOQualifier.QualifierOperatorEqual
static NSSelector GT
          Equivalent to EOQualifier.QualifierOperatorGreaterThan
static NSSelector GTEQ
          Equivalent to EOQualifier.QualifierOperatorGreaterThanOrEqualTo
static NSSelector ILIKE
          Equivalent to EOQualifier.QualifierOperatorCaseInsensitiveLike
static NSSelector LIKE
          Equivalent to EOQualifier.QualifierOperatorLike
static NSSelector LT
          Equivalent to EOQualifier.QualifierOperatorLessThan
static NSSelector LTEQ
          Equivalent to EOQualifier.QualifierOperatorLessThanOrEqualTo
static NSSelector NE
          Equivalent to EOQualifier.QualifierOperatorNotEqual
 
Constructor Summary
ERXQ()
           
 
Method Summary
static ERXAndQualifier and(EOQualifier... qualifiersArray)
          Equivalent to new ERXAndQualifier(new NSArray(qualifiersArray).
static EOQualifier between(String key, Object lowerBound, Object upperBound)
          Equivalent to key > lowerBound and key < upperBound (exclusive).
static EOQualifier between(String key, Object lowerBound, Object upperBound, boolean inclusive)
          Equivalent to key >= lowerBound and key <= upperBound (inclusive).
static ERXKeyValueQualifier compare(String key, NSSelector operator, Object value)
          Equivalent to new ERXKeyValueQualifier(key, operator, value);
static ERXKeyValueQualifier contains(String key, String value)
          Equivalent to new ERXKeyValueQualifier(key, EOQualifier.OperatorCaseInsensitiveLike, "*" + value + "*").
static ERXOrQualifier containsAll(NSArray<String> keys, String tokensWithWhitespace)
          Returns a qualifier that evalutes to true when the value of any of the given keys contains all of the given tokens (insensitively) in the search string.
static ERXAndQualifier containsAll(String key, String tokensWithWhitespace)
          Returns a qualifier that evalutes to true when the value of the given key contains all of the given tokens (insensitively) in the search string.
static ERXAndQualifier containsAll(String key, String[] tokens)
          Returns a qualifier that evalutes to true when the value of the given key contains all of the given tokens (insensitively).
static ERXAndQualifier containsAllInAny(String[] keys, String tokensWithWhitespace)
          Returns a qualifier that evaluates to true when all values in the given tokens are found when searching across any of the keypaths.
static ERXAndQualifier containsAllInAny(String[] keys, String[] tokens)
          Returns a qualifier that evaluates to true when all values in the given tokens are found when searching across any of the keypaths.
static ERXOrQualifier containsAny(NSArray<String> keys, String tokensWithWhitespace)
          Returns a qualifier that evalutes to true when the value of any of the given keys contains any of the given tokens (insensitively) in the search string.
static ERXOrQualifier containsAny(String key, String tokensWithWhitespace)
          Returns a qualifier that evalutes to true when the value of the given key contains any of the given tokens (insensitively) in the search string.
static ERXOrQualifier containsAny(String key, String[] tokens)
          Returns a qualifier that evalutes to true when the value of the given key contains any of the given tokens (insensitively).
static ERXKeyValueQualifier containsObject(String key, Object value)
          Equivalent to new ERXKeyValueQualifier(key, EOQualifier.OperatorContains, value).
static ERXKeyValueQualifier equals(String key, Object value)
          Equivalent to new ERXKeyValueQualifier(key, EOQualifier.QualifierOperatorEqual, value);
static void filter(NSMutableArray<?> array, EOQualifier qualifier)
          Equivalent to EOQualifier.filterArrayWithQualifier(NSMutableArray, EOQualfier)
static
<T> NSArray<T>
filtered(NSArray<T> array, EOQualifier qualifier)
          Equivalent to EOQualifier.filteredArrayWithQualifier(NSArray, EOQualifier)
static
<T> T
first(NSArray<T> array, EOQualifier qualifier)
          Returns the first object that matches the qualifier in the given array (or null if there is no match).
static ERXKeyValueQualifier greaterThan(String key, Object value)
          Equivalent to new ERXKeyValueQualifier(key, EOQualifier.QualifierOperatorGreaterThan, value);
static ERXKeyValueQualifier greaterThanOrEqualTo(String key, Object value)
          Equivalent to new ERXKeyValueQualifier(key, EOQualifier.QualifierOperatorGreaterThanOrEqualTo, value);
static ERXKeyValueQualifier has(String key, NSArray values)
          Equivalent to new ERXToManyQualifier(key, values);
static ERXKeyValueQualifier hasAtLeast(String key, NSArray values, int min)
          Equivalent to new ERXToManyQualifier(key, values);
static ERXKeyValueQualifier hasValues(String key, NSArray values)
          Equivalent to new ERXInQualifier(key, values);
static ERXOrQualifier in(String key, NSArray<?> values)
          Equivalent to a new ERXOrQualifier of EOKeyValueQualifier with key equals value for each value.
static ERXOrQualifier inObjects(String key, Object... values)
          Equivalent to a new ERXOrQualifier of EOKeyValueQualifier with key equals value for each value.
static ERXKeyValueQualifier is(String key, Object value)
          Equivalent to new ERXKeyValueQualifier(key, EOQualifier.QualifierOperatorEqual, value);
static ERXKeyValueQualifier isFalse(String key)
          Equivalent to new ERXKeyValueQualifier(key, EOQualifier.QualifierOperatorEqual, Boolean.FALSE);
static ERXKeyValueQualifier isNotNull(String key)
          Equivalent to new ERXKeyValueQualifier(key, EOQualifier.QualifierOperatorNotEqual, null);
static ERXKeyValueQualifier isNull(String key)
          Equivalent to new ERXKeyValueQualifier(key, EOQualifier.QualifierOperatorEqual, null);
static ERXKeyValueQualifier isNull(String key, boolean yesOrNo)
          Returns isNull or isNotNull depending on the value of yesOrNo.
static ERXKeyValueQualifier isTrue(String key)
          Equivalent to new ERXKeyValueQualifier(key, EOQualifier.QualifierOperatorEqual, Boolean.TRUE);
static String keyPath(String... elements)
          Generates a key path from a var args list of strings.
static ERXKeyValueQualifier lessThan(String key, Object value)
          Equivalent to new ERXKeyValueQualifier(key, EOQualifier.QualifierOperatorLessThan, value);
static ERXKeyValueQualifier lessThanOrEqualTo(String key, Object value)
          Equivalent to new ERXKeyValueQualifier(key, EOQualifier.QualifierOperatorLessThanOrEqualTo, value);
static ERXKeyValueQualifier like(String key, Object value)
          Equivalent to new ERXKeyValueQualifier(key, EOQualifier.QualifierOperatorLike, value);
static ERXKeyValueQualifier likeInsensitive(String key, Object value)
          Equivalent to new ERXKeyValueQualifier(key, EOQualifier.QualifierOperatorCaseInsensitiveLike, value);
static ERXKeyValueQualifier matches(String key, String value)
          Equivalent to new ERXRegExQualifier(key, value);
static ERXNotQualifier not(EOQualifier qualifier)
          Equivalent to new ERXNotQualifier(qualifier);
static ERXKeyValueQualifier notEquals(String key, Object value)
          Equivalent to new ERXKeyValueQualifier(key, EOQualifier.QualifierOperatorNotEqual, value);
static ERXAndQualifier notIn(String key, NSArray values)
          Equivalent to a new ERXAndQualifier of EONotQualifier(EOKeyValueQualifier) with key equals value for each value.
static
<T> T
one(NSArray<T> array, EOQualifier qualifier)
          Returns the one object that matches the qualifier in the given array (or null if there is no match).
static ERXOrQualifier or(EOQualifier... qualifiersArray)
          Equivalent to new ERXOrQualifier(new NSArray(qualifiersArray).
static
<T> T
requiredOne(NSArray<T> array, EOQualifier qualifier)
          Returns the one object that matches the qualifier in the given array (or throws if there is no match).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EQ

public static final NSSelector EQ
Equivalent to EOQualifier.QualifierOperatorEqual


NE

public static final NSSelector NE
Equivalent to EOQualifier.QualifierOperatorNotEqual


LT

public static final NSSelector LT
Equivalent to EOQualifier.QualifierOperatorLessThan


GT

public static final NSSelector GT
Equivalent to EOQualifier.QualifierOperatorGreaterThan


LTEQ

public static final NSSelector LTEQ
Equivalent to EOQualifier.QualifierOperatorLessThanOrEqualTo


GTEQ

public static final NSSelector GTEQ
Equivalent to EOQualifier.QualifierOperatorGreaterThanOrEqualTo


CONTAINS

public static final NSSelector CONTAINS
Equivalent to EOQualifier.QualifierOperatorContains


LIKE

public static final NSSelector LIKE
Equivalent to EOQualifier.QualifierOperatorLike


ILIKE

public static final NSSelector ILIKE
Equivalent to EOQualifier.QualifierOperatorCaseInsensitiveLike

Constructor Detail

ERXQ

public ERXQ()
Method Detail

filtered

public static <T> NSArray<T> filtered(NSArray<T> array,
                                      EOQualifier qualifier)
Equivalent to EOQualifier.filteredArrayWithQualifier(NSArray, EOQualifier)

Type Parameters:
T - the type of the array
Parameters:
array - the array to filter
qualifier - the qualifier to filter with
Returns:
the filtered array

filter

public static void filter(NSMutableArray<?> array,
                          EOQualifier qualifier)
Equivalent to EOQualifier.filterArrayWithQualifier(NSMutableArray, EOQualfier)

Parameters:
array - the array to filter (in place)
qualifier - the qualifier to filter with

one

public static <T> T one(NSArray<T> array,
                        EOQualifier qualifier)
Returns the one object that matches the qualifier in the given array (or null if there is no match).

Type Parameters:
T - the type of the objects
Parameters:
array - the array to filter
qualifier - the qualifier to filter on
Returns:
one matching object or null

first

public static <T> T first(NSArray<T> array,
                          EOQualifier qualifier)
Returns the first object that matches the qualifier in the given array (or null if there is no match).

Type Parameters:
T - the type of the objects
Parameters:
array - the array to filter
qualifier - the qualifier to filter on
Returns:
one matching object or null

requiredOne

public static <T> T requiredOne(NSArray<T> array,
                                EOQualifier qualifier)
Returns the one object that matches the qualifier in the given array (or throws if there is no match).

Type Parameters:
T - the type of the objects
Parameters:
array - the array to filter
qualifier - the qualifier to filter on
Returns:
one matching object

or

public static ERXOrQualifier or(EOQualifier... qualifiersArray)
Equivalent to new ERXOrQualifier(new NSArray(qualifiersArray). Nulls are skipped.

Parameters:
qualifiersArray - the array of qualifiers to or
Returns:
and EOOrQualifier

and

public static ERXAndQualifier and(EOQualifier... qualifiersArray)
Equivalent to new ERXAndQualifier(new NSArray(qualifiersArray). Nulls are skipped.

Parameters:
qualifiersArray - the array of qualifiers to and
Returns:
and EOAndQualifier

like

public static ERXKeyValueQualifier like(String key,
                                        Object value)
Equivalent to new ERXKeyValueQualifier(key, EOQualifier.QualifierOperatorLike, value);

Parameters:
key - the key
value - the value
Returns:
an EOKeyValueQualifier

likeInsensitive

public static ERXKeyValueQualifier likeInsensitive(String key,
                                                   Object value)
Equivalent to new ERXKeyValueQualifier(key, EOQualifier.QualifierOperatorCaseInsensitiveLike, value);

Parameters:
key - the key
value - the value
Returns:
an EOKeyValueQualifier

matches

public static ERXKeyValueQualifier matches(String key,
                                           String value)
Equivalent to new ERXRegExQualifier(key, value);

Parameters:
key - the key
value - the value
Returns:
an EOKeyValueQualifier

hasValues

public static ERXKeyValueQualifier hasValues(String key,
                                             NSArray values)
Equivalent to new ERXInQualifier(key, values);

Parameters:
key - the key
values - the values
Returns:
an EOKeyValueQualifier

has

public static ERXKeyValueQualifier has(String key,
                                       NSArray values)
Equivalent to new ERXToManyQualifier(key, values);

Parameters:
key - the key
values - the values
Returns:
an EOKeyValueQualifier

hasAtLeast

public static ERXKeyValueQualifier hasAtLeast(String key,
                                              NSArray values,
                                              int min)
Equivalent to new ERXToManyQualifier(key, values);

Parameters:
key - the key
values - the values
Returns:
an EOKeyValueQualifier

equals

public static ERXKeyValueQualifier equals(String key,
                                          Object value)
Equivalent to new ERXKeyValueQualifier(key, EOQualifier.QualifierOperatorEqual, value);

Parameters:
key - the key
value - the value
Returns:
an EOKeyValueQualifier

is

public static ERXKeyValueQualifier is(String key,
                                      Object value)
Equivalent to new ERXKeyValueQualifier(key, EOQualifier.QualifierOperatorEqual, value);

Parameters:
key - the key
value - the value
Returns:
an EOKeyValueQualifier

isNull

public static ERXKeyValueQualifier isNull(String key,
                                          boolean yesOrNo)
Returns isNull or isNotNull depending on the value of yesOrNo.

Parameters:
key - the key
yesOrNo - if true, returns isNull, if false, returns isNotNull
Returns:
the EOKeyValueQualifier

isNull

public static ERXKeyValueQualifier isNull(String key)
Equivalent to new ERXKeyValueQualifier(key, EOQualifier.QualifierOperatorEqual, null);

Parameters:
key - the key
Returns:
an EOKeyValueQualifier

isNotNull

public static ERXKeyValueQualifier isNotNull(String key)
Equivalent to new ERXKeyValueQualifier(key, EOQualifier.QualifierOperatorNotEqual, null);

Parameters:
key - the key
Returns:
an EOKeyValueQualifier

isTrue

public static ERXKeyValueQualifier isTrue(String key)
Equivalent to new ERXKeyValueQualifier(key, EOQualifier.QualifierOperatorEqual, Boolean.TRUE);

Parameters:
key - the key
Returns:
an EOKeyValueQualifier

isFalse

public static ERXKeyValueQualifier isFalse(String key)
Equivalent to new ERXKeyValueQualifier(key, EOQualifier.QualifierOperatorEqual, Boolean.FALSE);

Parameters:
key - the key
Returns:
an EOKeyValueQualifier

notEquals

public static ERXKeyValueQualifier notEquals(String key,
                                             Object value)
Equivalent to new ERXKeyValueQualifier(key, EOQualifier.QualifierOperatorNotEqual, value);

Parameters:
key - the key
value - the value
Returns:
an EOKeyValueQualifier

lessThan

public static ERXKeyValueQualifier lessThan(String key,
                                            Object value)
Equivalent to new ERXKeyValueQualifier(key, EOQualifier.QualifierOperatorLessThan, value);

Parameters:
key - the key
value - the value
Returns:
an EOKeyValueQualifier

greaterThan

public static ERXKeyValueQualifier greaterThan(String key,
                                               Object value)
Equivalent to new ERXKeyValueQualifier(key, EOQualifier.QualifierOperatorGreaterThan, value);

Parameters:
key - the key
value - the value
Returns:
an EOKeyValueQualifier

lessThanOrEqualTo

public static ERXKeyValueQualifier lessThanOrEqualTo(String key,
                                                     Object value)
Equivalent to new ERXKeyValueQualifier(key, EOQualifier.QualifierOperatorLessThanOrEqualTo, value);

Parameters:
key - the key
value - the value
Returns:
an EOKeyValueQualifier

greaterThanOrEqualTo

public static ERXKeyValueQualifier greaterThanOrEqualTo(String key,
                                                        Object value)
Equivalent to new ERXKeyValueQualifier(key, EOQualifier.QualifierOperatorGreaterThanOrEqualTo, value);

Parameters:
key - the key
value - the value
Returns:
an EOKeyValueQualifier

not

public static ERXNotQualifier not(EOQualifier qualifier)
Equivalent to new ERXNotQualifier(qualifier);

Parameters:
qualifier - the qualifier to not
Returns:
an EONotQualifier

compare

public static ERXKeyValueQualifier compare(String key,
                                           NSSelector operator,
                                           Object value)
Equivalent to new ERXKeyValueQualifier(key, operator, value);

Parameters:
key - the key
operator - ERXQ.EQ, NE, GT, LT, etc
value - the value
Returns:
an EOKeyValueQualifier

inObjects

public static ERXOrQualifier inObjects(String key,
                                       Object... values)
Equivalent to a new ERXOrQualifier of EOKeyValueQualifier with key equals value for each value.

Parameters:
key - the key
values - the values
Returns:
an EOQualifier

in

public static ERXOrQualifier in(String key,
                                NSArray<?> values)
Equivalent to a new ERXOrQualifier of EOKeyValueQualifier with key equals value for each value.

Parameters:
key - the key
values - the values
Returns:
an EOQualifier

notIn

public static ERXAndQualifier notIn(String key,
                                    NSArray values)
Equivalent to a new ERXAndQualifier of EONotQualifier(EOKeyValueQualifier) with key equals value for each value.

Parameters:
key - the key
values - the values
Returns:
an EOQualifier

between

public static EOQualifier between(String key,
                                  Object lowerBound,
                                  Object upperBound)
Equivalent to key > lowerBound and key < upperBound (exclusive). Not that this does not return an ERXBetweenQualifier.

Parameters:
key - the key
lowerBound - the lower bound value
upperBound - the upper bound value
Returns:
the qualifier

between

public static EOQualifier between(String key,
                                  Object lowerBound,
                                  Object upperBound,
                                  boolean inclusive)
Equivalent to key >= lowerBound and key <= upperBound (inclusive). Not that this does not return an ERXBetweenQualifier.

Parameters:
key - the key
lowerBound - the lower bound value
upperBound - the upper bound value
Returns:
the qualifier

containsObject

public static ERXKeyValueQualifier containsObject(String key,
                                                  Object value)
Equivalent to new ERXKeyValueQualifier(key, EOQualifier.OperatorContains, value).

Parameters:
key - the key
value - the value
Returns:
an EOKeyValueQualifier

contains

public static ERXKeyValueQualifier contains(String key,
                                            String value)
Equivalent to new ERXKeyValueQualifier(key, EOQualifier.OperatorCaseInsensitiveLike, "*" + value + "*").

Parameters:
key - the key
value - the substring value
Returns:
an EOKeyValueQualifier

containsAny

public static ERXOrQualifier containsAny(NSArray<String> keys,
                                         String tokensWithWhitespace)
Returns a qualifier that evalutes to true when the value of any of the given keys contains any of the given tokens (insensitively) in the search string. The search string will be tokenized by splitting on space characters.

Parameters:
keys - the keys
tokensWithWhitespace - a whitespace separated list of tokens to search for
Returns:
an ERXOrQualifier

containsAny

public static ERXOrQualifier containsAny(String key,
                                         String tokensWithWhitespace)
Returns a qualifier that evalutes to true when the value of the given key contains any of the given tokens (insensitively) in the search string. The search string will be tokenized by splitting on space characters.

Parameters:
key - the key
tokensWithWhitespace - a whitespace separated list of tokens to search for
Returns:
an ERXOrQualifier

containsAny

public static ERXOrQualifier containsAny(String key,
                                         String[] tokens)
Returns a qualifier that evalutes to true when the value of the given key contains any of the given tokens (insensitively).

Parameters:
key - the key
tokens - the list of tokens to search for
Returns:
an ERXOrQualifier

containsAll

public static ERXOrQualifier containsAll(NSArray<String> keys,
                                         String tokensWithWhitespace)
Returns a qualifier that evalutes to true when the value of any of the given keys contains all of the given tokens (insensitively) in the search string. The search string will be tokenized by splitting on space characters.

Parameters:
keys - the keys
tokensWithWhitespace - a whitespace separated list of tokens to search for
Returns:
an ERXOrQualifier

containsAll

public static ERXAndQualifier containsAll(String key,
                                          String tokensWithWhitespace)
Returns a qualifier that evalutes to true when the value of the given key contains all of the given tokens (insensitively) in the search string. The search string will be tokenized by splitting on space characters.

Parameters:
key - the key
tokensWithWhitespace - a whitespace separated list of tokens to search for
Returns:
an ERXAndQualifier

containsAll

public static ERXAndQualifier containsAll(String key,
                                          String[] tokens)
Returns a qualifier that evalutes to true when the value of the given key contains all of the given tokens (insensitively).

Parameters:
key - the key
tokens - the list of tokens to search for
Returns:
an ERXAndQualifier

containsAllInAny

public static ERXAndQualifier containsAllInAny(String[] keys,
                                               String tokensWithWhitespace)
Returns a qualifier that evaluates to true when all values in the given tokens are found when searching across any of the keypaths. As an example, you could search for "Mike Schrag" across the keys (firstName, lastName) and it would find (firstName=Mike or lastName=Mike) and (firstName=Schrag or lastName=Schrag). Be careful of this one as it permutes quickly.

Parameters:
keys - keypaths to perform search in
tokensWithWhitespace - tokens to search for
Returns:
an ERXAndQualifier

containsAllInAny

public static ERXAndQualifier containsAllInAny(String[] keys,
                                               String[] tokens)
Returns a qualifier that evaluates to true when all values in the given tokens are found when searching across any of the keypaths. As an example, you could search for "Mike Schrag" across the keys (firstName, lastName) and it would find (firstName=Mike or lastName=Mike) and (firstName=Schrag or lastName=Schrag). Be careful of this one as it permutes quickly.

Parameters:
keys - keypaths to perform search in
tokens - tokens to search for
Returns:
an ERXAndQualifier

keyPath

public static String keyPath(String... elements)
Generates a key path from a var args list of strings. Reduces this mess:
 qualifiers.addObject(ERXQ.equals(Distribution.PUBLICATION + "." + Publication.AD + "." + Ad.STATE, DisplayAdStateMachine.ReadyForPrinting));
 
to:
 qualifiers.addObject(ERXQ.equals(ERXQ.keyPath(Distribution.PUBLICATION, Publication.AD, Ad.STATE, DisplayAdStateMachine.ReadyForPrinting));
 

Parameters:
elements - one or more string to concatenate into a keyPath
Returns:
elements with "." between them to form a keypath

Last updated: Fri, Jan 9, 2009 • 04:35 AM EST

Copyright © 2002 – 2007 Project Wonder.