[1980] | 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 | # ------------------------------------------------------------------------------ |
---|
| 6 | use strict; |
---|
| 7 | use warnings; |
---|
| 8 | |
---|
| 9 | package Fcm::Keyword::Entry::Location; |
---|
| 10 | use base qw{Fcm::Keyword::Entry}; |
---|
| 11 | |
---|
| 12 | use Fcm::Keyword::Config; |
---|
| 13 | |
---|
| 14 | sub 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_* |
---|
| 35 | for 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 |
---|
| 57 | sub is_implied { |
---|
| 58 | my ($self) = @_; |
---|
| 59 | return $self->{is_implied}; |
---|
| 60 | } |
---|
| 61 | |
---|
| 62 | 1; |
---|
| 63 | __END__ |
---|
| 64 | |
---|
| 65 | =head1 NAME |
---|
| 66 | |
---|
| 67 | Fcm::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 | |
---|
| 83 | This is a sub-class of L<Fcm::Keyword::Entry|Fcm::Keyword::Entry>. An object of |
---|
| 84 | this class represents a FCM location keyword entry. |
---|
| 85 | |
---|
| 86 | =head1 METHODS |
---|
| 87 | |
---|
| 88 | See L<Fcm::Keyword::Entry|Fcm::Keyword::Entry> for inherited methods. |
---|
| 89 | |
---|
| 90 | =over 4 |
---|
| 91 | |
---|
| 92 | =item new($args_ref) |
---|
| 93 | |
---|
| 94 | Constructor. |
---|
| 95 | |
---|
| 96 | =item get_browser_url_template() |
---|
| 97 | |
---|
| 98 | Returns 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 |
---|
| 100 | captured by the location component pattern and the revision template. See |
---|
| 101 | C<get_url_component_pattern()> and C<get_browser_rev_template()>. |
---|
| 102 | |
---|
| 103 | =item get_browser_rev_template() |
---|
| 104 | |
---|
| 105 | Returns the template string for constructing the revision part of the browser |
---|
| 106 | URL. The string {1} in the template string will be substituted by the revision. |
---|
| 107 | See C<get_browser_url_template()>. |
---|
| 108 | |
---|
| 109 | =item get_implied_entry_list() |
---|
| 110 | |
---|
| 111 | Returns a list of entries implied by this entry. |
---|
| 112 | |
---|
| 113 | =item get_location_component_pattern() |
---|
| 114 | |
---|
| 115 | Returns a regular expression, when matched against the scheme-specific-part in |
---|
| 116 | the actual URI of a location in the namespace of this keyword entry, will |
---|
| 117 | capture a list of components, which can then be used to replace the numbered |
---|
| 118 | fields in the browser URL template. See C<get_browser_url_template()>. |
---|
| 119 | |
---|
| 120 | =item get_revision_entries() |
---|
| 121 | |
---|
| 122 | Returns a L<Fcm::Keyword::Entries|Fcm::Keyword::Entries> object containing the |
---|
| 123 | revision keyword entries of this location. |
---|
| 124 | |
---|
| 125 | =item is_implied() |
---|
| 126 | |
---|
| 127 | Returns true if this is an implied entry. |
---|
| 128 | |
---|
| 129 | =back |
---|
| 130 | |
---|
| 131 | =head1 TO DO |
---|
| 132 | |
---|
| 133 | Introduce a Fcm::Keyword::Config module to store entries constructor setting. |
---|
| 134 | |
---|
| 135 | =head1 SEE ALSO |
---|
| 136 | |
---|
| 137 | L<Fcm::Keyword|Fcm::Keyword>, |
---|
| 138 | L<Fcm::Keyword::Config|Fcm::Keyword::Config>, |
---|
| 139 | L<Fcm::Keyword::Entries|Fcm::Keyword::Entries>, |
---|
| 140 | L<Fcm::Keyword::Entry|Fcm::Keyword::Entry> |
---|
| 141 | |
---|
| 142 | =head1 COPYRIGHT |
---|
| 143 | |
---|
| 144 | E<169> Crown copyright Met Office. All rights reserved. |
---|
| 145 | |
---|
| 146 | =cut |
---|