21
22
$calendar->add_entry($vtodo);
23
24
$event->add_entry($alarm);
27
A L<Data::ICal::Entry> object represents a single entry in an iCalendar file.
28
(Note that the iCalendar RFC refers to entries as "components".) iCalendar
29
defines several types of entries, such as events and to-do lists; each of
30
these corresponds to a subclass of L<Data::ICal::Entry> (though only to-do
31
lists and events are currently implemented). L<Data::ICal::Entry> should be treated
32
as an abstract base class -- all objects created should be of its subclasses.
33
The entire calendar itself (the L<Data::ICal> object) is also represented
28
A L<Data::ICal::Entry> object represents a single entry in an
29
iCalendar file. (Note that the iCalendar RFC refers to entries as
30
"components".) iCalendar defines several types of entries, such as
31
events and to-do lists; each of these corresponds to a subclass of
32
L<Data::ICal::Entry> (though only to-do lists and events are currently
33
implemented). L<Data::ICal::Entry> should be treated as an abstract
34
base class -- all objects created should be of its subclasses. The
35
entire calendar itself (the L<Data::ICal> object) is also represented
34
36
as a L<Data::ICal::Entry> object.
36
Each entry has an entry type (such as C<VCALENDAR> or C<VEVENT>), a series
37
of "properties", and possibly some sub-entries. (Only the root L<Data::ICal>
38
object can have sub-entries, except for alarm entries contained in events and
39
to-dos (not yet implemented).)
38
Each entry has an entry type (such as C<VCALENDAR> or C<VEVENT>), a
39
series of "properties", and possibly some sub-entries. (Only the root
40
L<Data::ICal> object can have sub-entries, except for alarm entries
41
contained in events and to-dos (not yet implemented).)
53
my $self = $class->SUPER::new;
54
$self->set(properties => {});
55
$self->set(entries => []);
55
my $self = $class->SUPER::new;
56
$self->set( properties => {} );
57
$self->set( entries => [] );
61
Returns the entry as an appropriately formatted string (with trailing newline).
63
Properties are returned in alphabetical order, with multiple properties of the same name
64
returned in the order added. (Property order is unimportant
65
in iCalendar, and this makes testing easier.)
61
=head2 as_string [ crlf => C<CRLF> ]
63
Returns the entry as an appropriately formatted string (with trailing
66
Properties are returned in alphabetical order, with multiple
67
properties of the same name returned in the order added. (Property
68
order is unimportant in iCalendar, and this makes testing easier.)
67
70
If any mandatory property is missing, issues a warning.
72
The string to use as a newline can optionally be specified by giving
73
the a C<crlf> argument, which defaults to C<\x0d\x0a>, per RFC 2445
74
spec; this option is primarily for backwards compatability with
75
versions of this module before 0.16.
74
my $output = $self->header;
85
my $output = $self->header(%args);
77
88
$self->mandatory_unique_properties,
81
92
carp "Mandatory property for " . ( ref $self ) . " missing: $name"
82
93
unless $self->properties->{$name}
83
and @{ $self->properties->{$name} };
94
and @{ $self->properties->{$name} };
86
97
for my $name ( sort keys %{ $self->properties } ) {
91
102
for my $entry ( @{ $self->entries } ) {
92
103
$output .= $entry->as_string(%args);
94
$output .= $self->footer;
105
$output .= $self->footer(%args);
99
110
=head2 add_entry $entry
101
Adds an entry to this entry. (According to the standard, this should only be called
102
on either a to-do or event entry with an alarm entry, or on a calendar entry (L<Data::ICal>)
103
with a to-do, event, journal, timezone, or free/busy entry.)
112
Adds an entry to this entry. (According to the standard, this should
113
only be called on either a to-do or event entry with an alarm entry,
114
or on a calendar entry (L<Data::ICal>) with a to-do, event, journal,
115
timezone, or free/busy entry.)
105
Returns true if the entry was successfully added, and false otherwise (perhaps because you
106
tried to add an entry of an invalid type, but this check hasn't been implemented yet).
117
Returns true if the entry was successfully added, and false otherwise
118
(perhaps because you tried to add an entry of an invalid type, but
119
this check hasn't been implemented yet).
128
141
=head2 properties
130
Returns a reference to the hash of properties of this entry. The keys are property names and
131
the values are array references containing L<Data::ICal::Property> objects.
143
Returns a reference to the hash of properties of this entry. The keys
144
are property names and the values are array references containing
145
L<Data::ICal::Property> objects.
149
164
=head2 add_property $propname => $propval
151
Creates a new L<Data::ICal::Property> object with name C<$propname> and value
152
C<$propval> and adds it to the event.
166
Creates a new L<Data::ICal::Property> object with name C<$propname>
167
and value C<$propval> and adds it to the event.
154
If the property is not known to exist for that object type and does not begin
155
with C<X->, issues a warning.
169
If the property is not known to exist for that object type and does
170
not begin with C<X->, issues a warning.
157
172
If the property is known to be unique, replaces the original property.
159
To specify parameters for the property, let C<$propval> be a two-element array reference
160
where the first element is the property value and the second element is a hash reference.
161
The keys of the hash are parameter names; the values should be either strings or array references
162
of strings, depending on whether the parameter should have one or multiple (to be comma-separated)
174
To specify parameters for the property, let C<$propval> be a
175
two-element array reference where the first element is the property
176
value and the second element is a hash reference. The keys of the
177
hash are parameter names; the values should be either strings or array
178
references of strings, depending on whether the parameter should have
179
one or multiple (to be comma-separated) values.
165
181
Examples of setting parameters:
192
207
my ( $prop_value, $param_hash ) = @$val;
194
209
my $p = Data::ICal::Property->new( $prop => $prop_value, $param_hash );
195
$p->vcal10( $self-> vcal10 );
210
$p->vcal10( $self->vcal10 );
197
212
push @{ $self->properties->{$prop} }, $p;
200
215
=head2 add_properties $propname1 => $propval1, [$propname2 => $propname2, ...]
202
Convenience function to call C<add_property> several times with a list of properties.
204
This method is guaranteed to call add C<add_property> on them in the order given, so that
205
unique properties given later in the call will take precedence over those given earlier.
206
(This is unrelated to the order of properties when the entry is rendered as a string, though.)
208
Parameters for the properties are specified in the same way as in C<add_property>.
217
Convenience function to call C<add_property> several times with a list
220
This method is guaranteed to call add C<add_property> on them in the
221
order given, so that unique properties given later in the call will
222
take precedence over those given earlier. (This is unrelated to the
223
order of properties when the entry is rendered as a string, though.)
225
Parameters for the properties are specified in the same way as in
227
245
=head2 mandatory_unique_properties
229
Subclasses should override this method (which returns an empty list by default)
230
to provide a list of lower case strings identifying the properties which must appear exactly
231
once in the subclass's entry type.
247
Subclasses should override this method (which returns an empty list by
248
default) to provide a list of lower case strings identifying the
249
properties which must appear exactly once in the subclass's entry
237
256
=head2 mandatory_repeatable_properties
239
Subclasses should override this method (which returns an empty list by default)
240
to provide a list of lower case strings identifying the properties which must appear at least
241
once in the subclass's entry type.
258
Subclasses should override this method (which returns an empty list by
259
default) to provide a list of lower case strings identifying the
260
properties which must appear at least once in the subclass's entry
247
267
=head2 optional_unique_properties
249
Subclasses should override this method (which returns an empty list by default)
250
to provide a list of lower case strings identifying the properties which must appear at most
251
once in the subclass's entry type.
269
Subclasses should override this method (which returns an empty list by
270
default) to provide a list of lower case strings identifying the
271
properties which must appear at most once in the subclass's entry
257
278
=head2 optional_repeatable_properties
259
Subclasses should override this method (which returns an empty list by default)
260
to provide a list of lower case strings identifying the properties which may appear zero,
261
one, or more times in the subclass's entry type.
280
Subclasses should override this method (which returns an empty list by
281
default) to provide a list of lower case strings identifying the
282
properties which may appear zero, one, or more times in the subclass's
267
289
=head2 is_property $name
269
Returns a boolean value indicating whether or not the property C<$name> is known to the class
270
(that is, if it's listed in C<(mandatory/optional)_(unique/repeatable)_properties>).
291
Returns a boolean value indicating whether or not the property
292
C<$name> is known to the class (that is, if it's listed in
293
C<(mandatory/optional)_(unique/repeatable)_properties>).
283
306
=head2 is_mandatory $name
285
Returns a boolean value indicating whether or not the property C<$name> is known to the class as mandatory
286
(that is, if it's listed in C<mandatory_(unique/repeatable)_properties>).
308
Returns a boolean value indicating whether or not the property
309
C<$name> is known to the class as mandatory (that is, if it's listed
310
in C<mandatory_(unique/repeatable)_properties>).
297
321
=head2 is_optional $name
299
Returns a boolean value indicating whether or not the property C<$name> is known to the class as optional
300
(that is, if it's listed in C<optional_(unique/repeatable)_properties>).
323
Returns a boolean value indicating whether or not the property
324
C<$name> is known to the class as optional (that is, if it's listed in
325
C<optional_(unique/repeatable)_properties>).
311
336
=head2 is_unique $name
313
Returns a boolean value indicating whether or not the property C<$name> is known to the class as unique
314
(that is, if it's listed in C<(mandatory/optional)_unique_properties>).
338
Returns a boolean value indicating whether or not the property
339
C<$name> is known to the class as unique (that is, if it's listed in
340
C<(mandatory/optional)_unique_properties>).
325
351
=head2 is_repeatable $name
327
Returns a boolean value indicating whether or not the property C<$name> is known to the class as repeatable
328
(that is, if it's listed in C<(mandatory/optional)_repeatable_properties>).
353
Returns a boolean value indicating whether or not the property
354
C<$name> is known to the class as repeatable (that is, if it's listed
355
in C<(mandatory/optional)_repeatable_properties>).
339
366
=head2 ical_entry_type
341
Subclasses should override this method to provide the identifying type name of the entry
342
(such as C<VCALENDAR> or C<VTODO>).
368
Subclasses should override this method to provide the identifying type
369
name of the entry (such as C<VCALENDAR> or C<VTODO>).
348
375
=head2 vcal10 [$bool]
350
Gets or sets a boolean saying whether this entry should be interpreted as vCalendar
351
1.0 (as opposed to iCalendar 2.0). Generally, you can just set this on your
352
main L<Data::ICal> object when you construct it; C<add_entry> automatically makes
353
sure that sub-entries end up with the same value as their parents.
377
Gets or sets a boolean saying whether this entry should be interpreted
378
as vCalendar 1.0 (as opposed to iCalendar 2.0). Generally, you can
379
just set this on your main L<Data::ICal> object when you construct it;
380
C<add_entry> automatically makes sure that sub-entries end up with the
381
same value as their parents.
497
533
$occurence->{value} =~ s/\\([;,\\])/$1/g;
498
534
$occurence->{value} =~ s/\\n/\n/ig;
501
537
# handle optional params and 'normal' key/value pairs
502
538
# TODO: line wrapping?
503
539
if ( $occurence->{param} ) {
516
Jesse Vincent C<< <jesse@bestpractical.com> >> with David Glasser and Simon Wistow
552
Jesse Vincent C<< <jesse@bestpractical.com> >> with David Glasser,
553
Simon Wistow, and Alex Vandiver
519
555
=head1 LICENCE AND COPYRIGHT
521
Copyright (c) 2005, Best Practical Solutions, LLC. All rights reserved.
557
Copyright (c) 2005 - 2009, Best Practical Solutions, LLC. All rights reserved.
523
559
This module is free software; you can redistribute it and/or
524
560
modify it under the same terms as Perl itself. See L<perlartistic>.