Project Wonder 5.0.0.8795

er.extensions.eof
Class ERXKey<T>

java.lang.Object
  extended by er.extensions.eof.ERXKey<T>
Type Parameters:
T - the type of the value of this key

public class ERXKey<T>
extends Object

ERXKey provides a rich wrapper around a keypath. When combined with chainable qualifiers, ERXKey provides a starting point for the qualifier chain. As an example:

 <code>
 public class Person extends ERXGenericRecord {
   ...
   public static final ERXKey<Country> country = new ERXKey<Country>(Person.COUNTRY_KEY);
   public static final ERXKey<NSTimestamp> birthDate = new ERXKey<NSTimestamp>(Person.BIRTH_DATE_KEY);
   ...
 }
 
   Country germany = ...;
   NSTimestamp someRandomDate = ...;
   EOQualifier qualifier = Person.country.is(germany).and(Person.birthDate.after(someRandomDate));
 </code>
 

Author:
mschrag

Nested Class Summary
static class ERXKey.Type
          Enums to desribe the type of key this represents.
static interface ERXKey.ValueCoding
           
 
Constructor Summary
ERXKey(String key)
          Constructs an ERXKey.
 
Method Summary
 ERXKeyValueQualifier after(NSTimestamp when)
          Equivalent to new ERXKeyValueQualifier(key, EOQualifier.QualifierOperatorGreaterThan, value);
<U> ERXKey<U>
append(ERXKey<U> key)
          Returns a new ERXKey that appends the given key to this keypath.
<U> ERXKey<U>
append(String key)
          Returns a new ERXKey that appends the given key to this keypath.
<U> ERXKey<NSArray<U>>
appendAsArray(ERXKey<U> key)
          Returns a new ERXKey that appends the given key to this keypath.
 NSArray<T> arrayValueInObject(Object obj)
          Returns the value of this keypath on the given object cast as an NSArray.
 ERXSortOrdering asc()
          Equivalent to ERXS.asc(key())
 ERXSortOrdering ascInsensitive()
          Equivalent to ERXS.ascInsensitive(key())
 ERXSortOrdering.ERXSortOrderings ascInsensitives()
          Equivalent to ERXS.ascInsensitives(key())
 ERXSortOrdering.ERXSortOrderings ascs()
          Equivalent to ERXS.ascs(key())
 ERXKeyValueQualifier before(NSTimestamp when)
          Equivalent to new ERXKeyValueQualifier(key, EOQualifier.QualifierOperatorLessThan, value);
 EOQualifier between(T lowerBound, T upperBound)
          Equivalent to key > lowerBound and key < upperBound (exclusive).
 EOQualifier between(T lowerBound, T upperBound, boolean inclusive)
          Equivalent to key >= lowerBound and key <= upperBound (inclusive).
 ERXKeyValueQualifier contains(String value)
          Equivalent to new ERXKeyValueQualifier(key, EOQualifier.OperatorCaseInsensitiveLike, "*" + value + "*").
 ERXAndQualifier containsAll(String tokens)
          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.
 ERXAndQualifier containsAll(String[] tokens)
          Returns a qualifier that evalutes to true when the value of the given key contains all of the given tokens (insensitively).
 ERXOrQualifier containsAny(String tokens)
          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.
 ERXOrQualifier containsAny(String[] tokens)
          Returns a qualifier that evalutes to true when the value of the given key contains any of the given tokens (insensitively).
 ERXSortOrdering desc()
          Equivalent to ERXS.desc(key())
 ERXSortOrdering descInsensitive()
          Equivalent to ERXS.descInsensitive(key())
 ERXSortOrdering.ERXSortOrderings descInsensitives()
          Equivalent to ERXS.descInsensitives(key())
 ERXSortOrdering.ERXSortOrderings descs()
          Equivalent to ERXS.descs(key())
<U> ERXKey<U>
dot(ERXKey<U> key)
          Calls append(key)
<U> ERXKey<U>
dot(String key)
          Calls append(key)
