Chris Josephes > ubertext > Text::UberText::Tree

Download:
ubertext-0.95.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  0
Report a bug
Module Version: 0.95   Source  

NAME ^

Text::UberText::Tree - Tree Representation Of UberText Document

DESCRIPTION ^

An UberText document can have command blocks that enclose other commands or text within the document. Because of this, the document needs to be structured like a tree to keep track of the relationships of the commands and text. Some parts of the document are siblings in relation, others have children, and all parts have a parent.

Each broken down portion of the document is refered to as a node, and each node can represent either a command, or a piece of text. If the command acts as a container block, it will have an understanding of several child nodes that must also be processed when the command is run by the Text::UberText::Dispatch object.

METHODS ^

$tree=Text::UberTree->new();

Creates a new tree object.

$tree->addNode(-text => $string, -line $line, -class => $class);

Adds a hunk of text to the tree. The $string variable refers to the raw text, and $line refers to the line number in the source document. The $class variable points to which Node class this data should be assigned to (either Text::UberText::Node::Text, or Text::UberText::Node::Command).

$tree->showTree();

Shows the breakdown of the document tree, which may be useful for debugging purposes.

$tree->run();

Processes each top level node in the tree. If nodes at this level have children, they are expected to handle processing the child nodes themselves.

$tree->children($node_id);

Returns a list of children for a particular node id. Zero (0) is used by default, and is considered the topmost node in the document.

$tree->output($node_id);

Returns the output of the tree for all child nodes of $node_id. Zero (0) is used by default since it is the highest node in the tree.

$tree->debugOutput($node_id);

Returns the document output like the output() method, but prefixes the actual node output with the id number of the node.

$tree->node($node_id);

Returns a single Node object, based on the ID passed to it.

AUTHOR ^

Chris Josephes <cpj1@visi.com>

SEE ALSO ^

Text::UberText::Node, Text::UberText::Dispatch

COPYRIGHT ^

Copyright 2002, Chris Josephes. All rights reserved. This module is free software. It may be used, redistributed, and/or modified under the same terms as Perl itself. ~