BDRuleModel

Inherits from:
NSObject
Conforms to:
NSCoding
BDPropertyListEncoding (informal protocol)
Declared in:
BDRuleEngine/BDRuleModel.h

Class at a Glance

A BDRuleModel respresents a collection of rules within the rule system.


Class Description

A BDRuleModel is a collection of rules within the rule system. Rule models can be initialized with the contents of ruleSet files or arrays of rules, or they can have their rules added manually.

Rule models can also return a collection of candidate rules to use when looking up the value of a given key. These candidate rules are all the rules that have the requested key as their right-hand side's key path. The returned candidate rules are sorted first according to their priority, and then according to the number of qualifier keys in their left-hand side.


Adopted Protocols

NSCoding
-encodeWithCoder:
-initWithCoder:
 
BDPropertyListEncoding (informal protocol)
-encodeIntoPropertyList:
-initWithPropertyList:owner:
-awakeWithPropertyList:

Method Types

Initialization
-init
-initWithRules:
-initWithContentsOfFile:
-initWithRulesFromOldStylePlistRep:
-initWithRulesFromOldStyleFile:
Writing to a File
-writeToFile:atomically:
Accessors
-setRules:
-rules
-addToRules:
-removeFromRules:
Finding Candidate Rules
-candidateRulesForKey:

Instance Methods

addToRules:

- (void)addToRules:(BDRule *)value

Adds the rule value to the rule model's rule set.

candidateRulesForKey:

- (NSArray *)candidateRulesForKey:(NSString *)key

Locates all of the candidate rules that might apply for the given key.

Candidate rules are rules whose right-hand side key path matches key. The returned candidate rules are sorted in descending order first according to priority, and then according to the number of qualifier keys in their left-hand side. Thus candidate rules are returned in most-specific to least-specific order.

init

- (id)init

Initializes an instance of BDRuleModel with an empty rule set.

initWithRules:

- (id)initWithRules:(NSArray *)rules

Initializes an instance of BDRuleModel with the rules in the array.

Note: This is the designated initializer.

initWithContentsOfFile:

- (id)initWithContentsOfFile:(NSArray *)path

Initializes an instance of BDRuleModel with the property list representation of a set of rules located in the file at path.

initWithRulesFromPlistRep:

- (id)initWithRulesFromOldStylePlistRep:(NSArray *)plistRep

Initializes an instance of BDRuleModel with the old-style property list representation of a set of rules.

initWithRulesFromOldStyleFile:

- (id)initWithRulesFromOldStyleFile:(NSArray *)path

Initializes an instance of BDRuleModel with the property list representation of a set of rules located in the old-style rules file at path.

removeFromRules:

- (void)removeFromRules:(NSString *)value

Removes the rule value from the rule model's rule set.

rules

- (NSArray *)rules

Returns all of the rules in this rule model's rule set.

setRules:

- (void)setRules:(NSArray *)value

Sets the rule model's rule set to contain all of the rules in the array value. Rules may still be added and removed.

writeToFile:atomically:

- (BOOL)writeToFile:(NSString *)path atomically:(BOOL)flag

Writes the property-list representation of the rule set to the file at path. If flag is set, it will write to a temporary file on the same volume and then move the temporary file to path if the write is successful.

Returns whether the file was written.


Copyright © 2002, 2003 bDistributed.com, Inc. All rights reserved worldwide.