comparison Lib/IMPL/DOM/Navigator.pm @ 235:a4d9126edcbb

code cleaning
author sergey
date Fri, 12 Oct 2012 02:08:51 +0400
parents 4d0e1962161c
children b8c724f6de36
comparison
equal deleted inserted replaced
234:2530d1bb9638 235:a4d9126edcbb
45 if (my $current = $this->Current) { 45 if (my $current = $this->Current) {
46 46
47 my @alternatives = $current->selectNodes($query); 47 my @alternatives = $current->selectNodes($query);
48 48
49 unless (@alternatives) { 49 unless (@alternatives) {
50 $current = $this->advanceNavigator or return undef; 50 $current = $this->advanceNavigator or return;
51 @alternatives = $current->selectNodes($query); 51 @alternatives = $current->selectNodes($query);
52 } 52 }
53 53
54 push @{$this->{$_path}},$this->{$_state}; 54 push @{$this->{$_path}},$this->{$_state};
55 $this->{$_state} = { 55 $this->{$_state} = {
58 query => $query 58 query => $query
59 }; 59 };
60 60
61 $node = $alternatives[0]; 61 $node = $alternatives[0];
62 } else { 62 } else {
63 return undef; 63 return;
64 } 64 }
65 } 65 }
66 66
67 $node; 67 $node;
68 } 68 }
101 101
102 if (@{$this->{$_state}{alternatives}} <= $this->{$_state}{current}) { 102 if (@{$this->{$_state}{alternatives}} <= $this->{$_state}{current}) {
103 if ( exists $this->{$_state}{query} ) { 103 if ( exists $this->{$_state}{query} ) {
104 my $query = $this->{$_state}{query}; 104 my $query = $this->{$_state}{query};
105 105
106 $this->Back or return undef; # that meams the end of the history 106 $this->Back or return; # that meams the end of the history
107 107
108 undef while ( $this->advanceNavigator and not $this->Navigate($query)); 108 undef while ( $this->advanceNavigator and not $this->Navigate($query));
109 109
110 return $this->Current; 110 return $this->Current;
111 } 111 }
112 return undef; 112 return;
113 } 113 }
114 114
115 return $this->Current; 115 return $this->Current;
116 } 116 }
117 117
140 140
141 $this->{$_state} = (splice @{$this->{$_path}},-$steps)[0]; 141 $this->{$_state} = (splice @{$this->{$_path}},-$steps)[0];
142 } 142 }
143 $this->Current if defined wantarray; 143 $this->Current if defined wantarray;
144 } else { 144 } else {
145 return undef; 145 return;
146 } 146 }
147 } 147 }
148 148
149 sub PathToString { 149 sub PathToString {
150 my ($this,$delim) = @_; 150 my ($this,$delim) = @_;
163 my ($this,$index) = @_; 163 my ($this,$index) = @_;
164 164
165 if (my $state = $this->{$_path} ? $this->{$_path}->[$index] : undef ) { 165 if (my $state = $this->{$_path} ? $this->{$_path}->[$index] : undef ) {
166 return $state->{alternatives}[$state->{current}] 166 return $state->{alternatives}[$state->{current}]
167 } else { 167 } else {
168 return undef; 168 return;
169 } 169 }
170 } 170 }
171 171
172 sub clone { 172 sub clone {
173 my ($this) = @_; 173 my ($this) = @_;
218 $result = $transaction->(); 218 $result = $transaction->();
219 }; 219 };
220 220
221 if ($@) { 221 if ($@) {
222 $this->restoreState(); 222 $this->restoreState();
223 return undef; 223 return;
224 } else { 224 } else {
225 $this->applyState(); 225 $this->applyState();
226 return $result; 226 return $result;
227 } 227 }
228 } 228 }