<U> ERXKey<NSArray<U>>
dotArray(ERXKey<U> key)
          Calls appendAsArray(key).
 ERXKeyValueQualifier eq(T value)
          Equivalent to new ERXKeyValueQualifier(key, EOQualifier.QualifierOperatorEqual, value);
 boolean equals(Object obj)
           
 ERXKeyValueQualifier greaterThan(T value)
          Equivalent to new ERXKeyValueQualifier(key, EOQualifier.QualifierOperatorGreaterThan, value);
 ERXKeyValueQualifier greaterThanOrEqualTo(T value)
          Equivalent to new ERXKeyValueQualifier(key, EOQualifier.QualifierOperatorGreaterThanOrEqualTo, value);
 ERXKeyValueQualifier gt(T value)
          Equivalent to new ERXKeyValueQualifier(key, EOQualifier.QualifierOperatorGreaterThan, value);
 ERXKeyValueQualifier gte(T value)
          Equivalent to new ERXKeyValueQualifier(key, EOQualifier.QualifierOperatorGreaterThanOrEqualTo, value);
 int hashCode()
           
 ERXKeyValueQualifier ilike(String value)
          Equivalent to new ERXKeyValueQualifier(key, EOQualifier.QualifierOperatorCaseInsensitiveLike, value);
 ERXOrQualifier in(NSArray<T> values)
          Equivalent to a new ERXOrQualifier of EOKeyValueQualifier with key equals value for each value.
 ERXOrQualifier inObjects(T... values)
          Equivalent to a new ERXOrQualifier of EOKeyValueQualifier with key equals value for each value.
 ERXKeyValueQualifier is(T value)
          Equivalent to new ERXKeyValueQualifier(key, EOQualifier.QualifierOperatorEqual, value);
 ERXKeyValueQualifier isFalse()
          Equivalent to new ERXKeyValueQualifier(key, EOQualifier.QualifierOperatorEqual, Boolean.FALSE);
 ERXKeyValueQualifier isNot(T value)
          Equivalent to new ERXKeyValueQualifier(key, EOQualifier.QualifierOperatorNotEqual, value);
 ERXKeyValueQualifier isNotNull()
          Equivalent to new ERXKeyValueQualifier(key, EOQualifier.QualifierOperatorNotEqual, null);
 ERXKeyValueQualifier isNull()
          Equivalent to new ERXKeyValueQualifier(key, EOQualifier.QualifierOperatorEqual, null);
 ERXKeyValueQualifier isTrue()
          Equivalent to new ERXKeyValueQualifier(key, EOQualifier.QualifierOperatorEqual, Boolean.TRUE);
 ERXKeyValueQualifier isUnlessNull(T value)
          Equivalent to new ERXKeyValueQualifier(key, EOQualifier.QualifierOperatorEqual, value) only if the value is not null.
 String key()
          Returns the keypath that this ERXKey represents.
 ERXKeyValueQualifier lessThan(T value)
          Equivalent to new ERXKeyValueQualifier(key, EOQualifier.QualifierOperatorLessThan, value);
 ERXKeyValueQualifier lessThanOrEqualTo(T value)
          Equivalent to new ERXKeyValueQualifier(key, EOQualifier.QualifierOperatorLessThanOrEqualTo, value);
 ERXKeyValueQualifier like(String value)
          Equivalent to new ERXKeyValueQualifier(key, EOQualifier.QualifierOperatorLike, value);
 ERXKeyValueQualifier likeInsensitive(String value)
          Equivalent to new ERXKeyValueQualifier(key, EOQualifier.QualifierOperatorCaseInsensitiveLike, value);
 ERXKeyValueQualifier lt(T value)
          Equivalent to new ERXKeyValueQualifier(key, EOQualifier.QualifierOperatorLessThan, value);
 ERXKeyValueQualifier lte(T value)
          Equivalent to new ERXKeyValueQualifier(key, EOQualifier.QualifierOperatorLessThanOrEqualTo, value);
 ERXKeyValueQualifier ne(T value)
          Equivalent to new ERXKeyValueQualifier(key, EOQualifier.QualifierOperatorNotEqual, value);
 ERXAndQualifier notIn(NSArray<T> values)
          Equivalent to a new ERXAndQualifier of EONotQualifier(EOKeyValueQualifier) with key equals value for each value.
 Object rawValueInObject(Object obj)
          Returns the value of this keypath on the given object.
 void takeValueInObject(T value, Object obj)
          Sets the value of this keypath on the given object.
 String toString()
           
 T valueInObject(Object obj)
          Returns the value of this keypath on the given object.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ERXKey

