<<

NAME

Web::Node - Basic doomfiles node object, a bundle of all the information that makes up a doomfiles page

SYNOPSIS

  use Web::Node;

  $node1 = Web::Node->new($node_name_1);
  $node1->body($main_body_ref);

  print $node1->prev(); # undef

  $node2 = Web::Node->new();  # node name left blank for now
  $node2->name($node_name_2);

  $node2->prev($node1);
  $node1->next($node2);

  print $node2->next(); # shows undef

  # Chained methods access:
  $name_from_node4 = $node1->next->next->next->name;

DESCRIPTION

Basic node class for the DF project: holds the data that make up a DF page. The methods here consist entirely of accessor/getters (and some deprecated mutators).

Every node should have a name which matches the $DF_NODE_NAME_PINNED_RULE which is defined in Web::Definitions. A typical example of a matching name: UPPERCASE_WITH_UNDERSCORES

TODO - make it impossible to create a node without a name.

This is used by the "Chain" class, which has methods to generate and parse different formats, to manipulate chains, and to validate them. (The Chain class is reponsible for ensuring that the names are unique for each node of the chain.)

METHODS

new - creates a new node object with given name if supplied (this can be deferred and set with "name" later).

SETTERS and GETTERS

Simple routines that either assign values to an object attribute (named set_*), or return existing values (named get_*).

Originally I thought mutators would be more convenient but (a) there's a clear need to be able to assign undefs, so the undef can't be used to signal a get; (b) I believe the code reads a little more clearly if assignment is flagged with the prefix "set_". (Though to my eye, the need for "get_" is a little less clear.)

The setters (which all take Web::Node objects as arguments):

set_prev - sets the pointer to the previous node in the chain

set_next - sets the pointer to the next node in the chain

Setters that take references, and croak if they're given anything else.

set_body - sets the main body (the text content) of the doomfiles node expected to be a reference to a string.

GETTERS

Methods that return the value of an object attribute.

get_name - return the name of the node (A short string, typically uppercase with underscores).

get_prev - returns the pointer to the previous node in the chain (Another node object)

get_next - returns the pointer to the next node in the chain (Another node object)

body - gets the main body (the text content) of the doomfiles node expected to be a reference to a string.

MUTATORS

Mutators set arguments if provided, and if not just return existing setting. First, mutators that take simple strings (not a ref):

TODO: make sure that these are no longer in use, and delete them. Then rename getters from get_foo to just foo.

name -

Mutators that take Web::Node objects:

prev - sets or gets the pointer to the previous node in the chain

next - sets or gets the pointer to the next node in the chain

Mutators that take references, and carp if they're given anything else.

body - sets or gets the main body (the text content) of the doomfiles node

INTERNAL ROUTINES

Note, some of the following are used internally by this package, some are used "internally" by the project.

_dump_contents_to_stderr - used internally by this project to assist in debugging. Dumps node contents (name of node, name of previous and next nodes, the node body) in a simple textual form to STDERR.

PROCEEDURAL FUNCTIONS

Some proceedural (i.e. not OOP) utilities , used internally by this package

_check_name - Makes sure the name is in doomfiles node name format Croaks in the event of a bad name argument.

FUTURE DEVELOPMENT

Notes for future development:

As written nothing prevents next or prev from pointing at any node. Possibly the linear chain idea should be enforced on the level of the Chain object...

Idea: in the future, add a capability to store the names of identified links in the body, perhaps with locations, e.g. byte offset(s). This "out of band" link info might be used for a link checking in the Chain object

EXPORT

None by default.

SEE ALSO

Project Documentation

Web::Chain

AUTHOR

Joseph Brenner, <doom@kzsu.stanford.edu>

COPYRIGHT AND LICENSE

Copyright (C) 2004 by Joseph Brenner

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.2 or, at your option, any later version of Perl 5 you may have available.

BUGS

None reported... yet.

<<