| 1 | # ===================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # Copyright (c) 2002,2003 IBM Corporation | ||||||||||||||||||||||||||||||||||||||||||||||
| 3 | # All rights reserved. This program and the accompanying materials | ||||||||||||||||||||||||||||||||||||||||||||||
| 4 | # are made available under the terms of the Common Public License v1.0 | ||||||||||||||||||||||||||||||||||||||||||||||
| 5 | # which accompanies this distribution, and is available at | ||||||||||||||||||||||||||||||||||||||||||||||
| 6 | # http://www.opensource.org/licenses/cpl.php | ||||||||||||||||||||||||||||||||||||||||||||||
| 7 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 8 | # ===================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||
| 9 | package OWL::LSID; | ||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 4 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 4 | ▶ | use base 'URI::urn'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||
| 17 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 18 | # new - Creates a new LS::ID object from a string | ||||||||||||||||||||||||||||||||||||||||||||||
| 19 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 20 | # Parameters: A URI containing the LSID | ||||||||||||||||||||||||||||||||||||||||||||||
| 21 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 22 | # Returns: An LS::ID object if successful, | ||||||||||||||||||||||||||||||||||||||||||||||
| 23 | # undef if the URI is not in the correct form | ||||||||||||||||||||||||||||||||||||||||||||||
| 24 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 1 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 1 | my ($class, $uri) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 1 | ▶ | return undef unless _is_valid($uri); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 1 | return bless \$uri, $class; | |||||||||||||||||||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||
| 34 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 35 | # _is_valid - Determines whether or not the LSID is a valid LSID | ||||||||||||||||||||||||||||||||||||||||||||||
| 36 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 37 | # Returns: undef if the LSID is not valid, | ||||||||||||||||||||||||||||||||||||||||||||||
| 38 | # true if the LSID is valid | ||||||||||||||||||||||||||||||||||||||||||||||
| 39 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 1 | ▶ | sub _is_valid { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_is_valid: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 1 | my ($string) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 1 | return $string =~ /^[uU][rR][nN]:[lL][sS][iI][dD]:[A-Za-z0-9][\w\(\)\+\,\-\.\=\@\;\$\"\!\*\']*:[A-Za-z0-9][\w\(\)\+\,\-\.\=\@\;\$\"\!\*\']*:[A-Za-z0-9][\w\(\)\+\,\-\.\=\@\;\$\"\!\*\']*(:[A-Za-z0-9][\w\(\)\+\,\-\.\=\@\;\$\"\!\*\']*)?$/; | |||||||||||||||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||||||
| 47 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 48 | # _component - | ||||||||||||||||||||||||||||||||||||||||||||||
| 49 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 3 | ▶ | sub _component { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_component: called CC=5 SCAR=25.2
| |||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 52 | 3 | my $index = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 3 | my @components = split(/:/, $self->nss()); | |||||||||||||||||||||||||||||||||||||||||||||
| 55 | 3 | my $value = $components[$index]; | |||||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 3 | ▶ | if (@_) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | ▶ | if (($index == 3 && $_[0] eq '') || ($_[0] =~ /^[A-Za-z0-9][\w\(\)\+\,\-\.\=\@\;\$\"\_\!\*\']*$/)) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$index == 3 and $_[0] eq "" or $_[0] =~ /^[A-Za-z0-9][\w\(\)\+\,\-\.\=\@\;\$\"\_\!\*\']*$/
$index == 3 and $_[0] eq ""
MC/DC0%0/3
$index == 3 and $_[0] eq "" or $_[0] =~ /^[A-Za-z0-9][\w\(\)\+\,\-\.\=\@\;\$\"\_\!\*\']*$/
$index == 3
$_[0] eq ""
$_[0] =~ /^[A-Za-z0-9][\w\(\)\+\,\-\.\=\@\;\$\"\_\!\*\']*$/
Truth table0%0/5
A and B or C
A= $index == 3B= $_[0] eq ""C= $_[0] =~ /^[A-Za-z0-9][\w\(\)\+\,\-\.\=\@\;\$\"\_\!\*\']*$/
| |||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | $components[$index] = $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | $self->nss(join(':', @components)); | |||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 64 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 3 | return $value; | |||||||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||
| 73 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 74 | # _authority - Access to the raw authority component of the LSID | ||||||||||||||||||||||||||||||||||||||||||||||
| 75 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 76 | # Returns: The raw string of the authority component | ||||||||||||||||||||||||||||||||||||||||||||||
| 77 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 1 | ▶ | sub _authority { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_authority: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 80 | 1 | return $self->_component(0, @_); | |||||||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||||||
| 84 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 85 | # authority - Access to the authority component of the LSID | ||||||||||||||||||||||||||||||||||||||||||||||
| 86 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 87 | # Returns: The authority component | ||||||||||||||||||||||||||||||||||||||||||||||
| 88 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 1 | ▶ | sub authority { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
authority: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 91 | 1 | return lc $self->_authority(@_); | |||||||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||||||
| 95 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 96 | # _namespace - | ||||||||||||||||||||||||||||||||||||||||||||||
| 97 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 1 | ▶ | sub _namespace { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_namespace: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 100 | 1 | return $self->_component(1, @_); | |||||||||||||||||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||||||
| 104 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 105 | # namespace - Access to the namespace component of the LSID | ||||||||||||||||||||||||||||||||||||||||||||||
| 106 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 107 | # Returns: The namespace component | ||||||||||||||||||||||||||||||||||||||||||||||
| 108 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 1 | ▶ | sub namespace { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
namespace: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 111 | 1 | return $self->_namespace(@_); | |||||||||||||||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||||||
| 115 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 116 | # _object - | ||||||||||||||||||||||||||||||||||||||||||||||
| 117 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 1 | ▶ | sub _object { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_object: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 120 | 1 | return $self->_component(2, @_); | |||||||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||||||
| 124 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 125 | # object - Access to the object component of the LSID | ||||||||||||||||||||||||||||||||||||||||||||||
| 126 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 127 | # Returns: The object component | ||||||||||||||||||||||||||||||||||||||||||||||
| 128 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 1 | ▶ | sub object { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
object: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 131 | 1 | return $self->_object(@_); | |||||||||||||||||||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||||||
| 135 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 136 | # _revision - | ||||||||||||||||||||||||||||||||||||||||||||||
| 137 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | ▶ | sub _revision { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_revision: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | return $self->_component(3, @_); | |||||||||||||||||||||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||||||
| 144 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 145 | # revision - Access to the revision component of the LSID | ||||||||||||||||||||||||||||||||||||||||||||||
| 146 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 147 | # Returns: The revision component | ||||||||||||||||||||||||||||||||||||||||||||||
| 148 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | ▶ | sub revision { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
revision: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | return $self->_revision(@_); | |||||||||||||||||||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||||||
| 155 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 156 | # canonical - Retrieves the canonicalized form of the LSID | ||||||||||||||||||||||||||||||||||||||||||||||
| 157 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 158 | # Parameters: | ||||||||||||||||||||||||||||||||||||||||||||||
| 159 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 160 | # Returns: The canonicalized LSID if successful, | ||||||||||||||||||||||||||||||||||||||||||||||
| 161 | # undef if unsuccessful | ||||||||||||||||||||||||||||||||||||||||||||||
| 162 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | ▶ | sub canonical { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
canonical: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | my $nss = $self->nss; | |||||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | my $new = $self->SUPER::canonical(); | |||||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||||||
| 170 | # If the scheme portion of the URN is not lowercase, e.g. "URN", | ||||||||||||||||||||||||||||||||||||||||||||||
| 171 | # URI::canonical will reset the scheme to lc scheme, which in turn will | ||||||||||||||||||||||||||||||||||||||||||||||
| 172 | # rebless the object as a URI::urn. In case this happens, we need to | ||||||||||||||||||||||||||||||||||||||||||||||
| 173 | # rebless it as an LS::ID here. | ||||||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | ▶ | bless ($new, __PACKAGE__) if (ref $new ne __PACKAGE__); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | ▶ | return $new if $nss !~ /[A-Z]/ && $nss !~ /:$/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$nss =~ /[A-Z]/ or $nss =~ /:$/
MC/DC0%0/2
$nss =~ /[A-Z]/ or $nss =~ /:$/
$nss =~ /[A-Z]/
$nss =~ /:$/
Truth table0%0/3
A or B
A= $nss =~ /[A-Z]/B= $nss =~ /:$/
| |||||||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | $nss =~ s/:$//; | |||||||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | ▶ | $new = $new->clone() if $new == $self; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | $new->authority(lc($self->authority())); | |||||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | return $new; | |||||||||||||||||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 4 | 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||||||
| 190 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||