annotate Lib/IMPL/DOM/Schema/SwitchNode.pm @ 391:2287c72f303a

code cleanup
author cin
date Thu, 13 Feb 2014 20:17:22 +0400
parents 5aff94ba842f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 24
diff changeset
1 package IMPL::DOM::Schema::SwitchNode;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 24
diff changeset
2 use strict;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 24
diff changeset
3 use warnings;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 24
diff changeset
4
389
5aff94ba842f DOM Schema refactoring complete
cin
parents: 238
diff changeset
5 use IMPL::declare {
5aff94ba842f DOM Schema refactoring complete
cin
parents: 238
diff changeset
6 require => {
5aff94ba842f DOM Schema refactoring complete
cin
parents: 238
diff changeset
7 Label => 'IMPL::DOM::Schema::Label',
5aff94ba842f DOM Schema refactoring complete
cin
parents: 238
diff changeset
8 ValidationError => 'IMPL::DOM::Schema::ValidationError'
5aff94ba842f DOM Schema refactoring complete
cin
parents: 238
diff changeset
9 },
5aff94ba842f DOM Schema refactoring complete
cin
parents: 238
diff changeset
10 base => [
5aff94ba842f DOM Schema refactoring complete
cin
parents: 238
diff changeset
11 'IMPL::DOM::Schema::AnyNode' => sub {
5aff94ba842f DOM Schema refactoring complete
cin
parents: 238
diff changeset
12 my %args = @_;
5aff94ba842f DOM Schema refactoring complete
cin
parents: 238
diff changeset
13
5aff94ba842f DOM Schema refactoring complete
cin
parents: 238
diff changeset
14 $args{nodeName} ||= 'SwitchNode';
5aff94ba842f DOM Schema refactoring complete
cin
parents: 238
diff changeset
15
5aff94ba842f DOM Schema refactoring complete
cin
parents: 238
diff changeset
16 %args;
5aff94ba842f DOM Schema refactoring complete
cin
parents: 238
diff changeset
17 }
5aff94ba842f DOM Schema refactoring complete
cin
parents: 238
diff changeset
18 ],
5aff94ba842f DOM Schema refactoring complete
cin
parents: 238
diff changeset
19 props => [
5aff94ba842f DOM Schema refactoring complete
cin
parents: 238
diff changeset
20 messageNoMatch => { get => 1, set => 1, dom => 1 }
5aff94ba842f DOM Schema refactoring complete
cin
parents: 238
diff changeset
21 ]
5aff94ba842f DOM Schema refactoring complete
cin
parents: 238
diff changeset
22 };
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 24
diff changeset
23
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 24
diff changeset
24 sub CTOR {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 24
diff changeset
25 my ($this,%args) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 24
diff changeset
26
238
b8c724f6de36 DOM model refactoring
sergey
parents: 236
diff changeset
27 $this->messageNoMatch($args{messageNoMatch} || 'A node %node.nodeName% isn\'t expected in the %parent.path%');
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 24
diff changeset
28 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 24
diff changeset
29
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 24
diff changeset
30 sub Validate {
125
a4b0a819bbda Small fixes in IMPL::DOM::Schema
wizard
parents: 49
diff changeset
31 my ($this,$node,$ctx) = @_;
a4b0a819bbda Small fixes in IMPL::DOM::Schema
wizard
parents: 49
diff changeset
32
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 24
diff changeset
33 if ( my ($schema) = $this->selectNodes(sub {$_[0]->name eq $node->nodeName} ) ) {
389
5aff94ba842f DOM Schema refactoring complete
cin
parents: 238
diff changeset
34 return $schema->Validate($node,$ctx);
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 24
diff changeset
35 } else {
389
5aff94ba842f DOM Schema refactoring complete
cin
parents: 238
diff changeset
36 return ValidationError->new(
236
2904da230022 DOM refactoring
sergey
parents: 180
diff changeset
37 node => $node,
389
5aff94ba842f DOM Schema refactoring complete
cin
parents: 238
diff changeset
38 message => $this->_MakeLabel($this->messageNoMatch)
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 24
diff changeset
39 );
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 24
diff changeset
40 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 24
diff changeset
41 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 24
diff changeset
42
389
5aff94ba842f DOM Schema refactoring complete
cin
parents: 238
diff changeset
43 sub _MakeLabel {
5aff94ba842f DOM Schema refactoring complete
cin
parents: 238
diff changeset
44 my ($this,$label) = @_;
5aff94ba842f DOM Schema refactoring complete
cin
parents: 238
diff changeset
45
5aff94ba842f DOM Schema refactoring complete
cin
parents: 238
diff changeset
46 if ($label =~ /^ID:(\w+)$/) {
5aff94ba842f DOM Schema refactoring complete
cin
parents: 238
diff changeset
47 return Label->new($this->document->stringMap, $1);
5aff94ba842f DOM Schema refactoring complete
cin
parents: 238
diff changeset
48 } else {
5aff94ba842f DOM Schema refactoring complete
cin
parents: 238
diff changeset
49 return $label;
5aff94ba842f DOM Schema refactoring complete
cin
parents: 238
diff changeset
50 }
5aff94ba842f DOM Schema refactoring complete
cin
parents: 238
diff changeset
51 }
5aff94ba842f DOM Schema refactoring complete
cin
parents: 238
diff changeset
52
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 24
diff changeset
53 1;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 24
diff changeset
54
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 24
diff changeset
55 __END__
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 24
diff changeset
56
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 24
diff changeset
57 =pod
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 24
diff changeset
58
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 24
diff changeset
59 =head1 DESCRIPTION
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 24
diff changeset
60
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 165
diff changeset
61 Представляет узел, который может быть одним из узлов, которые лежат внутри него.
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 165
diff changeset
62 Это более строгий вариант C<IMPL::DOM::Schema::AnyNode>.
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 24
diff changeset
63
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 24
diff changeset
64 =cut