line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/bin/perl |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Goo::Object; |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
############################################################################### |
6
|
|
|
|
|
|
|
# Nigel Hamilton |
7
|
|
|
|
|
|
|
# |
8
|
|
|
|
|
|
|
# Copyright Nigel Hamilton 2002 |
9
|
|
|
|
|
|
|
# All Rights Reserved |
10
|
|
|
|
|
|
|
# |
11
|
|
|
|
|
|
|
# Author: Nigel Hamilton |
12
|
|
|
|
|
|
|
# Filename: Goo::Object.pm |
13
|
|
|
|
|
|
|
# Description: Super object that holds convenience methods. |
14
|
|
|
|
|
|
|
# All objects that inherit from this are hash-based. |
15
|
|
|
|
|
|
|
# |
16
|
|
|
|
|
|
|
# Date Change |
17
|
|
|
|
|
|
|
# ---------------------------------------------------------------------------- |
18
|
|
|
|
|
|
|
# 27/05/02 Version 1 - used for debugging |
19
|
|
|
|
|
|
|
# Added Clone method - needed for mod_perl persistent environment |
20
|
|
|
|
|
|
|
# 24/07/04 DataDumper was hanging around - removed in case of RAM consumption! |
21
|
|
|
|
|
|
|
# |
22
|
|
|
|
|
|
|
############################################################################## |
23
|
|
|
|
|
|
|
|
24
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
399
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
############################################################################## |
27
|
|
|
|
|
|
|
# |
28
|
|
|
|
|
|
|
# new - instantiate an object |
29
|
|
|
|
|
|
|
# |
30
|
|
|
|
|
|
|
############################################################################## |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub new { |
33
|
|
|
|
|
|
|
|
34
|
1
|
|
|
1
|
1
|
2
|
my ($class) = @_; |
35
|
|
|
|
|
|
|
|
36
|
1
|
|
|
|
|
2
|
my $this = {}; |
37
|
|
|
|
|
|
|
|
38
|
1
|
|
|
|
|
5
|
bless( $this, $class ); |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
############################################################################## |
43
|
|
|
|
|
|
|
# |
44
|
|
|
|
|
|
|
# add_fields - add fields to this object |
45
|
|
|
|
|
|
|
# |
46
|
|
|
|
|
|
|
############################################################################## |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub add_fields { |
49
|
|
|
|
|
|
|
|
50
|
0
|
|
|
0
|
1
|
|
my ( $this, $fields ) = @_; |
51
|
|
|
|
|
|
|
|
52
|
0
|
0
|
|
|
|
|
if ( ref($fields) eq "HASH" ) { |
53
|
0
|
|
|
|
|
|
%$this = ( %$this, %$fields ); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
############################################################################## |
59
|
|
|
|
|
|
|
# |
60
|
|
|
|
|
|
|
# has - return whether or not an attribute is defined for this object? |
61
|
|
|
|
|
|
|
# |
62
|
|
|
|
|
|
|
############################################################################## |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub has { |
65
|
|
|
|
|
|
|
|
66
|
0
|
|
|
0
|
1
|
|
my ( $this, $attribute ) = @_; |
67
|
|
|
|
|
|
|
|
68
|
0
|
|
|
|
|
|
return exists( $this->{$attribute} ); |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
############################################################################## |
73
|
|
|
|
|
|
|
# |
74
|
|
|
|
|
|
|
# get_type - return the type of this object |
75
|
|
|
|
|
|
|
# |
76
|
|
|
|
|
|
|
############################################################################## |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub get_type { |
79
|
|
|
|
|
|
|
|
80
|
0
|
|
|
0
|
1
|
|
my ($this) = @_; |
81
|
|
|
|
|
|
|
|
82
|
0
|
|
|
|
|
|
return ref($this); |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
############################################################################## |
87
|
|
|
|
|
|
|
# |
88
|
|
|
|
|
|
|
# to_string - return a string representation of this class |
89
|
|
|
|
|
|
|
# |
90
|
|
|
|
|
|
|
############################################################################## |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub to_string { |
93
|
|
|
|
|
|
|
|
94
|
0
|
|
|
0
|
1
|
|
my ($this) = @_; |
95
|
|
|
|
|
|
|
|
96
|
0
|
|
|
|
|
|
my $string = "[" . ref($this) . "]"; |
97
|
|
|
|
|
|
|
|
98
|
0
|
|
|
|
|
|
foreach my $key ( keys %$this ) { |
99
|
0
|
|
|
|
|
|
$string .= " $key = $this->{$key} |"; |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
0
|
|
|
|
|
|
return $string . "\n\n"; |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
############################################################################## |
108
|
|
|
|
|
|
|
# |
109
|
|
|
|
|
|
|
# to_htmlstring - return a html representation of this class |
110
|
|
|
|
|
|
|
# |
111
|
|
|
|
|
|
|
############################################################################## |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
sub to_htmlstring { |
114
|
|
|
|
|
|
|
|
115
|
0
|
|
|
0
|
1
|
|
my ($this) = @_; |
116
|
|
|
|
|
|
|
|
117
|
0
|
|
|
|
|
|
my $string = |
118
|
|
|
|
|
|
|
"<p><table width='95%' border ='1'><tr><td colspan = '2'>" |
119
|
|
|
|
|
|
|
. ref($this) |
120
|
|
|
|
|
|
|
. "</td><td></td></tr>"; |
121
|
|
|
|
|
|
|
|
122
|
0
|
|
|
|
|
|
foreach my $key ( keys %$this ) { |
123
|
|
|
|
|
|
|
|
124
|
0
|
|
|
|
|
|
$this->{$key} =~ s/\</</g; |
125
|
0
|
|
|
|
|
|
$this->{$key} =~ s/\>/>/g; |
126
|
0
|
|
|
|
|
|
$string .= "<tr><td>$key</td><td>$this->{$key}</td></tr>"; |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
|
130
|
0
|
|
|
|
|
|
return $string . "</table>"; |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
1; |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
__END__ |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=head1 NAME |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
Goo::Object - Super object that holds convenience methods. |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=head1 SYNOPSIS |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
use Goo::Object; |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=head1 DESCRIPTION |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head1 METHODS |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=over |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=item new |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
instantiate an object |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=item add_fields |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
add fields to this object |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=item has |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
return whether or not an attribute is defined for this object? |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=item get_type |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
return the type of this object |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=item to_string |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
return a string representation of this object |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=item to_htmlstring |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
return a HTML representation of this object |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=back |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=head1 AUTHOR |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
Nigel Hamilton <nigel@trexy.com> |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=head1 SEE ALSO |
184
|
|
|
|
|
|
|
|