annotate Lib/IMPL/DOM/Schema/Node.pm @ 384:4edd36025051

DOM schema refactoring
author cin
date Mon, 10 Feb 2014 17:41:34 +0400
parents 2f16f13b000c
children 648dfaf642e0
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: 37
diff changeset
1 package IMPL::DOM::Schema::Node;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
2 use strict;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
3 use warnings;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
4
381
ced5937ff21a Custom getters/setters support method names in theirs definitions
cin
parents: 278
diff changeset
5 use IMPL::Const qw(:prop);
ced5937ff21a Custom getters/setters support method names in theirs definitions
cin
parents: 278
diff changeset
6 use IMPL::declare {
383
2f16f13b000c DOM localization
cin
parents: 381
diff changeset
7 require => {
2f16f13b000c DOM localization
cin
parents: 381
diff changeset
8 Label => 'IMPL::DOM::Schema::Label'
2f16f13b000c DOM localization
cin
parents: 381
diff changeset
9 },
381
ced5937ff21a Custom getters/setters support method names in theirs definitions
cin
parents: 278
diff changeset
10 base => [
ced5937ff21a Custom getters/setters support method names in theirs definitions
cin
parents: 278
diff changeset
11 'IMPL::DOM::Node' => sub {
ced5937ff21a Custom getters/setters support method names in theirs definitions
cin
parents: 278
diff changeset
12 my %args = @_;
ced5937ff21a Custom getters/setters support method names in theirs definitions
cin
parents: 278
diff changeset
13 delete @args{qw(
ced5937ff21a Custom getters/setters support method names in theirs definitions
cin
parents: 278
diff changeset
14 minOccur
ced5937ff21a Custom getters/setters support method names in theirs definitions
cin
parents: 278
diff changeset
15 maxOccur
ced5937ff21a Custom getters/setters support method names in theirs definitions
cin
parents: 278
diff changeset
16 type
ced5937ff21a Custom getters/setters support method names in theirs definitions
cin
parents: 278
diff changeset
17 name
ced5937ff21a Custom getters/setters support method names in theirs definitions
cin
parents: 278
diff changeset
18 )} ;
ced5937ff21a Custom getters/setters support method names in theirs definitions
cin
parents: 278
diff changeset
19 $args{nodeName} ||= 'Node';
ced5937ff21a Custom getters/setters support method names in theirs definitions
cin
parents: 278
diff changeset
20 %args
ced5937ff21a Custom getters/setters support method names in theirs definitions
cin
parents: 278
diff changeset
21 }
ced5937ff21a Custom getters/setters support method names in theirs definitions
cin
parents: 278
diff changeset
22 ],
ced5937ff21a Custom getters/setters support method names in theirs definitions
cin
parents: 278
diff changeset
23 props => [
ced5937ff21a Custom getters/setters support method names in theirs definitions
cin
parents: 278
diff changeset
24 minOccur => { get => 1, set => 1, direct => 1, dom => 1},
ced5937ff21a Custom getters/setters support method names in theirs definitions
cin
parents: 278
diff changeset
25 maxOccur => { get => 1, set => 1, direct => 1, dom => 1},
ced5937ff21a Custom getters/setters support method names in theirs definitions
cin
parents: 278
diff changeset
26 type => { get => 1, set => 1, direct => 1, dom => 1},
ced5937ff21a Custom getters/setters support method names in theirs definitions
cin
parents: 278
diff changeset
27 name => { get => 1, set => 1, direct => 1, dom => 1},
ced5937ff21a Custom getters/setters support method names in theirs definitions
cin
parents: 278
diff changeset
28 label => { get => '_getLabel', direct => 1 }
ced5937ff21a Custom getters/setters support method names in theirs definitions
cin
parents: 278
diff changeset
29 ]
ced5937ff21a Custom getters/setters support method names in theirs definitions
cin
parents: 278
diff changeset
30 };
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
31
381
ced5937ff21a Custom getters/setters support method names in theirs definitions
cin
parents: 278
diff changeset
32 sub _getLabel {
ced5937ff21a Custom getters/setters support method names in theirs definitions
cin
parents: 278
diff changeset
33 my ($this) = @_;
ced5937ff21a Custom getters/setters support method names in theirs definitions
cin
parents: 278
diff changeset
34
383
2f16f13b000c DOM localization
cin
parents: 381
diff changeset
35 $this->{$label} ||= Label->new($this->document->stringMap, $this->name );
381
ced5937ff21a Custom getters/setters support method names in theirs definitions
cin
parents: 278
diff changeset
36 }
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
37
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
38 sub CTOR {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
39 my ($this,%args) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
40
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
41 $this->{$minOccur} = defined $args{minOccur} ? $args{minOccur} : 1;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
42 $this->{$maxOccur} = defined $args{maxOccur} ? $args{maxOccur} : 1;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
43 $this->{$type} = $args{type};
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
44 $this->{$name} = $args{name} or die new IMPL::InvalidArgumentException('Argument is required','name');
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
45 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
46
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
47 sub Validate {
384
4edd36025051 DOM schema refactoring
cin
parents: 383
diff changeset
48 my ($this,$node,$ctx) = @_;
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
49
384
4edd36025051 DOM schema refactoring
cin
parents: 383
diff changeset
50 if (my $schemaType = $this->{$type} ? $this->document->ResolveType($this->{$type}) : undef ) {
104
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 103
diff changeset
51 my @errors = $schemaType->Validate($node,{Source => $this});
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 103
diff changeset
52 return @errors;
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
53 } else {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
54 return ();
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
55 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
56 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
57
241
f48a1a9f4fa2 +Added ViewResult to allow implementation of the view environment.
sergey
parents: 194
diff changeset
58 sub isOptional {
f48a1a9f4fa2 +Added ViewResult to allow implementation of the view environment.
sergey
parents: 194
diff changeset
59 my ($this) = @_;
f48a1a9f4fa2 +Added ViewResult to allow implementation of the view environment.
sergey
parents: 194
diff changeset
60
f48a1a9f4fa2 +Added ViewResult to allow implementation of the view environment.
sergey
parents: 194
diff changeset
61 return $this->{$minOccur} ? 0 : 1;
f48a1a9f4fa2 +Added ViewResult to allow implementation of the view environment.
sergey
parents: 194
diff changeset
62 }
f48a1a9f4fa2 +Added ViewResult to allow implementation of the view environment.
sergey
parents: 194
diff changeset
63
f48a1a9f4fa2 +Added ViewResult to allow implementation of the view environment.
sergey
parents: 194
diff changeset
64 sub isMultiple {
f48a1a9f4fa2 +Added ViewResult to allow implementation of the view environment.
sergey
parents: 194
diff changeset
65 my ($this) = @_;
f48a1a9f4fa2 +Added ViewResult to allow implementation of the view environment.
sergey
parents: 194
diff changeset
66
f48a1a9f4fa2 +Added ViewResult to allow implementation of the view environment.
sergey
parents: 194
diff changeset
67 return ($this->{$maxOccur} eq 'unbounded' || $this->{$maxOccur} > 1 ) ? 1 : 0;
f48a1a9f4fa2 +Added ViewResult to allow implementation of the view environment.
sergey
parents: 194
diff changeset
68 }
f48a1a9f4fa2 +Added ViewResult to allow implementation of the view environment.
sergey
parents: 194
diff changeset
69
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
70 sub qname {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
71 $_[0]->nodeName.'[name='.$_[0]->{$name}.']';
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
72 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
73
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
74 1;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
75
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
76 __END__
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
77 =pod
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
78
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
79 =head1 SYNOPSIS
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
80
104
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 103
diff changeset
81 package SchemaEntity;
165
76515373dac0 Added Class::Template,
wizard
parents: 152
diff changeset
82 use parent qw(IMPL::DOM::Schema::Node);
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
83
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
84 sub Validate {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
85 my ($this,$node) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
86 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
87
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
88 =head1 DESCRIPTION
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
89
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 165
diff changeset
90 Базовый класс для элементов схемы. Также позволяет объявлять узлы определенного типа.
148
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 104
diff changeset
91
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 104
diff changeset
92 =head1 MEMBERS
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 104
diff changeset
93
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 104
diff changeset
94 =head2 PROPERTIES
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 104
diff changeset
95
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 104
diff changeset
96 =over
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 104
diff changeset
97
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 104
diff changeset
98 =item C<[get,set] minOccur>
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 104
diff changeset
99
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 104
diff changeset
100 C<default: 1>.
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 104
diff changeset
101
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 165
diff changeset
102 Минимальное количество повторений узла.
148
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 104
diff changeset
103
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 104
diff changeset
104 =item C<[get,set] maxOccur>
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 104
diff changeset
105
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 104
diff changeset
106 C<default: 1>.
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 104
diff changeset
107
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 165
diff changeset
108 Максимальное количество повторений узла
148
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 104
diff changeset
109
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 104
diff changeset
110 =item C<[get,set] type>
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 104
diff changeset
111
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 104
diff changeset
112 C<default: undef>
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 104
diff changeset
113
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 165
diff changeset
114 Имя типа из схемы.
148
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 104
diff changeset
115
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 104
diff changeset
116 =item C<[get,set] name>
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 104
diff changeset
117
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 165
diff changeset
118 Имя узла.
148
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 104
diff changeset
119
e6447ad85cb4 DOM objects now have a schema and schemaSource properties
wizard
parents: 104
diff changeset
120 =back
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
121
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
122 =cut