1Tree::Simple::Visitor::UFsienrdBCyoPnattrhi(b3u)ted PerlTrDeoec:u:mSeinmtpaltei:o:nVisitor::FindByPath(3)
2
3
4

NAME

6       Tree::Simple::Visitor::FindByPath - A Visitor for finding an element in
7       a Tree::Simple hierarchy with a path
8

SYNOPSIS

10         use Tree::Simple::Visitor::FindByPath;
11
12         # create a visitor object
13         my $visitor = Tree::Simple::Visitor::FindByPath->new();
14
15         # set the search path for our tree
16         $visitor->setSearchPath(qw(1 1.2 1.2.2));
17
18         # pass the visitor to a tree
19         $tree->accept($visitor);
20
21         # fetch the result, which will
22         # be the Tree::Simple object that
23         # we have found, or undefined
24         my $result = $visitor->getResult() || die "No Tree found";
25
26         # our result's node value should match
27         # the last element in our path
28         print $result->getNodeValue(); # this should print 1.2.2
29

DESCRIPTION

31       Given a path and Tree::Simple hierarchy, this Visitor will attempt to
32       find the node specified by the path.
33

METHODS

35       new There are no arguments to the constructor the object will be in its
36           default state. You can use the "setSearchPath" and "setNodeFilter"
37           methods to customize its behavior.
38
39       includeTrunk ($boolean)
40           Based upon the value of $boolean, this will tell the visitor to
41           include the trunk of the tree in the search as well.
42
43       setSearchPath (@path)
44           This is the path we will attempt to follow down the tree. We will
45           do a stringified comparison of each element of the path and the
46           current tree's node (or the value returned by the node filter if it
47           is set).
48
49       setNodeFilter ($filter_function)
50           This method accepts a CODE reference as its $filter_function
51           argument and throws an exception if it is not a code reference.
52           This code reference is used to filter the tree nodes as they are
53           collected. This can be used to customize output, or to gather
54           specific information from a more complex tree node. The filter
55           function should accept a single argument, which is the current
56           Tree::Simple object.
57
58       visit ($tree)
59           This is the method that is used by Tree::Simple's "accept" method.
60           It can also be used on its own, it requires the $tree argument to
61           be a Tree::Simple object (or derived from a Tree::Simple object),
62           and will throw and exception otherwise.
63
64       getResult
65           This method will return the tree found at the specified path (set
66           by the "setSearchPath" method) or "undef" if no tree is found.
67
68       getResults
69           This method will return the tree's that make up the path specified
70           in "setSearchPath". In the case of a failed search, this can be
71           used to find the elements which did successfully match along the
72           way.
73

Repository

75       <https://github.com/ronsavage/Tree-Simple-VisitorFactory>
76

SUPPORT

78       Bugs should be reported via the CPAN bug tracker at
79
80       <https://github.com/ronsavage/Tree-Simple-VisitorFactory/issues>
81

CODE COVERAGE

83       See the CODE COVERAGE section in Tree::Simple::VisitorFactory for more
84       information.
85

SEE ALSO

87       These Visitor classes are all subclasses of Tree::Simple::Visitor,
88       which can be found in the Tree::Simple module, you should refer to that
89       module for more information.
90

AUTHOR

92       stevan little, <stevan@iinteractive.com>
93
95       Copyright 2004, 2005 by Infinity Interactive, Inc.
96
97       <http://www.iinteractive.com>
98
99       This library is free software; you can redistribute it and/or modify it
100       under the same terms as Perl itself.
101
102
103
104perl v5.34.0                      2021-07-2T7ree::Simple::Visitor::FindByPath(3)
Impressum