public ERXKey(String key)
Constructs an ERXKey.

Parameters:
key - the underlying keypath
Method Detail

asc

public ERXSortOrdering asc()
Equivalent to ERXS.asc(key())

Returns:
asc sort ordering for key

ascs

public ERXSortOrdering.ERXSortOrderings ascs()
Equivalent to ERXS.ascs(key())

Returns:
asc sort ordering for key

desc

public ERXSortOrdering desc()
Equivalent to ERXS.desc(key())

Returns:
desc sort ordering for key

descs

public ERXSortOrdering.ERXSortOrderings descs()
Equivalent to ERXS.descs(key())

Returns:
desc sort ordering for key

ascInsensitive

public ERXSortOrdering ascInsensitive()
Equivalent to ERXS.ascInsensitive(key())

Returns:
ascInsensitive sort ordering for key

ascInsensitives

public ERXSortOrdering.ERXSortOrderings ascInsensitives()
Equivalent to ERXS.ascInsensitives(key())

Returns:
ascInsensitive sort ordering for key

descInsensitive

public ERXSortOrdering descInsensitive()
Equivalent to ERXS.descInsensitive(key())

Returns:
descInsensitive sort ordering for key

descInsensitives

public ERXSortOrdering.ERXSortOrderings descInsensitives()
Equivalent to ERXS.descInsensitives(key())

Returns:
descInsensitive sort ordering for key

key

public String key()
Returns the keypath that this ERXKey represents.

Returns:
the keypath that this ERXKey represents

isTrue

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

Returns:
an ERXKeyValueQualifier

isFalse

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

Returns:
an ERXKeyValueQualifier

isUnlessNull

public ERXKeyValueQualifier isUnlessNull(T value)
Equivalent to new ERXKeyValueQualifier(key, EOQualifier.QualifierOperatorEqual, value) only if the value is not null. If the value is null, this will return null, allowing you to conditionally chain an equals only if the value is non-null.

Parameters:
value - the value
Returns:
an ERXKeyValueQualifier or null

is

public ERXKeyValueQualifier is(T value)
Equivalent to new ERXKeyValueQualifier(key, EOQualifier.QualifierOperatorEqual, value);

Parameters:
value - the value
Returns:
an ERXKeyValueQualifier

eq

public ERXKeyValueQualifier eq(T value)
Equivalent to new ERXKeyValueQualifier(key, EOQualifier.QualifierOperatorEqual, value);

Parameters:
value - the value
Returns:
an ERXKeyValueQualifier

isNot

public ERXKeyValueQualifier isNot(T value)
Equivalent to new ERXKeyValueQualifier(key, EOQualifier.QualifierOperatorNotEqual, value);

Parameters:
value - the value
Returns:
an ERXKeyValueQualifier

ne

public ERXKeyValueQualifier ne(T value)
Equivalent to new ERXKeyValueQualifier(key, EOQualifier.QualifierOperatorNotEqual, value);

Parameters:
value - the value
Returns:
an ERXKeyValueQualifier

greaterThan

public ERXKeyValueQualifier greaterThan(T value)
Equivalent to new ERXKeyValueQualifier(key, EOQualifier.QualifierOperatorGreaterThan, value);

Parameters:
value - the value
Returns:
an ERXKeyValueQualifier

gt

public ERXKeyValueQualifier gt(T value)
Equivalent to new ERXKeyValueQualifier(key, EOQualifier.QualifierOperatorGreaterThan, value);

Parameters:
value - the value
Returns:
an ERXKeyValueQualifier

