ERXEnterpriseObjectChangeListener< T extends EOEnterpriseObject > Class Reference

Collaboration diagram for ERXEnterpriseObjectChangeListener< T extends EOEnterpriseObject >:

Collaboration graph
[legend]

List of all members.

Public Member Functions

abstract void clearCache ()
void clearCache (NSNotification n)
void editingContextDidSaveChanges (NSNotification n)
abstract void entitiesChanged (NSArray< T > entitiesInserted, NSArray< T > entitiesUpdated, NSArray< T > entitiesDeleted)
 ERXEnterpriseObjectChangeListener (String entityName, boolean trackAllChanges, boolean deep)
 ERXEnterpriseObjectChangeListener (Class c, boolean trackAllChanges, boolean deep)

Static Public Attributes

static String ClearCacheNotification = "ERXEnterpriseObjectChangeListener.ClearCache"

Protected Member Functions

String entityName ()
boolean isRelevant (EOEditingContext editingContext, String changedEntityName)
void registerForNotifications ()
NSArray< T > relevantChanges (EOEditingContext editingContext, NSDictionary dict, String key)

Static Private Member Functions

static String entityNameForClass (Class c)

Private Attributes

boolean _deep
String _entityName
boolean _trackAllChanges


Detailed Description

Listens to EOEditingContextDidSaveChanges notifications to track changes on a given entity and calls the entitiesChanged method when the entity changes.

Author:
mschrag (mostly taken from ERXEnterpriseObjectCache, though)

Constructor & Destructor Documentation

ERXEnterpriseObjectChangeListener ( Class  c,
boolean  trackAllChanges,
boolean  deep 
)

Constructs an ERXEnterpriseChangeListener.

Parameters:
c the class name of the entity to watch for changes
trackAllChanges if true, entitiesChanged will pass the array of all changed EO's (slightly slower)
deep if true, subentities of the given entity will be considered relevent to this change listener

ERXEnterpriseObjectChangeListener ( String  entityName,
boolean  trackAllChanges,
boolean  deep 
)

Constructs an ERXEnterpriseChangeListener.

Parameters:
entityName the entity name to watch for changes
trackAllChanges if true, entitiesChanged will pass the array of all changed EO's (slightly slower)
deep if true, subentities of the given entity will be considered relevent to this change listener


Member Function Documentation

abstract void clearCache (  )  [pure virtual]

Called when a clear cache request has been received.

void clearCache ( NSNotification  n  ) 

Handler for the clearCaches notification. Calls reset if n.object is the entity name.

Parameters:
n 

void editingContextDidSaveChanges ( NSNotification  n  ) 

Handler for the editingContextDidSaveChanges notification. Calls entitiesChanged if an object of the given entity (or its subentities) were changed.

Parameters:
n 

abstract void entitiesChanged ( NSArray< T >  entitiesInserted,
NSArray< T >  entitiesUpdated,
NSArray< T >  entitiesDeleted 
) [pure virtual]

Called when the entity being listened to changes. If trackAllChanges is false, all of the arrays will be null.

Parameters:
entitiesInserted entities of this type were inserted, if null, it was not checked
entitiesUpdated entities of this type were updated, if null, it was not checked
entitiesDeleted entities of this type were deleted, if null, it was not checked

String entityName (  )  [protected]

Returns the name of the entity this cache is watching.

Returns:
the name of the entity this cache is watching

static String entityNameForClass ( Class  c  )  [static, private]

boolean isRelevant ( EOEditingContext  editingContext,
String  changedEntityName 
) [protected]

Returns true if the changed entity name matches the watched entity name, or if this change listener is "deep," if the changed entity name is a

Parameters:
editingContext the editing context containing the changes
changedEntityName the name of the changed entity
Returns:
true if this change is relevant to this change listener

void registerForNotifications (  )  [protected]

NSArray<T> relevantChanges ( EOEditingContext  editingContext,
NSDictionary  dict,
String  key 
) [protected]

Helper to check if an array of EOs contains the handled entity or its subclasses (if deep).

Parameters:
editingContext the editingContext containing the changes
dict the notification's userInfo dictionary
key the inserted/updated/deleted key
Returns:
an array of changed EOs (if not trackAllChanges, this will only ever return at most one)


Member Data Documentation

boolean _deep [private]

String _entityName [private]

boolean _trackAllChanges [private]

String ClearCacheNotification = "ERXEnterpriseObjectChangeListener.ClearCache" [static]


The documentation for this class was generated from the following file:

Generated on Sat May 26 06:43:08 2012 for Project Wonder by  doxygen 1.5.8