| 1 | # Copyright (C) 2004 Identity Commons. All Rights Reserved. | ||||||||||||||||||||||||||||
| 2 | # See LICENSE for licensing details | ||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||
| 4 | # Authors: | ||||||||||||||||||||||||||||
| 5 | # Fen Labalme <fen@idcommons.net> | ||||||||||||||||||||||||||||
| 6 | # Eugene Eric Kim <eekim@blueoxen.org> | ||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | package XRI::Descriptor; | ||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 4 | our $VERSION = 0.1; | |||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 4 | ▶ | use XRI::Descriptor::LocalAccess; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | 4 | ▶ | use XML::Smart; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 6 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 16 | 6 | my $self = shift; | |||||||||||||||||||||||||||
| 17 | 6 | my $xml = shift; | |||||||||||||||||||||||||||
| 18 | 6 | my $doc = XML::Smart->new( $xml ); | |||||||||||||||||||||||||||
| 19 | 6 | $doc = $doc->{XRIDescriptor}; | |||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 6 | bless { doc=>$doc }, $self; | |||||||||||||||||||||||||||
| 22 | } | ||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | 1 | ▶ | sub getResolved { | ||||||||||||||||||||||||||
|
Subroutine
getResolved: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 25 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 1 | return $self->{doc}{Resolved}; | |||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | # returns a reference to a list of URIs | ||||||||||||||||||||||||||||
| 31 | # | ||||||||||||||||||||||||||||
| 32 | 3 | ▶ | sub getXRIAuthorityURIs { | ||||||||||||||||||||||||||
|
Subroutine
getXRIAuthorityURIs: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 33 | 3 | my $self = shift; | |||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 3 | return \@{$self->{doc}{XRIAuthority}{URI}}; | |||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 1 | ▶ | sub getLocalAccess { | ||||||||||||||||||||||||||
|
Subroutine
getLocalAccess: called CC=9 SCAR=24.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 39 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 40 | 1 | my ($service, $type) = @_; | |||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 1 | my @localAccessObjects; | |||||||||||||||||||||||||||
| 43 | 1 | my @localAccessElements = @{$self->{doc}->{LocalAccess}}; | |||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | 1 | foreach my $element (@localAccessElements) { | |||||||||||||||||||||||||||
| 46 | 1 | my $object = XRI::Descriptor::LocalAccess->new; | |||||||||||||||||||||||||||
| 47 | 1 | ▶ | $object->service($element->{Service}) if ($element->{Service}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 48 | 1 | ▶ | if (!$service || $object->service eq $service) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not $service or $object->service eq $service
MC/DC0%0/2
not $service or $object->service eq $service
not $service
$object->service eq $service
Truth table33%1/3
not(A) or B
A= not $serviceB= $object->service eq $service
| |||||||||||||||||||||||||||||
| 49 | 1 | ▶ | if ($element->{URI}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 50 | # this conditional should be unnecessary if XML is valid. | ||||||||||||||||||||||||||||
| 51 | # according to the schema, there should always be at least | ||||||||||||||||||||||||||||
| 52 | # one URI per LocalAccess object. | ||||||||||||||||||||||||||||
| 53 | 1 | $object->uris($element->{URI}); | |||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||
| 55 | 1 | ▶ | $object->types($element->{Type}) if $element->{Type}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 56 | 1 | ▶ | if (!$type || grep(/^$type$/, $object->types)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not $type or grep /^$type$/, $object->types
MC/DC0%0/2
not $type or grep /^$type$/, $object->types
not $type
grep /^$type$/, $object->types
Truth table33%1/3
not(A) or B
A= not $typeB= grep /^$type$/, $object->types
| |||||||||||||||||||||||||||||
| 57 | 1 | push @localAccessObjects, $object; | |||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||
| 61 | 1 | return @localAccessObjects; | |||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | 1 | ▶ | sub getMappings { | ||||||||||||||||||||||||||
|
Subroutine
getMappings: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 65 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | 1 | return \@{$self->{doc}{Mapping}}; | |||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | 4 | 1; | |||||||||||||||||||||||||||
| 71 | __END__ | ||||||||||||||||||||||||||||