CatNiP prefinal
Sähköinen nuottikirja, HY-TKTKL-OHTUPROJ KESÄ11
MediaWikiQuery Class Reference

A basic URL fetch class that reads the given URL into an NSData object and passes it on to it's delegate once the process has finished. More...

#import <MediaWikiQuery.h>

Inheritance diagram for MediaWikiQuery:

List of all members.

Public Member Functions

(void) - addProgressListener:
 Adds a progress listener object to this object's listeners.
(NSString *) - buildQueryURL
 Builds the query URL, intended to be easily re-implemented in sublcasses.
(void) - connection:didFailWithError:
 NSURLConnection delegate method.
(void) - connection:didReceiveData:
 NSURLConnection delegate method.
(void) - connection:didReceiveResponse:
 NSURLConnection delegate method.
(void) - connectionDidFinishLoading:
 NSURLConnection delegate method.
(void) - dealloc [implementation]
(id) - init [implementation]
 Initializes the object.
(id) - initWithDelegate:
 Initialize a new MediaWikiQuery object with the specified delegate.
(id) - initWithDelegate:mediaWikiURL:
 Initialize a new MediaWikiQuery object with the specified delegate and MediaWiki URL (as a string)
(void) - removeProgressListener:
 Removes a progress listener object from this object's listeners.
(BOOL) - startQuery
 Launches the query process.

Protected Attributes

NSURLConnection * mediaWikiConnection
NSURLRequest * mediaWikiRequest
NSMutableSet * progressListeners
id< MediaWikiQueryDelegatequeryDelegate
NSMutableData * receivedData
BOOL working

Properties

NSInteger currentBytes
 Manual accessor for currentBytes.
NSInteger expectedSize
 Manual accessor for expectedSize.
NSString * mediaWikiURLString
 The base URL for this MediaWiki query.

Detailed Description

A basic URL fetch class that reads the given URL into an NSData object and passes it on to it's delegate once the process has finished.

Created by Antti V J Niemela, tkol on 5/24/11. Copyright 2011 University of Helsinki. All rights reserved.

Definition at line 17 of file MediaWikiQuery.h.


Member Function Documentation

- (void) addProgressListener: (id <MediaWikiProgressListener>)  listener

Adds a progress listener object to this object's listeners.

Progress Listeners receive periodic updates on the progress of the data transfer taking place. Multiple listeners are supported.

Parameters:
listenerA MediaWikiProgressListener that should receive updates.

Definition at line 204 of file MediaWikiQuery.m.

References progressListeners.

Here is the caller graph for this function:

- (NSString *) buildQueryURL

Builds the query URL, intended to be easily re-implemented in sublcasses.

Builds the query URL.

The URL is based on the mediaWikiURString property. Subclasses of MediaWikiQuery will likely want to override this method.

Returns:
The URL to be used when attempting the connection

Reimplemented in MediaWikiCategoryQuery, and MediaWikiPageQuery.

Definition at line 87 of file MediaWikiQuery.m.

Here is the caller graph for this function:

- (void) connection: (NSURLConnection *)  connection
didFailWithError: (NSError *)  error 

NSURLConnection delegate method.

NSURLConnectionDelegate implementation, reports the error with NSLog.

Definition at line 172 of file MediaWikiQuery.m.

References mediaWikiConnection, receivedData, CatNiPErrorManager::reportError:, CatNiPErrorManager::sharedManager, and working.

Here is the call graph for this function:

- (void) connection: (NSURLConnection *)  connection
didReceiveData: (NSData *)  data 

NSURLConnection delegate method.

NSURLConnectionDelegate implementation, reads the data into an internal variable.

Definition at line 159 of file MediaWikiQuery.m.

References currentBytes, progressListeners, and receivedData.

- (void) connection: (NSURLConnection *)  connection
didReceiveResponse: (NSURLResponse *)  response 

NSURLConnection delegate method.

