source: XMLIO_V2/tools/FCM/lib/Fcm/Keyword/Entry/Location.pm @ 81

Last change on this file since 81 was 81, checked in by ymipsl, 15 years ago

ajout FCM 1.5

File size: 4.0 KB
Line 
1# ------------------------------------------------------------------------------
2# (C) Crown copyright Met Office. All rights reserved.
3# For further details please refer to the file COPYRIGHT.txt
4# which you should have received as part of this distribution.
5# ------------------------------------------------------------------------------
6use strict;
7use warnings;
8
9package Fcm::Keyword::Entry::Location;
10use base qw{Fcm::Keyword::Entry};
11
12use Fcm::Keyword::Config;
13
14sub new {
15    my ($class, $args_ref) = @_;
16    if (!$args_ref) {
17        $args_ref = {};
18    }
19    $args_ref = {
20        browser_rev_template       => undef,
21        browser_url_template       => undef,
22        implied_entry_list         => [],
23        is_implied                 => 0,
24        location_component_pattern => undef,
25        revision_entries           => Fcm::Keyword::Config::get_entries(
26            'REVISION_ENTRIES', $args_ref,
27        ),
28        %{$args_ref},
29    },
30    return bless({%{$args_ref}}, $class);
31}
32
33################################################################################
34# Methods: get_*
35for my $key (
36    # Returns a template for constructing the browser URL
37    'browser_url_template',
38    # Returns a template for constructing the revision part in the browser URL
39    'browser_rev_template',
40    # Returns a list of entries implied this entry
41    'implied_entry_list',
42    # Returns the component pattern for a location matching this entry
43    'location_component_pattern',
44    # Returns the entries for revision keywords
45    'revision_entries',
46) {
47    no strict qw{refs};
48    my $getter = "get_$key";
49    *$getter = sub {
50        my ($self) = @_;
51        return $self->{$key};
52    }
53}
54
55################################################################################
56# Returns true if this is an implied entry
57sub is_implied {
58    my ($self) = @_;
59    return $self->{is_implied};
60}
61
621;
63__END__
64
65=head1 NAME
66
67Fcm::Keyword::Entry::Location
68
69=head1 SYNOPSIS
70
71    use Fcm::Keyword::Entry::Location;
72
73    $entry = Fcm::Keyword::Entry::Location->new({
74        key => $key, value => $value, # ...
75    });
76
77    $key = $entry->get_key();
78    $value = $entry->get_value();
79    $revision_entries = $entry->get_revision_entries();
80
81=head1 DESCRIPTION
82
83This is a sub-class of L<Fcm::Keyword::Entry|Fcm::Keyword::Entry>. An object of
84this class represents a FCM location keyword entry.
85
86=head1 METHODS
87
88See L<Fcm::Keyword::Entry|Fcm::Keyword::Entry> for inherited methods.
89
90=over 4
91
92=item new($args_ref)
93
94Constructor.
95
96=item get_browser_url_template()
97
98Returns the template string for constructing the browser URL. The string {1},
99{2}, {3}, etc in the template string will be substituted by the components
100captured by the location component pattern and the revision template. See
101C<get_url_component_pattern()> and C<get_browser_rev_template()>.
102
103=item get_browser_rev_template()
104
105Returns the template string for constructing the revision part of the browser
106URL. The string {1} in the template string will be substituted by the revision.
107See C<get_browser_url_template()>.
108
109=item get_implied_entry_list()
110
111Returns a list of entries implied by this entry.
112
113=item get_location_component_pattern()
114
115Returns a regular expression, when matched against the scheme-specific-part in
116the actual URI of a location in the namespace of this keyword entry, will
117capture a list of components, which can then be used to replace the numbered
118fields in the browser URL template. See C<get_browser_url_template()>.
119
120=item get_revision_entries()
121
122Returns a L<Fcm::Keyword::Entries|Fcm::Keyword::Entries> object containing the
123revision keyword entries of this location.
124
125=item is_implied()
126
127Returns true if this is an implied entry.
128
129=back
130
131=head1 TO DO
132
133Introduce a Fcm::Keyword::Config module to store entries constructor setting.
134
135=head1 SEE ALSO
136
137L<Fcm::Keyword|Fcm::Keyword>,
138L<Fcm::Keyword::Config|Fcm::Keyword::Config>,
139L<Fcm::Keyword::Entries|Fcm::Keyword::Entries>,
140L<Fcm::Keyword::Entry|Fcm::Keyword::Entry>
141
142=head1 COPYRIGHT
143
144E<169> Crown copyright Met Office. All rights reserved.
145
146=cut
Note: See TracBrowser for help on using the repository browser.