The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Repository::Simple::Node - Repository nodes

SYNOPSIS

The following code can be found in ex/print_nodes.pl:

  use Repository::Simple;

  sub print_node;

  my $repository = Repository::Simple->attach(
      FileSystem => root => $ARGV[0],
  );

  my $node = $repository->root_node;
  print_node($node, 0);

  sub print_node {
      my ($node, $depth) = @_;
      
      print "\t" x $depth, " * ", $node->name, "\n";

      for my $child ($node->nodes) {
          print_node($child, $depth + 1);
      }

      for my $p ($node->properties) {
          print "\t" x $depth, "\t * ", $p->name, " = ", $p->value, "\n";
      }
  }

DESCRIPTION

Each instance of this class describes a node in a repository. A node is basically a unit of information described by a path.

To retrieve an instance of this type, you never construct this object directly. Instead, use one of the node access methods in Repository::Simple and Repository::Simple::Node:

  my $root = $repository->root_node;
  my @children = $root->nodes;

METHODS

$repository = $node->repository

Returns the Repository::Simple object to which this node belongs.

$node = $type->parent

Fetch the node that is the parent of this node. This will always return a node, even for the root node. The root node is the parent of itself.

If you consider time travel, you may wish to stop yourself before you think too hard on the implications and gross yourself out.

$name = $node->name

Fetch the name of the node. This will always be the last element of the node's path. That is, if the path of the node is:

  /foo/bar/baz

then the name of the node is:

  baz

In this API it has been decided that the root node will be represented by the string "/" to match with the normal Unix practice of naming the root tree object. The root node must have this name and no other node may have this name.

$path = $node->path

This returns the full path from the root of the tree to this node.

@nodes = $node->nodes

Returns all the child nodes of this node.

@properties = $node->properties

Returns all the proeprties of this node.

$type = $node->type

Returns the Repository::Simple::Type::Node object describing the node.

AUTHOR

Andrew Sterling Hanenkamp, <hanenkamp@cpan.org>

LICENSE AND COPYRIGHT

Copyright 2005 Andrew Sterling Hanenkamp <hanenkamp@cpan.org>. All Rights Reserved.

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

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.