NSURLConnectionDelegate implementation, resets the internal data buffer (only the data from the last response is stuff we're interested in).

Definition at line 143 of file MediaWikiQuery.m.

References expectedSize, and receivedData.

- (void) connectionDidFinishLoading: (NSURLConnection *)  connection

NSURLConnection delegate method.

NSURLConnectionDelegate implementation, passes the received data to the delegate.

Definition at line 187 of file MediaWikiQuery.m.

References mediaWikiConnection, queryDelegate, receivedData, and working.

- (void) dealloc [implementation]
- (id) init [implementation]

Initializes the object.

Reimplemented in MediaWikiCategoryQuery, and MediaWikiPageQuery.

Definition at line 40 of file MediaWikiQuery.m.

References currentBytes, expectedSize, and progressListeners.

Here is the caller graph for this function:

- (id) initWithDelegate: (id <MediaWikiQueryDelegate>)  mediaWikiQueryDelegate

Initialize a new MediaWikiQuery object with the specified delegate.

Initializes the object with the specified delegate.

Parameters:
mediaWikiQueryDelegateThe delegate object that will receive the data read from the URL
Returns:
id pointer to the initialized object.

Definition at line 54 of file MediaWikiQuery.m.

References init, queryDelegate, and working.

Here is the call graph for this function:

Here is the caller graph for this function:

- (id) initWithDelegate: (id <MediaWikiQueryDelegate>)  mediaWikiQueryDelegate
mediaWikiURL: (NSString*)  mwURLString 

Initialize a new MediaWikiQuery object with the specified delegate and MediaWiki URL (as a string)

Initializes the object with the specified delegate and MediaWiki URL.

Parameters:
mediaWikiQueryDelegateThe delegate object that will receive the data read from the URL
mwURLStringThe URL to read from.
Returns:
id pointer to the initialized object.

Definition at line 71 of file MediaWikiQuery.m.

References initWithDelegate:.

Here is the call graph for this function:

Here is the caller graph for this function:

- (void) removeProgressListener: (id <MediaWikiProgressListener>)  listener

Removes a progress listener object from this object's listeners.

Parameters:
listenerThe listener to remove from this object's listener set.

Definition at line 217 of file MediaWikiQuery.m.

References progressListeners.

- (BOOL) startQuery

Launches the query process.

Starts the MediaWiki query.

Starts the HTTP query represented by the URL received using [self buildQueryURL] using an internal NSURLConnection object. This object functions as the delegate for the NSURLConnection, and passes the read data to it's delegate once the connection finishes loading.

Returns:
YES if the connection started succesfully, NO if the URL was malformed or this object was already in the middle of reading data

Definition at line 99 of file MediaWikiQuery.m.

References buildQueryURL, mediaWikiConnection, mediaWikiRequest, receivedData, CatNiPErrorManager::reportError:, CatNiPErrorManager::sharedManager, and working.

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

- (NSURLConnection*) mediaWikiConnection [protected]

Definition at line 21 of file MediaWikiQuery.h.

- (NSURLRequest*) mediaWikiRequest [protected]

Definition at line 20 of file MediaWikiQuery.h.

- (NSMutableSet*) progressListeners [protected]

Definition at line 23 of file MediaWikiQuery.h.

Definition at line 18 of file MediaWikiQuery.h.

- (NSMutableData*) receivedData [protected]

Definition at line 22 of file MediaWikiQuery.h.

- (BOOL) working [protected]

Definition at line 26 of file MediaWikiQuery.h.


Property Documentation

- (NSInteger) currentBytes [read, assign]

Manual accessor for currentBytes.

Returns:
The number of bytes of data received from the target host.

Definition at line 25 of file MediaWikiQuery.h.

- (NSInteger) expectedSize [read, assign]

Manual accessor for expectedSize.

Only available once a NSURLResponse has been received from the target host. Returns NSIntegerMin if a response has not yet been received, and -1 when a response has been received but it did not contain information on the size of the response.

Returns:
The expected size (in 8-bit bytes) of the file, NSIntegerMin or -1.

Definition at line 24 of file MediaWikiQuery.h.

- (NSString *) mediaWikiURLString [read, write, copy]

The base URL for this MediaWiki query.

Definition at line 19 of file MediaWikiQuery.h.


The documentation for this class was generated from the following files:
 All Classes Files Functions Variables Enumerations Enumerator Properties Defines