/usr/share/perl5/Bio/MAGE/Association.pm is in libbio-mage-perl 20030502.3-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 | ##############################
#
# Bio::MAGE::Association
#
##############################
package Bio::MAGE::Association;
use strict;
use Carp;
use Exporter;
use base qw/Exporter/;
use vars qw(@EXPORT_OK %EXPORT_TAGS);
use constant {
CARD_1 => '1',
CARD_0_OR_1 => '0..1',
CARD_1_TO_N => '1..N',
CARD_0_TO_N => '0..N',
};
@EXPORT_OK = ('CARD_1', 'CARD_0_OR_1', 'CARD_0_TO_N', 'CARD_1_TO_N');
%EXPORT_TAGS = (CARD => [@EXPORT_OK]);
=head1 Bio::MAGE::Association
=head2 SYNOPSIS
use Bio::MAGE::Association qw(:CARD);
# creating an empty instance
my $association = Bio::MAGE::Association->new();
# populating the instance in the constructor
my $association = Bio::MAGE::Association->new(self=>$assoc_end1,
other=>$assoc_end2);
# setting and retrieving the association ends
my $self_end = $association->self();
$association->self($value);
my $other_end = $association->other();
$association->other($value);
=head2 DESCRIPTION
This class holds the two association ends for each UML
association. C<self> is the end nearest the class of interest, while
C<other> is the end furthest away. The ends are of type
C<Bio::MAGE::Association::End>.
=head2 CARDINALITY
Associations in UML have a C<cardinality> that determines how many
objects can be associated. In the C<Bio::MAGE::Association>
modulte, C<cardinality> has two primary dimensions: B<optional> or
B<required>, and B<single> or B<list>. So there are four combinations
of the two dimensions:
=over 4
=item * 0..1
This is an B<optional> B<single> association, meaning it can have one
object associated, but it is optional.
=item * 1
This is a B<required> B<single> association, meaning it B<must> have
exactly one object associated.
=item * 0..N
This is an B<optional> B<list> association, meaning it can have many
objects associated.
=item * 1..N
This is an B<required> B<list> association, meaning it must have B<at
least> one object, but it B<may> have many.
=back
There are four constants defined in this module for handling the
cardinalities, and they can be imported into an application using the
B<CARD> import tag:
use Bio::MAGE::Association qw(:CARD);
The four constants are: B<CARD_0_OR_1>, B<CARD_1>, B<CARD_0_TO_N>, and
B<CARD_1_TO_N>.
=cut
sub new {
my $class = shift;
my $self = bless {}, $class;
if (scalar @_) {
my %args = @_;
foreach my $key (keys %args) {
no strict 'refs';
$self->$key($args{$key});
}
}
return $self;
}
sub self {
my $self = shift;
if (scalar @_) {
$self->{__SELF} = shift;
}
return $self->{__SELF};
}
sub other {
my $self = shift;
if (scalar @_) {
$self->{__OTHER} = shift;
}
return $self->{__OTHER};
}
##############################
#
# Bio::MAGE::Association::End
#
##############################
package Bio::MAGE::Association::End;
use strict;
use Carp;
=head1 Bio::MAGE::Association::End
=head2 SYNOPSIS
use Bio::MAGE::Association qw(:CARD);
# creating an empty instance
my $assoc_end = Bio::MAGE::Association::End->new();
# populating the instance in the constructor
my $assoc_end = Bio::MAGE::Association::End->new(
name=>$name,
is_ref=>$bool,
cardinality=>CARD_0_TO_N,
class_name=>$class_name,
documentation=>$doc_string,
rank=>$rank,
ordered=>$bool,
);
# setting and retrieving object attributes
my $name = $assoc_end->name();
$assoc_end->name($value);
my $is_ref = $assoc_end->is_ref();
$assoc_end->is_ref($value);
my $cardinality = $assoc_end->cardinality();
$assoc_end->cardinality($value);
my $class_name = $assoc_end->class_name();
$assoc_end->class_name($value);
my $documentation = $assoc_end->documentation();
$assoc_end->documentation($value);
my $rank = $assoc_end->rank();
$assoc_end->rank($value);
my $ordered = $assoc_end->ordered();
$assoc_end->ordered($value);
#
# Utility methods
#
# does this end of list cardinality (0..N or 1..N)
my $bool = $assoc_end->is_list();
=head2 DESCRIPTION
This class stores the information in a single UML association end.
=cut
sub new {
my $class = shift;
my $self = bless {}, $class;
if (scalar @_) {
my %args = @_;
foreach my $key (keys %args) {
no strict 'refs';
$self->$key($args{$key});
}
}
return $self;
}
sub cardinality {
my $self = shift;
if (scalar @_) {
$self->{__CARDINALITY} = shift;
}
return $self->{__CARDINALITY};
}
sub rank {
my $self = shift;
if (scalar @_) {
$self->{__RANK} = shift;
}
return $self->{__RANK};
}
sub ordered {
my $self = shift;
if (scalar @_) {
$self->{__ORDERED} = shift;
}
return $self->{__ORDERED};
}
sub is_ref {
my $self = shift;
if (scalar @_) {
$self->{__IS_REF} = shift;
}
return $self->{__IS_REF};
}
sub name {
my $self = shift;
if (scalar @_) {
$self->{__NAME} = shift;
}
return $self->{__NAME};
}
sub class_name {
my $self = shift;
if (scalar @_) {
$self->{__CLASS_NAME} = shift;
}
return $self->{__CLASS_NAME};
}
sub documentation {
my $self = shift;
if (scalar @_) {
$self->{__DOCUMENTATION} = shift;
}
return $self->{__DOCUMENTATION};
}
sub is_list {
my $self = shift;
return (($self->{__CARDINALITY} eq Bio::MAGE::Association::CARD_0_TO_N)
or ($self->{__CARDINALITY} eq Bio::MAGE::Association::CARD_1_TO_N))
}
1;
|