line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
216
|
|
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
push(@::bean_desc, { |
4
|
|
|
|
|
|
|
bean_opt => { |
5
|
|
|
|
|
|
|
abstract => 'Unique MULTI bean attribute information', |
6
|
|
|
|
|
|
|
package => 'PerlBean::Attribute::Multi::Unique', |
7
|
|
|
|
|
|
|
use_perl_version => 5.005, |
8
|
|
|
|
|
|
|
base => [ qw(PerlBean::Attribute::Multi)], |
9
|
|
|
|
|
|
|
description => <
|
10
|
|
|
|
|
|
|
C contains unique MULTI bean attribute information. It is a subclass of C. The code generation and documentation methods from C are implemented. |
11
|
|
|
|
|
|
|
EOF |
12
|
|
|
|
|
|
|
short_description => 'contains unique MULTI bean attribute information', |
13
|
|
|
|
|
|
|
synopsis => &get_syn(), |
14
|
|
|
|
|
|
|
}, |
15
|
|
|
|
|
|
|
attr_opt => [ |
16
|
|
|
|
|
|
|
], |
17
|
|
|
|
|
|
|
meth_opt => [ |
18
|
|
|
|
|
|
|
{ |
19
|
|
|
|
|
|
|
method_name => 'create_method_add', |
20
|
|
|
|
|
|
|
documented => 0, |
21
|
|
|
|
|
|
|
body => <<'THE_EOF', |
22
|
|
|
|
|
|
|
my $self = shift; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
my $an = $self->get_method_factory_name(); |
25
|
|
|
|
|
|
|
my $an_esc = $self->_esc_apos($an); |
26
|
|
|
|
|
|
|
my $op = &{$MOF}('add'); |
27
|
|
|
|
|
|
|
my $mb = $self->get_method_base(); |
28
|
|
|
|
|
|
|
my $ec = $self->get_exception_class(); |
29
|
|
|
|
|
|
|
my $pkg = $self->get_package(); |
30
|
|
|
|
|
|
|
my $pkg_us = $self->get_package_us(); |
31
|
|
|
|
|
|
|
my $desc = defined($self->get_short_description()) ? $self->get_short_description() : 'not described option'; |
32
|
|
|
|
|
|
|
my $exc = ' On error an exception C<' . $self->get_exception_class() . '> is thrown.'; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# Make body |
35
|
|
|
|
|
|
|
my $body = <
|
36
|
|
|
|
|
|
|
${IND}my \$self${AO}=${AO}shift; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
EOF |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# Check if isas/refs/rxs/values are allowed |
41
|
|
|
|
|
|
|
$body .= <
|
42
|
|
|
|
|
|
|
${IND}# Check if isas/refs/rxs/values are allowed |
43
|
|
|
|
|
|
|
${IND}\&_value_is_allowed${BFP}(${ACS}$an_esc,${AC}\@_${ACS})${AO}||${AO}throw $ec${BFP}("ERROR: ${pkg}::$op$mb, one or more specified value(s) '\@_' is/are not allowed."); |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
EOF |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
# Method tail |
48
|
|
|
|
|
|
|
$body .= <
|
49
|
|
|
|
|
|
|
${IND}# Add values |
50
|
|
|
|
|
|
|
${IND}foreach my \$val (\@_)${PBOC[1]}{ |
51
|
|
|
|
|
|
|
${IND}${IND}\$self->{$pkg_us}{$an}{\$val}${AO}=${AO}\$val; |
52
|
|
|
|
|
|
|
${IND}} |
53
|
|
|
|
|
|
|
EOF |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
# Make description |
56
|
|
|
|
|
|
|
my $description = <
|
57
|
|
|
|
|
|
|
Add additional values on ${desc}. C is the list value. The addition may not yield to multiple identical elements in the list. Hence, multiple occurrences of the same element cause the last occurrence to be inserted.${exc} |
58
|
|
|
|
|
|
|
EOF |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
# Add clauses to the description |
61
|
|
|
|
|
|
|
my $clauses = $self->mk_doc_clauses(); |
62
|
|
|
|
|
|
|
if ($clauses) { |
63
|
|
|
|
|
|
|
$description .= "\n" . $clauses; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
# Create and return the method |
67
|
|
|
|
|
|
|
return( PerlBean::Method->new( { |
68
|
|
|
|
|
|
|
method_name => "$op$mb", |
69
|
|
|
|
|
|
|
parameter_description => 'ARRAY', |
70
|
|
|
|
|
|
|
documented => $self->is_documented(), |
71
|
|
|
|
|
|
|
volatile => 1, |
72
|
|
|
|
|
|
|
description => $description, |
73
|
|
|
|
|
|
|
body => $body, |
74
|
|
|
|
|
|
|
} ) ); |
75
|
|
|
|
|
|
|
THE_EOF |
76
|
|
|
|
|
|
|
}, |
77
|
|
|
|
|
|
|
{ |
78
|
|
|
|
|
|
|
method_name => 'create_method_delete', |
79
|
|
|
|
|
|
|
documented => 0, |
80
|
|
|
|
|
|
|
body => <<'THE_EOF', |
81
|
|
|
|
|
|
|
my $self = shift; |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
my $an = $self->get_method_factory_name(); |
84
|
|
|
|
|
|
|
my $an_esc = $self->_esc_apos($an); |
85
|
|
|
|
|
|
|
my $op = &{$MOF}('delete'); |
86
|
|
|
|
|
|
|
my $mb = $self->get_method_base(); |
87
|
|
|
|
|
|
|
my $ec = $self->get_exception_class(); |
88
|
|
|
|
|
|
|
my $pkg = $self->get_package(); |
89
|
|
|
|
|
|
|
my $pkg_us = $self->get_package_us(); |
90
|
|
|
|
|
|
|
my $desc = defined( $self->get_short_description() ) ? $self->get_short_description() : 'not described option'; |
91
|
|
|
|
|
|
|
my $empt = $self->is_allow_empty() ? '' : ' After deleting at least one element must remain.'; |
92
|
|
|
|
|
|
|
my $exc = ' On error an exception C<' . $self->get_exception_class() . '> is thrown.'; |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
# Make body |
95
|
|
|
|
|
|
|
my $body = <
|
96
|
|
|
|
|
|
|
${IND}my \$self${AO}=${AO}shift; |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
EOF |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
# Check if list value is allowed to be empty |
101
|
|
|
|
|
|
|
if ( ! $self->is_allow_empty() ) { |
102
|
|
|
|
|
|
|
$body .= <
|
103
|
|
|
|
|
|
|
${IND}# List value for $an_esc is not allowed to be empty |
104
|
|
|
|
|
|
|
${IND}my \%would_delete${AO}=${AO}(); |
105
|
|
|
|
|
|
|
${IND}foreach my \$val (\@_)${PBOC[1]}{ |
106
|
|
|
|
|
|
|
${IND}${IND}\$would_delete{\$val}${AO}=${AO}\$val if${BCP}(${ACS}exists${BFP}(${ACS}\$self->{$pkg_us}{$an}{\$val}${ACS})${ACS}); |
107
|
|
|
|
|
|
|
${IND}} |
108
|
|
|
|
|
|
|
${IND}(${ACS}scalar${BFP}(${ACS}keys${BFP}(${ACS}\%{${ACS}\$self->{$pkg_us}{$an}${ACS}}${ACS})${ACS})${AO}==${AO}scalar(${ACS}keys${BFP}(\%would_delete)${ACS})${ACS})${AO}&&${AO}throw $ec${BFP}("ERROR: ${pkg}::$op$mb, list value may not be empty."); |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
EOF |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
# Method tail |
114
|
|
|
|
|
|
|
$body .= <
|
115
|
|
|
|
|
|
|
${IND}# Delete values |
116
|
|
|
|
|
|
|
${IND}my \$del${AO}=${AO}0; |
117
|
|
|
|
|
|
|
${IND}foreach my \$val (\@_)${PBOC[1]}{ |
118
|
|
|
|
|
|
|
${IND}${IND}exists${BFP}(${ACS}\$self->{$pkg_us}{$an}{\$val}${ACS})${AO}||${AO}next; |
119
|
|
|
|
|
|
|
${IND}${IND}delete${BFP}(${ACS}\$self->{$pkg_us}{$an}{\$val}${ACS}); |
120
|
|
|
|
|
|
|
${IND}${IND}\$del${AO}++; |
121
|
|
|
|
|
|
|
${IND}} |
122
|
|
|
|
|
|
|
${IND}return${BFP}(\$del); |
123
|
|
|
|
|
|
|
EOF |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
# Create and return the method |
126
|
|
|
|
|
|
|
return( PerlBean::Method->new( { |
127
|
|
|
|
|
|
|
method_name => "$op$mb", |
128
|
|
|
|
|
|
|
parameter_description => 'ARRAY', |
129
|
|
|
|
|
|
|
documented => $self->is_documented(), |
130
|
|
|
|
|
|
|
volatile => 1, |
131
|
|
|
|
|
|
|
description => <
|
132
|
|
|
|
|
|
|
Delete elements from ${desc}.${empt} Returns the number of deleted elements.${exc} |
133
|
|
|
|
|
|
|
EOF |
134
|
|
|
|
|
|
|
body => $body, |
135
|
|
|
|
|
|
|
} ) ); |
136
|
|
|
|
|
|
|
THE_EOF |
137
|
|
|
|
|
|
|
}, |
138
|
|
|
|
|
|
|
{ |
139
|
|
|
|
|
|
|
method_name => 'create_method_exists', |
140
|
|
|
|
|
|
|
documented => 0, |
141
|
|
|
|
|
|
|
body => <<'THE_EOF', |
142
|
|
|
|
|
|
|
my $self = shift; |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
my $an = $self->get_method_factory_name(); |
145
|
|
|
|
|
|
|
my $op = &{$MOF}('exists'); |
146
|
|
|
|
|
|
|
my $mb = $self->get_method_base(); |
147
|
|
|
|
|
|
|
my $pkg_us = $self->get_package_us(); |
148
|
|
|
|
|
|
|
my $desc = defined( $self->get_short_description() ) ? $self->get_short_description() : 'not described option'; |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
# Make body |
151
|
|
|
|
|
|
|
my $body = <
|
152
|
|
|
|
|
|
|
${IND}my \$self${AO}=${AO}shift; |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
${IND}# Count occurrences |
155
|
|
|
|
|
|
|
${IND}my \$count${AO}=${AO}0; |
156
|
|
|
|
|
|
|
${IND}foreach my \$val (\@_)${PBOC[1]}{ |
157
|
|
|
|
|
|
|
${IND}${IND}\$count${AO}+=${AO}exists${BFP}(${ACS}\$self->{$pkg_us}{$an}{\$val}${ACS}); |
158
|
|
|
|
|
|
|
${IND}} |
159
|
|
|
|
|
|
|
${IND}return${BFP}(\$count); |
160
|
|
|
|
|
|
|
EOF |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
# Create and return the method |
163
|
|
|
|
|
|
|
return( PerlBean::Method->new( { |
164
|
|
|
|
|
|
|
method_name => "$op$mb", |
165
|
|
|
|
|
|
|
parameter_description => 'ARRAY', |
166
|
|
|
|
|
|
|
documented => $self->is_documented(), |
167
|
|
|
|
|
|
|
volatile => 1, |
168
|
|
|
|
|
|
|
description => <
|
169
|
|
|
|
|
|
|
Returns the count of items in C that are in ${desc}. |
170
|
|
|
|
|
|
|
EOF |
171
|
|
|
|
|
|
|
body => $body, |
172
|
|
|
|
|
|
|
} ) ); |
173
|
|
|
|
|
|
|
THE_EOF |
174
|
|
|
|
|
|
|
}, |
175
|
|
|
|
|
|
|
{ |
176
|
|
|
|
|
|
|
method_name => 'create_method_set', |
177
|
|
|
|
|
|
|
documented => 0, |
178
|
|
|
|
|
|
|
body => <<'THE_EOF', |
179
|
|
|
|
|
|
|
my $self = shift; |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
my $an = $self->get_method_factory_name(); |
182
|
|
|
|
|
|
|
my $an_esc = $self->_esc_apos($an); |
183
|
|
|
|
|
|
|
my $op = &{$MOF}('set'); |
184
|
|
|
|
|
|
|
my $mb = $self->get_method_base(); |
185
|
|
|
|
|
|
|
my $ec = $self->get_exception_class(); |
186
|
|
|
|
|
|
|
my $pkg = $self->get_package(); |
187
|
|
|
|
|
|
|
my $pkg_us = $self->get_package_us(); |
188
|
|
|
|
|
|
|
my $desc = defined( $self->get_short_description() ) ? $self->get_short_description() : 'not described option'; |
189
|
|
|
|
|
|
|
my $def = defined( $self->get_default_value() ) ? ' Default value at initialization is C<' . join( ', ', $self->_esc_aq ( @{ $self->get_default_value() } ) ) . '>.' : ''; |
190
|
|
|
|
|
|
|
my $empt = $self->is_allow_empty() ? '' : ' C must at least have one element.'; |
191
|
|
|
|
|
|
|
my $exc = ' On error an exception C<' . $self->get_exception_class() . '> is thrown.'; |
192
|
|
|
|
|
|
|
my $attr_overl = $self->_get_overloaded_attribute(); |
193
|
|
|
|
|
|
|
my $overl = defined($attr_overl) ? " B Methods B> are overloaded from package C<". $attr_overl->get_package() .'>.': ''; |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
# Make body |
196
|
|
|
|
|
|
|
my $body = <
|
197
|
|
|
|
|
|
|
${IND}my \$self${AO}=${AO}shift; |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
EOF |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
# Check if list value is allowed to be empty |
202
|
|
|
|
|
|
|
if ( ! $self->is_allow_empty() ) { |
203
|
|
|
|
|
|
|
$body .= <
|
204
|
|
|
|
|
|
|
${IND}# List value for $an_esc is not allowed to be empty |
205
|
|
|
|
|
|
|
${IND}scalar${BFP}(\@_)${AO}||${AO}throw $ec${BFP}("ERROR: ${pkg}::$op$mb, list value may not be empty."); |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
EOF |
208
|
|
|
|
|
|
|
} |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
# Check if isas/refs/rxs/values are allowed |
211
|
|
|
|
|
|
|
$body .= <
|
212
|
|
|
|
|
|
|
${IND}# Check if isas/refs/rxs/values are allowed |
213
|
|
|
|
|
|
|
${IND}\&_value_is_allowed${BFP}(${ACS}$an_esc,${AC}\@_${ACS})${AO}||${AO}throw $ec${BFP}("ERROR: ${pkg}::$op$mb, one or more specified value(s) '\@_' is/are not allowed."); |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
EOF |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
# Method tail |
218
|
|
|
|
|
|
|
$body .= <
|
219
|
|
|
|
|
|
|
${IND}# Empty list |
220
|
|
|
|
|
|
|
${IND}\$self->{$pkg_us}{$an}${AO}=${AO}\{}; |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
${IND}# Add values |
223
|
|
|
|
|
|
|
${IND}foreach my \$val (\@_)${PBOC[1]}{ |
224
|
|
|
|
|
|
|
${IND}${IND}\$self->{$pkg_us}{$an}{\$val}${AO}=${AO}\$val; |
225
|
|
|
|
|
|
|
${IND}} |
226
|
|
|
|
|
|
|
EOF |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
# Make description |
229
|
|
|
|
|
|
|
my $description = <
|
230
|
|
|
|
|
|
|
Set ${desc} absolutely. C is the list value. Each element in the list is allowed to occur only once. Multiple occurrences of the same element yield in the last occurring element to be inserted and the rest to be ignored.${def}${empt}${exc}${overl} |
231
|
|
|
|
|
|
|
EOF |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
# Add clauses to the description |
234
|
|
|
|
|
|
|
my $clauses = $self->mk_doc_clauses(); |
235
|
|
|
|
|
|
|
if ($clauses) { |
236
|
|
|
|
|
|
|
$description .= "\n" . $clauses; |
237
|
|
|
|
|
|
|
} |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
# Create and return the method |
240
|
|
|
|
|
|
|
return( PerlBean::Method->new( { |
241
|
|
|
|
|
|
|
method_name => "$op$mb", |
242
|
|
|
|
|
|
|
parameter_description => 'ARRAY', |
243
|
|
|
|
|
|
|
documented => $self->is_documented(), |
244
|
|
|
|
|
|
|
volatile => 1, |
245
|
|
|
|
|
|
|
description => $description, |
246
|
|
|
|
|
|
|
body => $body, |
247
|
|
|
|
|
|
|
} ) ); |
248
|
|
|
|
|
|
|
THE_EOF |
249
|
|
|
|
|
|
|
}, |
250
|
|
|
|
|
|
|
{ |
251
|
|
|
|
|
|
|
method_name => 'create_method_values', |
252
|
|
|
|
|
|
|
documented => 0, |
253
|
|
|
|
|
|
|
body => <<'THE_EOF', |
254
|
|
|
|
|
|
|
my $self = shift; |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
my $an = $self->get_method_factory_name(); |
257
|
|
|
|
|
|
|
my $op = &{$MOF}('values'); |
258
|
|
|
|
|
|
|
my $mb = $self->get_method_base(); |
259
|
|
|
|
|
|
|
my $pkg_us = $self->get_package_us(); |
260
|
|
|
|
|
|
|
my $desc = defined( $self->get_short_description() ) ? $self->get_short_description() : 'not described option'; |
261
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
# Make body |
263
|
|
|
|
|
|
|
my $body = <
|
264
|
|
|
|
|
|
|
${IND}my \$self${AO}=${AO}shift; |
265
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
${IND}# Return all values |
267
|
|
|
|
|
|
|
${IND}return${BFP}(${ACS}values${BFP}(${ACS}\%{${ACS}\$self->{$pkg_us}{$an}${ACS}}${ACS})${ACS}); |
268
|
|
|
|
|
|
|
EOF |
269
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
# Create and return the method |
271
|
|
|
|
|
|
|
return( PerlBean::Method->new( { |
272
|
|
|
|
|
|
|
method_name => "$op$mb", |
273
|
|
|
|
|
|
|
documented => $self->is_documented(), |
274
|
|
|
|
|
|
|
volatile => 1, |
275
|
|
|
|
|
|
|
description => <
|
276
|
|
|
|
|
|
|
Returns an C containing all values of ${desc}. |
277
|
|
|
|
|
|
|
EOF |
278
|
|
|
|
|
|
|
body => $body, |
279
|
|
|
|
|
|
|
} ) ); |
280
|
|
|
|
|
|
|
THE_EOF |
281
|
|
|
|
|
|
|
}, |
282
|
|
|
|
|
|
|
{ |
283
|
|
|
|
|
|
|
method_name => 'create_methods', |
284
|
|
|
|
|
|
|
description => <
|
285
|
|
|
|
|
|
|
__SUPER_POD__ Access methods are B, B, B, B and B. |
286
|
|
|
|
|
|
|
EOF |
287
|
|
|
|
|
|
|
body => <<'EOF', |
288
|
|
|
|
|
|
|
my $self = shift; |
289
|
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
return( |
291
|
|
|
|
|
|
|
$self->create_method_add(), |
292
|
|
|
|
|
|
|
$self->create_method_delete(), |
293
|
|
|
|
|
|
|
$self->create_method_exists(), |
294
|
|
|
|
|
|
|
$self->create_method_set(), |
295
|
|
|
|
|
|
|
$self->create_method_values(), |
296
|
|
|
|
|
|
|
); |
297
|
|
|
|
|
|
|
EOF |
298
|
|
|
|
|
|
|
}, |
299
|
|
|
|
|
|
|
], |
300
|
|
|
|
|
|
|
sym_opt => [ |
301
|
|
|
|
|
|
|
], |
302
|
|
|
|
|
|
|
use_opt => [ |
303
|
|
|
|
|
|
|
{ |
304
|
|
|
|
|
|
|
dependency_name => 'PerlBean::Style', |
305
|
|
|
|
|
|
|
import_list => [ 'qw(:codegen)' ], |
306
|
|
|
|
|
|
|
}, |
307
|
|
|
|
|
|
|
], |
308
|
|
|
|
|
|
|
} ); |
309
|
|
|
|
|
|
|
|
310
|
|
|
|
|
|
|
sub get_syn { |
311
|
1
|
|
|
1
|
|
5
|
use IO::File; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
194
|
|
312
|
|
|
|
|
|
|
my $fh = IO::File->new('< syn-PerlBean_Attribute_Multi_Unique.pl'); |
313
|
|
|
|
|
|
|
$fh = IO::File->new('< gen/syn-PerlBean_Attribute_Multi_Unique.pl') if (! defined($fh)); |
314
|
|
|
|
|
|
|
my $syn = ''; |
315
|
|
|
|
|
|
|
my $prev_line = $fh->getline (); |
316
|
|
|
|
|
|
|
while (my $line = $fh->getline ()) { |
317
|
|
|
|
|
|
|
$syn .= ' ' . $prev_line; |
318
|
|
|
|
|
|
|
$prev_line = $line; |
319
|
|
|
|
|
|
|
} |
320
|
|
|
|
|
|
|
return($syn); |
321
|
|
|
|
|
|
|
} |
322
|
|
|
|
|
|
|
|
323
|
|
|
|
|
|
|
1; |