annotate Lib/IMPL/DOM/Document.pm @ 143:d9dd3500ead3

Singleton behavior changed
author wizard
date Thu, 08 Jul 2010 23:46:49 +0400
parents 196bf443b5e1
children e6447ad85cb4
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::Document;
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
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
5 use base qw(IMPL::DOM::Node);
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
6
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
7 __PACKAGE__->PassThroughArgs;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
8
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
9 sub document {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
10 return $_[0];
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
11 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
12
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
13 sub Create {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
14 my ($this,$nodeName,$class,$refProps) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
15
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
16 $refProps ||= {};
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
17
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
18 delete $refProps->{nodeName};
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
19
104
196bf443b5e1 DOM::Schema RC0 inflators support, validation and some other things,
wizard
parents: 77
diff changeset
20 die new IMPL::Exception("class is not specified") unless $class;
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
21 return $class->new(
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
22 nodeName => $nodeName,
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
23 document => $this,
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
24 %$refProps
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
25 );
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
26 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
27
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
28 {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
29 my $empty;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
30 sub Empty() {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
31 return $empty ? $empty : $empty = __PACKAGE__->new(nodeName => 'Empty');
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
32 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
33 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
34
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
35 1;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
36 __END__
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 =pod
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
39
77
9d24db321029 Refactoring Web::TT
wizard
parents: 49
diff changeset
40 =head1 NAME
9d24db321029 Refactoring Web::TT
wizard
parents: 49
diff changeset
41
9d24db321029 Refactoring Web::TT
wizard
parents: 49
diff changeset
42 C<IMPL::DOM::Document> DOM документ.
9d24db321029 Refactoring Web::TT
wizard
parents: 49
diff changeset
43
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
44 =head1 DESCRIPTION
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
45
77
9d24db321029 Refactoring Web::TT
wizard
parents: 49
diff changeset
46 Документ, позволяет создавать узлы определенных типов, что позволяет абстрагироваться
9d24db321029 Refactoring Web::TT
wizard
parents: 49
diff changeset
47 от механизмов реального создания объектов. Т.о. например C<IMPL::DOM::Navigator::Builder>
9d24db321029 Refactoring Web::TT
wizard
parents: 49
diff changeset
48 может формировать произвольные документы.
9d24db321029 Refactoring Web::TT
wizard
parents: 49
diff changeset
49
9d24db321029 Refactoring Web::TT
wizard
parents: 49
diff changeset
50 =head1 SYNOPSIS
9d24db321029 Refactoring Web::TT
wizard
parents: 49
diff changeset
51
9d24db321029 Refactoring Web::TT
wizard
parents: 49
diff changeset
52 =begin code
9d24db321029 Refactoring Web::TT
wizard
parents: 49
diff changeset
53
9d24db321029 Refactoring Web::TT
wizard
parents: 49
diff changeset
54 package MyDocument;
9d24db321029 Refactoring Web::TT
wizard
parents: 49
diff changeset
55 use base qw(IMPL::DOM::Document);
9d24db321029 Refactoring Web::TT
wizard
parents: 49
diff changeset
56
9d24db321029 Refactoring Web::TT
wizard
parents: 49
diff changeset
57 sub Create {
9d24db321029 Refactoring Web::TT
wizard
parents: 49
diff changeset
58 my $this = shift;
9d24db321029 Refactoring Web::TT
wizard
parents: 49
diff changeset
59 my ($name,$class,$hashProps) = @_;
9d24db321029 Refactoring Web::TT
wizard
parents: 49
diff changeset
60
9d24db321029 Refactoring Web::TT
wizard
parents: 49
diff changeset
61 if ($class eq 'Info') {
9d24db321029 Refactoring Web::TT
wizard
parents: 49
diff changeset
62 return MyInfo->new($name,$hashProps->{date},$hashProps->{description});
9d24db321029 Refactoring Web::TT
wizard
parents: 49
diff changeset
63 } else {
9d24db321029 Refactoring Web::TT
wizard
parents: 49
diff changeset
64 # leave as it is
9d24db321029 Refactoring Web::TT
wizard
parents: 49
diff changeset
65 return $this->SUPER::Create(@_);
9d24db321029 Refactoring Web::TT
wizard
parents: 49
diff changeset
66 }
9d24db321029 Refactoring Web::TT
wizard
parents: 49
diff changeset
67 }
9d24db321029 Refactoring Web::TT
wizard
parents: 49
diff changeset
68
9d24db321029 Refactoring Web::TT
wizard
parents: 49
diff changeset
69 =end code
9d24db321029 Refactoring Web::TT
wizard
parents: 49
diff changeset
70
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
71 =head1 METHODS
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 =over
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
74
77
9d24db321029 Refactoring Web::TT
wizard
parents: 49
diff changeset
75 =item C< Create($nodeName,$class,$hashProps) >
9d24db321029 Refactoring Web::TT
wizard
parents: 49
diff changeset
76
9d24db321029 Refactoring Web::TT
wizard
parents: 49
diff changeset
77 Реализация по умолчанию. Создает узел определеннго типа с определенным именем и свойствами.
9d24db321029 Refactoring Web::TT
wizard
parents: 49
diff changeset
78
9d24db321029 Refactoring Web::TT
wizard
parents: 49
diff changeset
79 =begin code
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
80
77
9d24db321029 Refactoring Web::TT
wizard
parents: 49
diff changeset
81 sub Create {
9d24db321029 Refactoring Web::TT
wizard
parents: 49
diff changeset
82 my ($this,$nodeName,$class,$hashProps) = @_;
9d24db321029 Refactoring Web::TT
wizard
parents: 49
diff changeset
83
9d24db321029 Refactoring Web::TT
wizard
parents: 49
diff changeset
84 return $class->new (
9d24db321029 Refactoring Web::TT
wizard
parents: 49
diff changeset
85 nodeName => $nodeName,
9d24db321029 Refactoring Web::TT
wizard
parents: 49
diff changeset
86 document => $this,
9d24db321029 Refactoring Web::TT
wizard
parents: 49
diff changeset
87 %$hashProps
9d24db321029 Refactoring Web::TT
wizard
parents: 49
diff changeset
88 );
9d24db321029 Refactoring Web::TT
wizard
parents: 49
diff changeset
89 }
9d24db321029 Refactoring Web::TT
wizard
parents: 49
diff changeset
90
9d24db321029 Refactoring Web::TT
wizard
parents: 49
diff changeset
91 =end code
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
92
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
93 =back
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
94
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 37
diff changeset
95 =cut