IDS::DataSource::HTTP::Part

Introduction

A common superclass for parts of an HTTP request. All real uses will be through subclasses.

We expect descendents to:

Whenever a string is loaded, parse then (no lazy evaluation). This is because *we* have the function to return the tokens.
Parameters relating to parsing are in the "params" entry, which is a hash reference. It is initialized here.
An optional initializer follows the parameters to new.
Elements of self:
data => the data that caused the parse that we have
tokens => The results of the parse
params => parameters that may affect parsing
The subclass must implement the following functions: parse, empty
parameters() =item parameters(param) =item parameters(param, value, ...)

Set or retrieve the current parameters (individual or group).

default_parameters()

Sets all of the default values for the parameters. Normally called by new() or one of its descendents.

handle_parameters($self, @_)

Handle the parameter string that IDS::Algorithm::new() will accept. Extracted from new() for subclass usage. Returns a filehandle if we were called with a filehandle from which to load.

cleanup

Clean data to prepare for tokenizing.

data()

Return the data used for the tokens we have. If called in array mode, we return the inidividual lines, otherwise the join of those line.

postdata()

Return the data part of a POST request. Only has meaning in a POST request.

source() =item source(value)

Set and/or get the data source.

tokens()

Return the tokens that result from parsing the structure. The tokens can be returned as an array or a reference to the internal array holding them (for efficiency). Modify this referenced array at your own risk.

Note that this function can remove values. Note that this function can convert everything to lower case. Both of these options are controlled by parameters, and neither affects the internal version of the tokens.

expand_pct(data)

Expand the %-substitutions. This function currently does not handle unicode and &-expansions. Should it?

Functions for subclasses

The followng functions are required in subclasses.

parse()

Parse the structure and return the resulting tokens.

empty()

Delete all data in preparation for loading new data.

AUTHOR INFORMATION

Copyright 2005-2007, Kenneth Ingham. All rights reserved.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

Address bug reports and comments to: ids_test at i-pi.com. When sending bug reports, please provide the versions of IDS::Test.pm, IDS::Algorithm.pm, IDS::DataSource.pm, the version of Perl, and the name and version of the operating system you are using. Since Kenneth is a PhD student, the speed of the reponse depends on how the research is proceeding.

BUGS

Please report them.

SEE ALSO

IDS::Algorithm, IDS::DataSource