annotate Lib/IMPL/DOM/Navigator.pm @ 17:7f88e01b58f8

dom
author Sergey
date Wed, 09 Sep 2009 17:43:31 +0400
parents bb8d67f811ea
children 818c74b038ae
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
1 package IMPL::DOM::Navigator;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
2 use strict;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
3 use warnings;
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
4
11
75980091813b DOM и навигация
Sergey
parents: 0
diff changeset
5 use base qw(IMPL::Object);
75980091813b DOM и навигация
Sergey
parents: 0
diff changeset
6 use IMPL::Class::Property;
75980091813b DOM и навигация
Sergey
parents: 0
diff changeset
7 use IMPL::Class::Property::Direct;
75980091813b DOM и навигация
Sergey
parents: 0
diff changeset
8 BEGIN {
75980091813b DOM и навигация
Sergey
parents: 0
diff changeset
9 public _direct property Path => prop_get | owner_set;
75980091813b DOM и навигация
Sergey
parents: 0
diff changeset
10 public _direct property Current => prop_get | owner_set;
75980091813b DOM и навигация
Sergey
parents: 0
diff changeset
11 }
75980091813b DOM и навигация
Sergey
parents: 0
diff changeset
12
75980091813b DOM и навигация
Sergey
parents: 0
diff changeset
13 sub CTOR {
75980091813b DOM и навигация
Sergey
parents: 0
diff changeset
14 my ($this,$CurrentNode) = @_;
75980091813b DOM и навигация
Sergey
parents: 0
diff changeset
15
75980091813b DOM и навигация
Sergey
parents: 0
diff changeset
16 $this->{$Current} = $CurrentNode or die IMPL::InvalidArgumentException("A starting node is a required paramater");
75980091813b DOM и навигация
Sergey
parents: 0
diff changeset
17 }
0
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
18
11
75980091813b DOM и навигация
Sergey
parents: 0
diff changeset
19 sub Navigate {
75980091813b DOM и навигация
Sergey
parents: 0
diff changeset
20 my ($this,$query) = @_;
75980091813b DOM и навигация
Sergey
parents: 0
diff changeset
21
75980091813b DOM и навигация
Sergey
parents: 0
diff changeset
22 if ( my ($newNode) = $this->{$Current}->selectNodes($query) ) {
75980091813b DOM и навигация
Sergey
parents: 0
diff changeset
23 push @{$this->{$Path}}, $this->{$Current};
75980091813b DOM и навигация
Sergey
parents: 0
diff changeset
24 return $this->{$Current} = $newNode;
75980091813b DOM и навигация
Sergey
parents: 0
diff changeset
25 } else {
75980091813b DOM и навигация
Sergey
parents: 0
diff changeset
26 return undef;
75980091813b DOM и навигация
Sergey
parents: 0
diff changeset
27 }
75980091813b DOM и навигация
Sergey
parents: 0
diff changeset
28 }
0
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
29
11
75980091813b DOM и навигация
Sergey
parents: 0
diff changeset
30 sub Back {
75980091813b DOM и навигация
Sergey
parents: 0
diff changeset
31 my ($this) = @_;
75980091813b DOM и навигация
Sergey
parents: 0
diff changeset
32
75980091813b DOM и навигация
Sergey
parents: 0
diff changeset
33 if ( my $newNode = $this->{$Path} ? pop @{$this->{$Path}} : undef ) {
75980091813b DOM и навигация
Sergey
parents: 0
diff changeset
34 return $this->{$Current} = $newNode;
75980091813b DOM и навигация
Sergey
parents: 0
diff changeset
35 } else {
75980091813b DOM и навигация
Sergey
parents: 0
diff changeset
36 return undef;
75980091813b DOM и навигация
Sergey
parents: 0
diff changeset
37 }
75980091813b DOM и навигация
Sergey
parents: 0
diff changeset
38 }
75980091813b DOM и навигация
Sergey
parents: 0
diff changeset
39
75980091813b DOM и навигация
Sergey
parents: 0
diff changeset
40 sub PathToString {
75980091813b DOM и навигация
Sergey
parents: 0
diff changeset
41 my $this = shift;
75980091813b DOM и навигация
Sergey
parents: 0
diff changeset
42
75980091813b DOM и навигация
Sergey
parents: 0
diff changeset
43 join('/',map $_->nodeName, $this->{$Path} ? (@{$this->{$Path}}, $this->{$Current}) : $this->{$Current});
75980091813b DOM и навигация
Sergey
parents: 0
diff changeset
44 }
0
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
45
03e58a454b20 Создан репозитарий
Sergey
parents:
diff changeset
46 1;
11
75980091813b DOM и навигация
Sergey
parents: 0
diff changeset
47
75980091813b DOM и навигация
Sergey
parents: 0
diff changeset
48 __END__
75980091813b DOM и навигация
Sergey
parents: 0
diff changeset
49 =pod
75980091813b DOM и навигация
Sergey
parents: 0
diff changeset
50
75980091813b DOM и навигация
Sergey
parents: 0
diff changeset
51 =head1 DESCRIPTION
75980091813b DOM и навигация
Sergey
parents: 0
diff changeset
52
75980091813b DOM и навигация
Sergey
parents: 0
diff changeset
53 DOM .
75980091813b DOM и навигация
Sergey
parents: 0
diff changeset
54
75980091813b DOM и навигация
Sergey
parents: 0
diff changeset
55 =head1 METHODS
75980091813b DOM и навигация
Sergey
parents: 0
diff changeset
56
75980091813b DOM и навигация
Sergey
parents: 0
diff changeset
57 =over
75980091813b DOM и навигация
Sergey
parents: 0
diff changeset
58
75980091813b DOM и навигация
Sergey
parents: 0
diff changeset
59 =item C<$obj->new($nodeStart)>
75980091813b DOM и навигация
Sergey
parents: 0
diff changeset
60
75980091813b DOM и навигация
Sergey
parents: 0
diff changeset
61 .
75980091813b DOM и навигация
Sergey
parents: 0
diff changeset
62
75980091813b DOM и навигация
Sergey
parents: 0
diff changeset
63 =item C<$obj->Navigate($query)>
75980091813b DOM и навигация
Sergey
parents: 0
diff changeset
64
75980091813b DOM и навигация
Sergey
parents: 0
diff changeset
65 C<$query>.
75980091813b DOM и навигация
Sergey
parents: 0
diff changeset
66 .
75980091813b DOM и навигация
Sergey
parents: 0
diff changeset
67 , .
75980091813b DOM и навигация
Sergey
parents: 0
diff changeset
68
75980091813b DOM и навигация
Sergey
parents: 0
diff changeset
69 , C<undef>.
75980091813b DOM и навигация
Sergey
parents: 0
diff changeset
70
75980091813b DOM и навигация
Sergey
parents: 0
diff changeset
71 =item C<$obj->Back()>
75980091813b DOM и навигация
Sergey
parents: 0
diff changeset
72
75980091813b DOM и навигация
Sergey
parents: 0
diff changeset
73 , .
75980091813b DOM и навигация
Sergey
parents: 0
diff changeset
74
75980091813b DOM и навигация
Sergey
parents: 0
diff changeset
75 , C<undef>.
75980091813b DOM и навигация
Sergey
parents: 0
diff changeset
76
75980091813b DOM и навигация
Sergey
parents: 0
diff changeset
77 =back
75980091813b DOM и навигация
Sergey
parents: 0
diff changeset
78
75980091813b DOM и навигация
Sergey
parents: 0
diff changeset
79 =cut