annotate Lib/IMPL/DOM/Schema/SimpleType.pm @ 245:7c517134c42f

Added Unsupported media type Web exception corrected resourceLocation setting in the resource Implemented localizable resources for text messages fixed TT view scopings, INIT block in controls now sets globals correctly.
author sergey
date Mon, 29 Oct 2012 03:15:22 +0400
parents b8c724f6de36
children 4ddb27ff4a0b
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: 20
diff changeset
1 package IMPL::DOM::Schema::SimpleType;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 20
diff changeset
2 use strict;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 20
diff changeset
3 use warnings;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 20
diff changeset
4
165
76515373dac0 Added Class::Template,
wizard
parents: 152
diff changeset
5 use parent qw(IMPL::DOM::Schema::SimpleNode);
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 20
diff changeset
6 use IMPL::Class::Property;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 20
diff changeset
7 use IMPL::Class::Property::Direct;
152
1e7f03414b65 DOM: schema improvements
wizard
parents: 124
diff changeset
8 use IMPL::DOM::Property qw(_dom);
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 20
diff changeset
9
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 20
diff changeset
10 BEGIN {
152
1e7f03414b65 DOM: schema improvements
wizard
parents: 124
diff changeset
11 public _dom _direct property nativeType => prop_get;
1e7f03414b65 DOM: schema improvements
wizard
parents: 124
diff changeset
12 public _dom _direct property messageWrongType => prop_get;
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 20
diff changeset
13 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 20
diff changeset
14
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 20
diff changeset
15 our %CTOR = (
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 20
diff changeset
16 'IMPL::DOM::Schema::SimpleNode' => sub {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 20
diff changeset
17 my %args = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 20
diff changeset
18 $args{nodeName} = 'SimpleType';
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 20
diff changeset
19 $args{minOccur} = 0;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 20
diff changeset
20 $args{maxOccur} = 'unbounded';
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 20
diff changeset
21 $args{name} ||= 'SimpleType';
124
e30bdd040fe3 IMPL::Web::TT::Form concept
wizard
parents: 105
diff changeset
22 delete @args{qw(nativeType messageWrongType)};
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 20
diff changeset
23 %args
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 20
diff changeset
24 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 20
diff changeset
25 );
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 20
diff changeset
26
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 20
diff changeset
27 sub CTOR {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 20
diff changeset
28 my ($this,%args) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 20
diff changeset
29
104
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 103
diff changeset
30 $this->{$nativeType} = $args{nativeType} if $args{nativeType};
238
b8c724f6de36 DOM model refactoring
sergey
parents: 236
diff changeset
31 $this->{$messageWrongType} = $args{messageWrongType} || "A simple node '%node.path%' is expected to be %schema.nativeType%";
103
c289ed9662ca Schema beta 2
wizard
parents: 102
diff changeset
32 }
c289ed9662ca Schema beta 2
wizard
parents: 102
diff changeset
33
c289ed9662ca Schema beta 2
wizard
parents: 102
diff changeset
34 sub Validate {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
35 my ($this, $node, $ctx) = @_;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
36
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
37 if ($this->{$nativeType}) {
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
38 return new IMPL::DOM::Schema::ValidationError(
236
2904da230022 DOM refactoring
sergey
parents: 194
diff changeset
39 node => $node,
2904da230022 DOM refactoring
sergey
parents: 194
diff changeset
40 source => $ctx && $ctx->{Source} || $this,
2904da230022 DOM refactoring
sergey
parents: 194
diff changeset
41 schema => $this,
2904da230022 DOM refactoring
sergey
parents: 194
diff changeset
42 message => $this->messageWrongType
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
43 ) unless $node->isa($this->{$nativeType});
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
44 }
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
45 return $this->SUPER::Validate($node,$ctx);
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 20
diff changeset
46 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 20
diff changeset
47
102
cf3b6ef2be22 Schema beta version
wizard
parents: 49
diff changeset
48 sub qname {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
49 $_[0]->nodeName.'[type='.$_[0]->type.']';
102
cf3b6ef2be22 Schema beta version
wizard
parents: 49
diff changeset
50 }
cf3b6ef2be22 Schema beta version
wizard
parents: 49
diff changeset
51
103
c289ed9662ca Schema beta 2
wizard
parents: 102
diff changeset
52 1;
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 20
diff changeset
53
103
c289ed9662ca Schema beta 2
wizard
parents: 102
diff changeset
54 __END__
c289ed9662ca Schema beta 2
wizard
parents: 102
diff changeset
55
c289ed9662ca Schema beta 2
wizard
parents: 102
diff changeset
56 =pod
c289ed9662ca Schema beta 2
wizard
parents: 102
diff changeset
57
c289ed9662ca Schema beta 2
wizard
parents: 102
diff changeset
58 =head1 NAME
c289ed9662ca Schema beta 2
wizard
parents: 102
diff changeset
59
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 165
diff changeset
60 C<IMPL::DOM::Schema::SimpleType> - тип для простых узлов.
103
c289ed9662ca Schema beta 2
wizard
parents: 102
diff changeset
61
c289ed9662ca Schema beta 2
wizard
parents: 102
diff changeset
62 =head1 DESCRIPTION
c289ed9662ca Schema beta 2
wizard
parents: 102
diff changeset
63
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 165
diff changeset
64 Используется для описания простых узлов, которые можно отобразить в узлы
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 165
diff changeset
65 определенного типа при построении DOM документа.
103
c289ed9662ca Schema beta 2
wizard
parents: 102
diff changeset
66
c289ed9662ca Schema beta 2
wizard
parents: 102
diff changeset
67 =head1 MEMBERS
c289ed9662ca Schema beta 2
wizard
parents: 102
diff changeset
68
c289ed9662ca Schema beta 2
wizard
parents: 102
diff changeset
69 =over
c289ed9662ca Schema beta 2
wizard
parents: 102
diff changeset
70
c289ed9662ca Schema beta 2
wizard
parents: 102
diff changeset
71 =item C<nativeType>
c289ed9662ca Schema beta 2
wizard
parents: 102
diff changeset
72
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 165
diff changeset
73 Имя класса который будет представлять узел в DOM модели.
103
c289ed9662ca Schema beta 2
wizard
parents: 102
diff changeset
74
c289ed9662ca Schema beta 2
wizard
parents: 102
diff changeset
75 =item C<messageWrongType>
c289ed9662ca Schema beta 2
wizard
parents: 102
diff changeset
76
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 165
diff changeset
77 Формат сообщения которое будет выдано, если узел в дом модели не будет
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 165
diff changeset
78 соответствовать свойству C<nativeType>.
103
c289ed9662ca Schema beta 2
wizard
parents: 102
diff changeset
79
c289ed9662ca Schema beta 2
wizard
parents: 102
diff changeset
80 =back
c289ed9662ca Schema beta 2
wizard
parents: 102
diff changeset
81
c289ed9662ca Schema beta 2
wizard
parents: 102
diff changeset
82 =cut