Mercurial > pub > Impl
annotate Lib/IMPL/DOM/Schema/SimpleNode.pm @ 305:b5d5793f348e
TTView refactoring, still experiencing memory leaks
| author | sergey |
|---|---|
| date | Wed, 17 Apr 2013 18:00:19 +0400 |
| parents | 4ddb27ff4a0b |
| children | 648dfaf642e0 |
| rev | line source |
|---|---|
| 49 | 1 package IMPL::DOM::Schema::SimpleNode; |
| 2 use strict; | |
| 3 use warnings; | |
| 4 | |
| 165 | 5 use parent qw(IMPL::DOM::Schema::Node); |
| 103 | 6 use IMPL::Class::Property; |
| 152 | 7 use IMPL::DOM::Property qw(_dom); |
| 103 | 8 |
| 9 BEGIN { | |
| 194 | 10 public _dom _direct property inflator => prop_get; |
| 11 public _dom _direct property messageInflateError => prop_get; | |
| 103 | 12 } |
| 49 | 13 |
| 14 our %CTOR = ( | |
| 124 | 15 'IMPL::DOM::Schema::Node' => sub { |
| 194 | 16 my %args = @_; |
| 17 $args{nodeName} ||= 'SimpleNode'; | |
| 18 delete @args{qw(inflator messageInflateError)}; | |
| 19 %args | |
| 124 | 20 } |
| 103 | 21 ); |
| 22 | |
| 23 sub CTOR { | |
| 194 | 24 my ($this,%args) = @_; |
| 25 | |
| 26 if ( $args{inflator} ) { | |
| 27 $this->{$inflator} = $args{inflator} ; | |
| 238 | 28 $this->{$messageInflateError} = exists $args{messageInflateError} ? $args{messageInflateError} : 'Failed to inflate nodeValue %node.path%: %error%'; |
| 194 | 29 } |
| 103 | 30 } |
| 49 | 31 |
| 32 sub Validate { | |
|
104
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
103
diff
changeset
|
33 my ($this,$node,$ctx) = @_; |
|
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
103
diff
changeset
|
34 |
|
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
103
diff
changeset
|
35 my @result; |
|
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
103
diff
changeset
|
36 |
|
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
103
diff
changeset
|
37 push @result, $_->Validate($node,$ctx) foreach $this->childNodes; |
| 49 | 38 |
|
104
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
103
diff
changeset
|
39 return @result; |
|
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
103
diff
changeset
|
40 } |
|
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
103
diff
changeset
|
41 |
|
196bf443b5e1
DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents:
103
diff
changeset
|
42 sub inflateValue { |
| 194 | 43 my ($this,$value) = @_; |
| 44 | |
| 45 if ( my $inflator = $this->inflator ) { | |
| 248 | 46 return $inflator->new($value,$this); |
| 194 | 47 } else { |
| 48 return $value; | |
| 49 } | |
| 49 | 50 } |
| 51 | |
| 52 1; | |
| 53 | |
| 54 __END__ | |
| 55 | |
| 56 =pod | |
| 57 | |
| 103 | 58 =head1 NAME |
| 59 | |
| 180 | 60 C<IMPL::DOM::SimpleNode> - узел с текстом. |
| 103 | 61 |
| 49 | 62 =head1 DESCRIPTION |
| 63 | |
| 180 | 64 Узел имеющий простое значение. Данный узел может содержать ограничения |
| 65 на простое значение. | |
| 49 | 66 |
| 180 | 67 Производит валидацию содержимого, при постоении DOM модели не имеет специального |
| 68 типа и будет создан в виде C<IMPL::DOM::Node>. | |
| 103 | 69 |
| 180 | 70 Также определяет как будет воссоздано значение узла в DOM модели. |
| 49 | 71 |
| 72 =cut |