lessThan

public ERXKeyValueQualifier lessThan(T value)
Equivalent to new ERXKeyValueQualifier(key, EOQualifier.QualifierOperatorLessThan, value);

Parameters:
value - the value
Returns:
an ERXKeyValueQualifier

lt

public ERXKeyValueQualifier lt(T value)
Equivalent to new ERXKeyValueQualifier(key, EOQualifier.QualifierOperatorLessThan, value);

Parameters:
value - the value
Returns:
an ERXKeyValueQualifier

greaterThanOrEqualTo

public ERXKeyValueQualifier greaterThanOrEqualTo(T value)
Equivalent to new ERXKeyValueQualifier(key, EOQualifier.QualifierOperatorGreaterThanOrEqualTo, value);

Parameters:
value - the value
Returns:
an ERXKeyValueQualifier

gte

public ERXKeyValueQualifier gte(T value)
Equivalent to new ERXKeyValueQualifier(key, EOQualifier.QualifierOperatorGreaterThanOrEqualTo, value);

Parameters:
value - the value
Returns:
an ERXKeyValueQualifier

lessThanOrEqualTo

public ERXKeyValueQualifier lessThanOrEqualTo(T value)
Equivalent to new ERXKeyValueQualifier(key, EOQualifier.QualifierOperatorLessThanOrEqualTo, value);

Parameters:
value - the value
Returns:
an ERXKeyValueQualifier

lte

public ERXKeyValueQualifier lte(T value)
Equivalent to new ERXKeyValueQualifier(key, EOQualifier.QualifierOperatorLessThanOrEqualTo, value);

Parameters:
value - the value
Returns:
an ERXKeyValueQualifier

like

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

Parameters:
value - the value
Returns:
an ERXKeyValueQualifier

likeInsensitive

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

Parameters:
value - the value
Returns:
an ERXKeyValueQualifier

ilike

public ERXKeyValueQualifier ilike(String value)
Equivalent to new ERXKeyValueQualifier(key, EOQualifier.QualifierOperatorCaseInsensitiveLike, value);

Parameters:
value - the value
Returns:
an ERXKeyValueQualifier

isNull

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

Returns:
an ERXKeyValueQualifier

isNotNull

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

Returns:
an ERXKeyValueQualifier

inObjects

public ERXOrQualifier inObjects(T... values)
Equivalent to a new ERXOrQualifier of EOKeyValueQualifier with key equals value for each value.

Parameters:
values - the values
Returns:
an ERXOrQualifier

in

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

Parameters:
values - the values
Returns:
an ERXOrQualifier

notIn

public ERXAndQualifier notIn(NSArray<T> values)
Equivalent to a new ERXAndQualifier of EONotQualifier(EOKeyValueQualifier) with key equals value for each value.

Parameters:
values - the values
Returns:
an ERXAndQualifier

before

public ERXKeyValueQualifier before(NSTimestamp when)
Equivalent to new ERXKeyValueQualifier(key, EOQualifier.QualifierOperatorLessThan, value);

Parameters:
when - the date to compare with
Returns:
an ERXKeyValueQualifier

after

public ERXKeyValueQualifier after(NSTimestamp when)
Equivalent to new ERXKeyValueQualifier(key, EOQualifier.QualifierOperatorGreaterThan, value);

Parameters:
when - the date to compare with
Returns:
an ERXKeyValueQualifier

between

public EOQualifier between(T lowerBound,
                           T upperBound)
Equivalent to key > lowerBound and key < upperBound (exclusive). Note that this does not return an ERXBetweenQualifier.

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

between

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

Parameters:
lowerBound - the lower bound value
upperBound - the upper bound value
inclusive - whether or not the between includes the endpoints
Returns:
the qualifier

contains

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

Parameters:
value - the substring value
Returns:
an ERXKeyValueQualifier

containsAny

public ERXOrQualifier containsAny(String tokens)
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:
tokens - a whitespace separated list of tokens to search for
Returns:
an ERXOrQualifier

containsAny

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

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

containsAll

