MultiParser


Inherits From:
NSObject
Declared In:
MultiParser.h


Class Description

This class takes some of the tedium from handling multiple, parallel searches. You set it up with one or more parsing dictionaries that take similar inputs; each source of information fills up an array of dictionaries as the results come in. The parsing dictionaries specify the "translation" to convert the user input names as passed in by the tool into the user inputs as used by the site being loaded.

The MultiParser communicates with the tool that uses it by notification rather than directly invoking methods like a LoadBroker does, since it's not tied as tightly.

A concurrent search is invoked with startNewSearchWithInputs.

To support loading of the next set of results, each parsing dictionary should scan out a string with the key "next_results" to be placed at the top level sequence. The method loadMoreResults uses these values to load all the "next" pages for circumstances where there are subsequent results pages, as is often found on web searches.


Global Variables

Synopsis:

NSString *MultiParserNewResultsNotification;
NSString *MultiParserDoneLoading;
NSString *MultiParserStillLoading;
NSString *MultiParserMoreResults;
NSString *MultiParserResultCount;
NSString *MultiParserPreferencesKey;
NSString *MultiParserPreferencesChanged;


Instance Variables

NSArray *mIdentifier;
NSDictionary *mParsingDicts;
NSMutableArray *mResultArray;
NSMutableDictionary *mNextPageURLs;
NSString *mPreferencesKey;
NSString *mFolder;
NSInvocation *mFilterInvocation;
ParseManager *mParseManager;
NSProgressIndicator *mProgress;

mIdentifierNo description.
mParsingDictsNo description.
mResultArrayNo description.
mNextPageURLsNo description.
mPreferencesKeyNo description.
mFolderNo description.
mFilterInvocationNo description.
mParseManagerNo description.
mProgressNo description.


Method Types

- initWithFolder:progress:fromBundle:
- initWithFolder:progress:fromBundle:prefKey:
- addHomePagesToDictionary:
- loadMoreResults
- stopLoading
- resultArray
- setFilterSelector:target:
- startNewSearchWithInputs:
- startNewSearchWithInputs:parsingDicts:
- folder
- dictionaryOfIdentifiersForPages
- preferencesKey
- parsingDicts
- translateUserInputs:withParsingDict:

Instance Methods

addHomePagesToDictionary:

- (void)addHomePagesToDictionary:(NSMutableDictionary *)inDict

No method description.


dictionaryOfIdentifiersForPages

- (NSDictionary *)dictionaryOfIdentifiersForPages

Return a dictionary with the names as the keys and the identifiers (the plist names) as the values


folder

- (NSString *)folder

Return the folder name associated with this; it should be a human-readable name.


initWithFolder:progress:fromBundle:

- (id)initWithFolder:(NSString *)inFolder progress:(NSProgressIndicator *)inProgress fromBundle:(NSBundle *)inBundle

Initialize, given the subdirectory inFolder to search for parsing dictionaries, the progress indicator to use, and the bundle that corresponds to this; use the default key for indicating how preferences are stored.


initWithFolder:progress:fromBundle:prefKey:

- (id)initWithFolder:(NSString *)inFolder progress:(NSProgressIndicator *)inProgress fromBundle:(NSBundle *)inBundle prefKey:(NSString *)inPrefKey

Initialize, given the subdirectory inFolder to search for parsing dictionaries, the progress indicator to use, the bundle that corresponds to this, and the given key for storing preferences. The bundle identifier will be used to indicate the subdirectory that any externally loaded parsing dictionaries will be found.


loadMoreResults

- (void)loadMoreResults

Load the next pages of results, as specified in the "next_results" values.


parsingDicts

- (NSDictionary *)parsingDicts

Return the dictionary of parsing dictionaries; allows tools not actually doing the multiparsing to still use MultiParser to load and organize the dictionaries.


preferencesKey

- (NSString *)preferencesKey

Return the string that is used in NSUserDefaults for storing settings related to this MultiParser.


resultArray

- (NSMutableArray *)resultArray

Return the resulting array of dictionaries after a load.


setFilterSelector:target:

- (void)setFilterSelector:(SEL)inSelector target:(id)inTarget

Set the method to be invoked to determine if a new record should be added to the result list. This is useful for weeding out duplicates, since multiple sites will be invoked. The selector is for a method like - (BOOL) canAddRecord:(NSDictionary *)inRecord. If not specified, no filtering will occur.


startNewSearchWithInputs:

- (void)startNewSearchWithInputs:(NSDictionary *)inInputs

Begin a new search. The dictionary of inputs are in a canonical form; the corresponding inputs to each request is stored at the top level of each parse dictionary. Only the sites checked in the user interface, out of all possible sites, are invoked.


startNewSearchWithInputs:parsingDicts:

- (void)startNewSearchWithInputs:(NSDictionary *)inInputs parsingDicts:(NSDictionary *)inParsingDicts

Begin a new search as above, using only the supplied dictionary of parsing dicts (and further filtered by user settings). This is useful if the client wants to choose which parsing dicts to use first, based on other factors.


stopLoading

- (void)stopLoading

Stop loading of all pages.


translateUserInputs:withParsingDict:

- (NSDictionary *)translateUserInputs:(NSDictionary *)inUserInputs withParsingDict:(NSDictionary *)inParsingDict

Convert the "meta" input names found in the parsing dictionary to the real inputs needed by the search engine.


Version 1.1 Copyright ©2003 by Karelia Software, LLC. All Rights Reserved.