Copyright ©1995 by NeXT Computer, Inc. All Rights Reserved.
IXAttributeQuery |
Inherits From: | Object | |
Declared In: | indexing/IXAttributeQuery.h |
Class Description |
IXAttributeQuery is an interpreter for the Indexing Kit's query language. An IXAttributeQuery is initialized with a single query expression, which it can evaluate against a "context" object: an IXRecordManager, an IXFileRecord, or an IXAttributeParser. When it evaluates the query, it returns an IXPostingList containing the objects selected by the query expression, or nil if no objects were selected. See "The Indexing Kit Query Language" in the "Other Features" section of this chapter for more information on query evaluation.
When a query is evaluated against a context that acts as a container (for example, an IXRecordManager), the resulting IXPostingList contains the objects selected from the container by the query expression. When a query is evaluated against an immediate context (for example, an IXAttributeParser or IXFileRecord), the resulting IXPostingList contains only the context. Evaluating a query against a single object is useful when a yes/no answer is desired, especially with an IXAttributeParser loaded from a stream of text. |
Instance Variables |
unsigned char *queryString;
id attributeParser; id queryContext; |
queryString | The query language expression to be evaluated. | |
attributeParser | The IXAttributeParser used to parse portions of the query. | |
queryContext | The object against which the query expression is evaluated. |
Method Types |
Initializing | initQueryString:andAttributeParser: | |
Accessing attributes | attributeNames |
attributeParser |
Retrieving the query expression | queryString | |
Evaluating the query | evaluateFor: |
Instance Methods |
attributeNames |
(char *)attributeNames |
Returns a newline-separated list of the attribute names found in the query string. This can be used to compare the attributes named in the query against those in an IXRecordManager, for example. The sender of this message is responsible for freeing the string returned.
See also: initQueryString:andAttributeParser:, attributeNames (IXRecordManager) |
attributeParser |
(IXAttributeParser *)attributeParser |
Returns the IXAttributeParser used for parse() operators in the query string.
See also: initQueryString:andAttributeParser: |
evaluateFor: |
(IXPostingList *)evaluateFor:anObject |
Evaluates the query string against information in anObject. anObject must be an instance of IXAttributeParser, IXFileRecord, or IXRecordManager. Returns the results of the query in an IXPostingList, or nil if there is no match. The sender of this message is responsible for freeing both the IXPostingList and the objects it contains.
If anObject is an IXAttributeParser or IXFileRecord and it matches the query, it will be the only object in the IXPostingList; its handle and weight will be 0, and the IXPostingList's source will be nil. If anObject is an IXRecordManager that contains records that match the query, the IXPostingList will be contain postings for those records, and the IXPostingList's source will be the IXRecordManager. |
initQueryString:andAttributeParser: |
initQueryString:(const char *)aString |
andAttributeParser:(IXAttributeParser *)aParser |
Initializes the receiver, a newly allocated IXAttributeQuery, compiling aString as its query and using aParser as the IXAttributeParser for any parse() operators in aString. aString must be a legal expression in the Indexing Kit query language, as documented in "The Indexing Kit Query Language." aParser may be nil; in this case a default instance of IXAttributeParser will be created by the IXAttributeQuery when a parse() operator is encountered. Returns self if aString is a well formed query, or nil if a compilation error is encountered.
aParser and its IXAttributeReaders should be configured in the same manner as the IXAttributeParser and IXAttributeReaders used to generate attribute values for the context. For example, if an IXRecordManager contains a parsed attribute named Text, then any IXAttributeQuery used to query the Text attribute of that IXRecordManager should be initialized with a parsing configuration similar to the Text attribute's parsing configuration. Once an IXAttributeQuery is initialized, its parser shouldn't be sent any messages until after the IXAttributeQuery is freed; the parser may be safely freed or reused at that time. See also: queryString, attributeParser, evaluateFor:, setParser:forAttributeNamed: (IXRecordManager) |
queryString |
(const char *)queryString |
Returns the IXAttributeQuery's query string.
See also: initQueryString:andAttributeParser: |