line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DublinCore::Element; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
DublinCore::Element - Class for representing a Dublin Core element |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 SYNOPSIS |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
my $element = DublinCore::Element->new( \%info ); |
10
|
|
|
|
|
|
|
print "content: ", $element->content(), "\n"; |
11
|
|
|
|
|
|
|
print "qualifier: ", $element->qualifier(), "\n"; |
12
|
|
|
|
|
|
|
print "language: ", $element->language(), "\n"; |
13
|
|
|
|
|
|
|
print "scheme: ", $element->scheme(), "\n"; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 DESCRIPTION |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
DublinCore::Record methods such as element(), elements(), title(), etc return |
18
|
|
|
|
|
|
|
DublinCore::Element objects as their result. These can be queried |
19
|
|
|
|
|
|
|
further to extract an elements content, qualifier, language, and schema. For a |
20
|
|
|
|
|
|
|
definition of these attributes please see RFC 2731 and |
21
|
|
|
|
|
|
|
L. |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=cut |
24
|
|
|
|
|
|
|
|
25
|
4
|
|
|
4
|
|
28
|
use base qw( Class::Accessor ); |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
4336
|
|
26
|
|
|
|
|
|
|
|
27
|
4
|
|
|
4
|
|
14032
|
use strict; |
|
4
|
|
|
|
|
12
|
|
|
4
|
|
|
|
|
139
|
|
28
|
4
|
|
|
4
|
|
22
|
use warnings; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
905
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
__PACKAGE__->mk_accessors( qw( name qualifier content language scheme is_empty ) ); |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head1 METHODS |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head2 new() |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
The constructor. Take a hashref of input arguments. |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=cut |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub new { |
43
|
32
|
|
|
32
|
1
|
1186
|
my $class = shift; |
44
|
32
|
|
|
|
|
117
|
my $self = $class->SUPER::new( @_ ); |
45
|
|
|
|
|
|
|
|
46
|
32
|
|
|
|
|
352
|
bless $self, $class; |
47
|
|
|
|
|
|
|
|
48
|
32
|
|
|
|
|
92
|
$self->is_empty( 1 ); |
49
|
|
|
|
|
|
|
|
50
|
32
|
|
|
|
|
351
|
return $self; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head2 content() |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
Gets and sets the content of the element. |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
## extract the element |
58
|
|
|
|
|
|
|
my $title = $record->element( 'title' ); |
59
|
|
|
|
|
|
|
print $title->content(); |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
## or you can chain them together |
62
|
|
|
|
|
|
|
print $record->element( 'title' )->content(); |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head2 qualifier() |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
Gets and sets the qualifier used by the element. |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head2 language() |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
Gets and sets the language of the content in element. |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head2 scheme() |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Gets and sets the scheme used by the element. |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head2 name() |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Gets and sets the element name (title, creator, date, etc). |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head2 is_empty() |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
Gets and sets the "empty" status of an element. This is useful when |
83
|
|
|
|
|
|
|
using DublinCore::Record's element() method. |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
To see if the record has an creator elements: |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
if( $record->element( 'creator' )->is_empty ) { |
88
|
|
|
|
|
|
|
# no creators |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head2 set() |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
This function overrides the default set() behavior in order to remove the |
95
|
|
|
|
|
|
|
is_empty flag. |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=cut |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub set { |
100
|
107
|
|
|
107
|
1
|
1063
|
my $self = shift; |
101
|
107
|
100
|
|
|
|
297
|
$self->SUPER::set( 'is_empty' => 0 ) if $self->is_empty; |
102
|
107
|
|
|
|
|
1445
|
$self->SUPER::set( @_ ); |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head1 SEE ALSO |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=over 4 |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=item * DublinCore::Record |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=back |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head1 AUTHOR |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=over 4 |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=item * Ed Summers Eehs@pobox.comE |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=item * Brian Cassidy Ebricas@cpan.orgE |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=back |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
Copyright 2007 by Ed Summers, Brian Cassidy |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
128
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=cut |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
1; |