public ERXAndQualifier containsAll(String tokens)
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:
tokens - a whitespace separated list of tokens to search for
Returns:
an ERXAndQualifier

containsAll

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

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

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

append

public <U> ERXKey<U> append(String key)
Returns a new ERXKey that appends the given key to this keypath. For instance, if this key is "person" and you add "firstName" to it, this will return a new ERXKey "person.firstName". Note: ERXKey has a limitation that it will not return the proper generic type if you attempt to build a keypath extension of an NSArray. For instance, ERXKey<NSArray<Person>>.append(ERXKey<String>) will return ERXKey<String> when, in fact, it should be ERXKey<NSArray<String>>. This is a limitation due to type erasure with generics that we cannot currently resolve this problem.

Type Parameters:
U - the type of the next key
Parameters:
key - the key to append to this keypath
Returns:
the new appended key

dot

public <U> ERXKey<U> dot(String key)
Calls append(key)

Type Parameters:
U - the key type
Parameters:
key - the key to append to this keypath
Returns:
the new appended key

append

public <U> ERXKey<U> append(ERXKey<U> key)
Returns a new ERXKey that appends the given key to this keypath. For instance, if this key is "person" and you add "firstName" to it, this will return a new ERXKey "person.firstName". Note: ERXKey has a limitation that it will not return the proper generic type if you attempt to build a keypath extension of an NSArray. For instance, ERXKey<NSArray<Person>>.append(ERXKey<String>) will return ERXKey<String> when, in fact, it should be ERXKey<NSArray<String>>. This is a limitation due to type erasure with generics that we cannot currently resolve this problem.

Type Parameters:
U - the type of the next key
Parameters:
key - the key to append to this keypath
Returns:
the new appended key

dot

public <U> ERXKey<U> dot(ERXKey<U> key)
Calls append(key)

Type Parameters:
U - the key type
Parameters:
key - the key to append to this keypath
Returns:
the new appended key

appendAsArray

public <U> ERXKey<NSArray<U>> appendAsArray(ERXKey<U> key)
Returns a new ERXKey that appends the given key to this keypath. For instance, if this key is "person" and you add "firstName" to it, this will return a new ERXKey "person.firstName".
 <code>
                ERXKey<String> k = new ERXKey<String>("foo");
                ERXKey<NSArray<String>> a = new ERXKey<NSArray<String>>("foos");
                k = k.append(k);
                a = a.append(k);
                a = k.appendAsArray(k);
                k = k.appendAsArray(k);
                a = k.appendAsArray(a);
                a = a.appendAsArray(k);
                a = a.appendAsArray(a);
 </code>
 

Type Parameters:
U - the type of the next key in the array
Parameters:
key - the key to append to this keypath
Returns:
the new appended key

dotArray

public <U> ERXKey<NSArray<U>> dotArray(ERXKey<U> key)
Calls appendAsArray(key).

Type Parameters:
U - the type
Parameters:
key - the key to append to this keypath
Returns:
the new append to this keypath

valueInObject

public T valueInObject(Object obj)
Returns the value of this keypath on the given object. Note: If you ERXKey representation a keypath through an NSArray, this method will result in a ClassCastException. See the 'Note' on .append(..) for further explanation.

Parameters:
obj - the target object to apply this keypath on
Returns:
the value of the keypath on the target object

rawValueInObject

public Object rawValueInObject(Object obj)
Returns the value of this keypath on the given object.

Parameters:
obj - the target object to apply this keypath on
Returns:
the value of the keypath on the target object

arrayValueInObject

public NSArray<T> arrayValueInObject(Object obj)
Returns the value of this keypath on the given object cast as an NSArray.

Parameters:
obj - the target object to apply this keypath on
Returns:
the value of the keypath on the target object

takeValueInObject

public void takeValueInObject(T value,
                              Object obj)
Sets the value of this keypath on the given object.

Parameters:
value - the value to set
obj - the object to set the value on

toString

public String toString()
Overrides:
toString in class Object

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

Copyright © 2002 – 2007 Project Wonder.