public class ERXKeyFilter extends Object
ERXKeyFilter is a hierarchical mapping between ERXKeys (single key, not keypaths), whether an include or exclude rule should be applied for that key, and if it's an include, the next set of filter rules to apply to the destination object.
ERXKeyFilter companyFilter = ERXKeyFilter.filterWithAttribtues();
ERXKeyFilter remindersFilter = companyFilter.include(Company.REMINDERS);
remindersFilter.include(Reminder.SUMMARY);
ERXKeyFilter reminderAuthorFilter = remindersFilter.include(Reminder.AUTHOR);
reminderAuthorFilter.includeAll();
reminderAuthorFilter.exclude(Author.HUGE_RELATIONSHIP);
For keys representing to-many relationships you can set a distinct flag
if you want to filter that relationship to return only distinct objects.
For this you can either pass in a key with the unique operator of
ERXArrayUtilities or explicitly set the flag:
ERXKeyFilter companyFilter = ERXKeyFilter.filterWithAttribtues();
companyFilter.include(ERXKey.unique(Company.EMPLOYEES));
companyFilter.include(Company.CLIENTS).setDistinct(true);
more method comments to come ...Modifier and Type | Class and Description |
---|---|
static class |
ERXKeyFilter.Base
ERXKeyFilter.Base defines the base rule that is applied
to a filter.
|
static interface |
ERXKeyFilter.Delegate
ERXKeyFilter.Delegate defines an interface for receiving notifications when your
filter is applied to an object graph.
|
Constructor and Description |
---|
ERXKeyFilter(ERXKeyFilter.Base base)
Creates a new ERXKeyFilter.
|
ERXKeyFilter(ERXKeyFilter.Base base,
ERXKeyFilter.Base nextBase)
Creates a new ERXKeyFilter.
|
Modifier and Type | Method and Description |
---|---|
ERXKeyFilter |
_filterForKey(ERXKey key)
Returns the filter for the given key, or creates a "nextBase" filter
if there isn't one.
|
ERXKeyFilter |
_filterForKey(String key)
Returns the filter for the given key, or creates a "nextBase" filter
if there isn't one.
|
void |
addMap(ERXKey fromKey,
ERXKey toKey)
Adds a key mapping to this filter.
|
void |
addMap(String fromKey,
String toKey)
Adds a key mapping to this filter.
|
ERXKeyFilter.Base |
base()
Returns the base rule for this filter.
|
protected ERXKeyFilter |
createFilter(ERXKeyFilter.Base base) |
protected ERXKeyFilter |
createNextFilter() |
ERXKeyFilter.Delegate |
delegate()
Returns the filter delegate for this filter.
|
void |
exclude(ERXKey... keys)
Excludes the given keys from this filter.
|
void |
exclude(String... keys)
Excludes the given keys from this filter.
|
NSSet<ERXKey> |
excludes()
Returns the set of keys that are explicitly excluded.
|
boolean |
excludes(ERXKey key)
Returns whether or not the given key is excluded.
|
boolean |
excludes(String key)
Returns whether or not the given key is excluded.
|
static ERXKeyFilter |
filterWithAll()
Shortcut to return a new ERXKeyFilter(All)
|
static ERXKeyFilter |
filterWithAllRecursive()
Shortcut to return a new ERXKeyFilter(All, All)
|
static ERXKeyFilter |
filterWithAttributes()
Shortcut to return a new ERXKeyFilter(Attributes)
|
static ERXKeyFilter |
filterWithAttributesAndToOneRelationships()
Shortcut to return a new ERXKeyFilter(AttributesAndToOneRelationships)
|
static ERXKeyFilter |
filterWithKeys(ERXKey<?>... keys)
Shortcut to return a new ERXKeyFilter()
|
static ERXKeyFilter |
filterWithKeys(String... keys)
Shortcut to return a new ERXKeyFilter()
|
static ERXKeyFilter |
filterWithNone()
Shortcut to return a new ERXKeyFilter(None)
|
void |
include(ERXKey... keys)
Includes the given set of keys in this filter.
|
ERXKeyFilter |
include(ERXKey key)
Includes the given key in this filter.
|
ERXKeyFilter |
include(ERXKey key,
ERXKeyFilter existingFilter)
Includes the given key in this filter.
|
void |
include(String... keyNames)
Includes the given set of keys in this filter, wrapping them in ERXKey objects for you.
|
ERXKeyFilter |
include(String key)
Includes the given key in this filter.
|
ERXKeyFilter |
include(String keyName,
ERXKeyFilter existingFilter)
Includes the given key in this filter, wrapping it in an ERXKey object for you.
|
void |
includeAll()
Sets the base rule to All.
|
void |
includeAttributes()
Sets the base rule to Attributes.
|
void |
includeAttributesAndToOneRelationships()
Sets the base rule to AttribtuesAndToOneRelationships.
|
void |
includeNone()
Sets the base rule to None.
|
Map<ERXKey,ERXKeyFilter> |
includes()
Returns the included keys and the next filters they map to.
|
boolean |
includes(ERXKey key)
Returns whether or not the given key is included in this filter.
|
boolean |
includes(String key)
Returns whether or not the given key is included in this filter.
|
boolean |
isAnonymousUpdateEnabled()
Returns whether or not nodes without ids will result in an anonymous update or an object creation.
|
boolean |
isDeduplicationEnabled()
Returns whether or not duplicate objects are collapsed to just an id.
|
boolean |
isDistinct()
Returns whether or not a to-many relationship should return only distinct objects.
|
boolean |
isUnknownKeyIgnored()
Returns whether or not unknown keys are ignored rather than throwing an unknown key exception.
|
<T> ERXKey<T> |
keyMap(ERXKey<T> fromKey)
Returns the key that is mapped to from the given input key.
|
String |
keyMap(String fromKey)
Returns the key that is mapped to from the given input key.
|
boolean |
lockedRelationship(ERXKey key)
Returns whether or not the given relationship is locked (i.e.
|
boolean |
lockedRelationship(String key)
Returns whether or not the given relationship is locked (i.e.
|
NSSet<ERXKey> |
lockedRelationships()
Returns the set of relationships that are locked (i.e.
|
void |
lockRelationship(ERXKey... keys)
Locks the given relationship on this filter.
|
void |
lockRelationship(String... keys)
Locks the given relationship on this filter.
|
boolean |
matches(ERXKey key,
ERXKey.Type type)
Returns whether or not the given key (of the given type, if known) is included in this filter.
|
boolean |
matches(String key,
ERXKey.Type type)
Returns whether or not the given key (of the given type, if known) is included in this filter.
|
ERXKeyFilter.Base |
nextBase()
Returns the base that is used for subkeys of this key by default.
|
void |
only(ERXKey... keys)
Restricts this filter to only allow the given keys.
|
ERXKeyFilter |
only(ERXKey key)
Restricts this filter to only allow the given key.
|
void |
only(String... keys)
Restricts this filter to only allow the given keys.
|
ERXKeyFilter |
only(String key)
Restricts this filter to only allow the given key.
|
void |
setAnonymousUpdateEnabled(boolean anonymousUpdateEnabled)
Sets whether nodes without ids will result in an anonymous update or an object creation.
|
void |
setBase(ERXKeyFilter.Base base)
Sets the base rule.
|
void |
setDeduplicationEnabled(boolean deduplicationEnabled)
Sets whether or not duplicate objects are collapsed to just an id in the filtered graph.
|
void |
setDelegate(ERXKeyFilter.Delegate delegate)
Associate a filter delegate with this filter.
|
ERXKeyFilter |
setDistinct(boolean distinct)
Sets whether or not a to-many relationship should return only distinct objects.
|
ERXKeyFilter |
setNextBase(ERXKeyFilter.Base nextBase)
Sets the base that is used for subkeys of this key by default.
|
void |
setSortOrderings(NSArray<com.webobjects.eocontrol.EOSortOrdering> sortOrderings)
Sets the sort orderings that will be applied by this key filter.
|
void |
setUnknownKeyIgnored(boolean unknownKeyIgnored)
Sets whether or not unknown keys are ignored rather than throwing an unknown key exception.
|
NSArray<com.webobjects.eocontrol.EOSortOrdering> |
sortOrderings()
Returns the sort orderings that will be applied by this key filter.
|
String |
toString() |
public ERXKeyFilter(ERXKeyFilter.Base base)
base
- the base rule to applypublic ERXKeyFilter(ERXKeyFilter.Base base, ERXKeyFilter.Base nextBase)
base
- the base rule to applynextBase
- the next base rule to applypublic void setDelegate(ERXKeyFilter.Delegate delegate)
delegate
- the delegate to associatepublic ERXKeyFilter.Delegate delegate()
public void addMap(ERXKey fromKey, ERXKey toKey)
fromKey
- the key to map fromtoKey
- the key to map topublic void addMap(String fromKey, String toKey)
fromKey
- the key to map fromtoKey
- the key to map topublic <T> ERXKey<T> keyMap(ERXKey<T> fromKey)
T
- the type of the key (which doesn't change)fromKey
- the key to map frompublic String keyMap(String fromKey)
fromKey
- the key to map frompublic static ERXKeyFilter filterWithNone()
public static ERXKeyFilter filterWithAttributes()
public static ERXKeyFilter filterWithKeys(ERXKey<?>... keys)
keys
- the keys to includepublic static ERXKeyFilter filterWithKeys(String... keys)
keys
- the keys to includepublic static ERXKeyFilter filterWithAttributesAndToOneRelationships()
public static ERXKeyFilter filterWithAll()
public static ERXKeyFilter filterWithAllRecursive()
public ERXKeyFilter.Base base()
public void includeAll()
public void includeAttributes()
public void includeAttributesAndToOneRelationships()
public void includeNone()
public void setBase(ERXKeyFilter.Base base)
base
- the base rulepublic ERXKeyFilter.Base nextBase()
protected ERXKeyFilter createFilter(ERXKeyFilter.Base base)
protected ERXKeyFilter createNextFilter()
public ERXKeyFilter setNextBase(ERXKeyFilter.Base nextBase)
nextBase
- the base that is used for subkeys of this key by defaultpublic void setAnonymousUpdateEnabled(boolean anonymousUpdateEnabled)
anonymousUpdateEnabled
- whether nodes without ids will result in an anonymous update or an object creationpublic boolean isAnonymousUpdateEnabled()
public void setDeduplicationEnabled(boolean deduplicationEnabled)
deduplicationEnabled
- if true, duplicate objects are collapsed into idspublic boolean isDeduplicationEnabled()
public ERXKeyFilter _filterForKey(ERXKey key)
key
- the key to lookuppublic ERXKeyFilter _filterForKey(String key)
key
- the key to lookuppublic Map<ERXKey,ERXKeyFilter> includes()
public NSSet<ERXKey> excludes()
public NSSet<ERXKey> lockedRelationships()
public void include(String... keyNames)
keyNames
- the names of the keys to includepublic ERXKeyFilter include(String keyName, ERXKeyFilter existingFilter)
keyName
- the key to includeexistingFilter
- the existing filter to use for this keypublic void include(ERXKey... keys)
keys
- the keys to includepublic boolean includes(ERXKey key)
key
- the key to lookuppublic boolean includes(String key)
key
- the key to lookuppublic ERXKeyFilter include(ERXKey key)
key
- the key to includepublic ERXKeyFilter include(String key)
key
- the key to includepublic ERXKeyFilter include(ERXKey key, ERXKeyFilter existingFilter)
key
- the key to includeexistingFilter
- the existing filter to use for this keypublic boolean excludes(ERXKey key)
key
- the key to lookuppublic boolean excludes(String key)
key
- the key to lookuppublic boolean lockedRelationship(ERXKey key)
key
- the key to lookuppublic boolean lockedRelationship(String key)
key
- the key to lookuppublic void lockRelationship(ERXKey... keys)
keys
- the relationships to lockpublic void lockRelationship(String... keys)
keys
- the relationships to lockpublic void exclude(ERXKey... keys)
keys
- the keys to excludepublic void exclude(String... keys)
keys
- the keys to excludepublic void only(ERXKey... keys)
keys
- the keys to restrict topublic void only(String... keys)
keys
- the keys to restrict topublic ERXKeyFilter only(ERXKey key)
key
- the only key to allowpublic ERXKeyFilter only(String key)
key
- the only key to allowpublic void setSortOrderings(NSArray<com.webobjects.eocontrol.EOSortOrdering> sortOrderings)
sortOrderings
- the sort orderings that will be applied by this key filterpublic NSArray<com.webobjects.eocontrol.EOSortOrdering> sortOrderings()
public void setUnknownKeyIgnored(boolean unknownKeyIgnored)
unknownKeyIgnored
- if true, unknown keys are ignoredpublic boolean isUnknownKeyIgnored()
public ERXKeyFilter setDistinct(boolean distinct)
distinct
- if true
and the key represents a to-many only distinct objects
will be returnedpublic boolean isDistinct()
public boolean matches(ERXKey key, ERXKey.Type type)
key
- the key to lookuptype
- the type of the key (if known)public boolean matches(String key, ERXKey.Type type)
key
- the key to lookuptype
- the type of the key (if known)Copyright © 2002 – 2020 Project Wonder.