line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Config::PropertiesSequence; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=pod |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
Config::PropertiesSequence - provides access to sequential properties loaded from properties file. |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 USAGE |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
my $props = Config::PropertiesSequence->new(); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
$props->load( *FH ); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
my @multipleSettings = $props->getPropertySequence( $prefix, @names ); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
returns settings prefixed by $prefix, numbered consecutively and suffixed with values |
19
|
|
|
|
|
|
|
from @names. |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
eg when |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
my $prefix = "test.settings.multi"; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
my @names = qw(setting1 setting2); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
then getPropertySequence will return |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
( |
30
|
|
|
|
|
|
|
{ setting1 => "abc", |
31
|
|
|
|
|
|
|
setting2 => "def" }, |
32
|
|
|
|
|
|
|
{ setting1 => "ghi", |
33
|
|
|
|
|
|
|
setting2 => "jkl" } |
34
|
|
|
|
|
|
|
) |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
from a properties file containing |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
test.settings.multi.1.setting1=abc |
39
|
|
|
|
|
|
|
test.settings.multi.1.setting2=def |
40
|
|
|
|
|
|
|
test.settings.multi.2.setting1=ghi |
41
|
|
|
|
|
|
|
test.settings.multi.2.setting2=jkl |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head1 NOTES |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
see L. |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head1 VERSION |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
$Id: PropertiesSequence.pm,v 1.2 2004/01/31 12:09:35 mark Exp $ |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=cut |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
55
|
1
|
|
|
1
|
|
41962
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
45
|
|
56
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
39
|
|
57
|
|
|
|
|
|
|
|
58
|
1
|
|
|
1
|
|
6
|
use base qw(Config::Properties); |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
1034
|
|
59
|
|
|
|
|
|
|
|
60
|
1
|
|
|
1
|
|
20567
|
use Carp qw(cluck); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
59
|
|
61
|
1
|
|
|
1
|
|
1160
|
use Carp::Assert; |
|
1
|
|
|
|
|
1310
|
|
|
1
|
|
|
|
|
5
|
|
62
|
1
|
|
|
1
|
|
1248
|
use Data::Dumper; |
|
1
|
|
|
|
|
17750
|
|
|
1
|
|
|
|
|
83
|
|
63
|
1
|
|
|
1
|
|
1026
|
use FileHandle; |
|
1
|
|
|
|
|
4777
|
|
|
1
|
|
|
|
|
6
|
|
64
|
1
|
|
|
1
|
|
648
|
use Config::Properties; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
40
|
|
65
|
|
|
|
|
|
|
|
66
|
1
|
|
|
1
|
|
6
|
use constant DEFAULTMAXSEQUENCENUMBER => 100; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
162
|
|
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
our $VERSION = sprintf "%d.%03d", q$Revision: 1.2 $ =~ /(\d+)/g; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
BEGIN { |
72
|
1
|
|
|
1
|
|
225
|
my $MAXSEQUENCENUMBER = DEFAULTMAXSEQUENCENUMBER; |
73
|
|
|
|
|
|
|
sub setMaxSequenceNumber($){ |
74
|
0
|
|
|
0
|
0
|
0
|
my $newMaxSequenceNumber = shift; |
75
|
0
|
|
|
|
|
0
|
$MAXSEQUENCENUMBER = $newMaxSequenceNumber; |
76
|
|
|
|
|
|
|
}; |
77
|
|
|
|
|
|
|
sub getMaxSequenceNumber(){ |
78
|
1
|
|
|
1
|
0
|
5
|
return $MAXSEQUENCENUMBER; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
}; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub getPropertySequence ($$@) { |
84
|
1
|
|
|
1
|
0
|
13139
|
my __PACKAGE__ $self = shift; |
85
|
1
|
|
|
|
|
3
|
my $prefix = shift; |
86
|
1
|
|
|
|
|
3
|
my @searchFor = @_; |
87
|
|
|
|
|
|
|
|
88
|
1
|
|
|
|
|
2
|
my @props = (); |
89
|
1
|
|
|
|
|
1
|
my $ii; |
90
|
1
|
|
|
|
|
5
|
my $MAXSEQUENCENUMBER = getMaxSequenceNumber(); |
91
|
|
|
|
|
|
|
|
92
|
1
|
|
|
|
|
7
|
for($ii = 1 ; $ii <= $MAXSEQUENCENUMBER ; $ii++ ){ |
93
|
3
|
|
|
|
|
5
|
my %sequence = (); |
94
|
3
|
|
|
|
|
6
|
foreach my $searchFor(@searchFor){ |
95
|
6
|
|
|
|
|
30
|
my $prop = $self->getProperty( "$prefix.$ii.$searchFor" ); |
96
|
6
|
100
|
|
|
|
74
|
$sequence{$searchFor} = $prop if defined $prop; |
97
|
|
|
|
|
|
|
} |
98
|
3
|
100
|
|
|
|
13
|
last unless keys %sequence; |
99
|
2
|
|
|
|
|
7
|
push @props, \%sequence; |
100
|
|
|
|
|
|
|
} |
101
|
1
|
50
|
|
|
|
3
|
if($ii == $MAXSEQUENCENUMBER){ |
102
|
0
|
|
|
|
|
0
|
cluck "maximum sequence number ".$MAXSEQUENCENUMBER." reached"; |
103
|
|
|
|
|
|
|
} |
104
|
1
|
|
|
|
|
5
|
return @props; |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
1; |
109
|
|
|
|
|
|
|
|