NAME
PerlBean::Collection - contains a ccollection of PerlBean objects
SYNOPSIS
use strict;
use PerlBean;
use PerlBean::Collection;
use PerlBean::Attribute::Factory;
my $bean = PerlBean->new ({
package => 'Athlete',
});
my $factory = PerlBean::Attribute::Factory->new ();
my $attr = $factory->createAttribute ({
attribute_name => 'name',
short_description => 'the name of the athlete',
});
$bean->addAttribute ($attr->getAttributeName (), $attr);
my $bean2 = PerlBean->new ({
package => 'Cyclist',
base => [ qw (Athlete)],
});
my $factory = PerlBean::Attribute::Factory->new ();
my $attr2 = $factory->createAttribute ({
attribute_name => 'cycle',
short_description => 'the cyclist\'s cycle',
});
$bean2->addAttribute ($attr2->getAttributeName (), $attr2);
my $collection = PerlBean::Collection->new ();
$collection->addBean ($bean->getPackage (), $bean);
$collection->addBean ($bean2->getPackage (), $bean2);
$collection->write ('tmp');
ABSTRACT
Code hierarchy generation for bean like Perl modules
DESCRIPTION
PerlBean::Collection contains a collection of PerlBean objects in order to generate an hierarchy of Perl modules.
CONSTRUCTOR
- new ([OPT_HASH_REF])
-
Creates a new
PerlBean::Collectionobject.OPT_HASH_REFis a hash reference used to pass initialization options. On error an exceptionError::Simpleis thrown.Options for
OPT_HASH_REFmay include:bean-
Passed to "setBean ()". Must be an
ARRAYreference. license-
Passed to "setLicense ()".
METHODS
- setBean ([KEY, VALUE ...])
-
Set the list of beans in the collection absolutely using keys/values.
KEY, VALUEare key/value pairs. 0 or more of these pairs may be supplied. Each key in is allowed to occur only once. Multiple occurences of the same key yield in the last occuring key to be inserted and the rest to be ignored. On error an exceptionError::Simpleis thrown. - addBean ([KEY, VALUE ...])
-
Add additional keys/values on the list of beans in the collection.
KEY, VALUEare key/value pairs. The addition may not yield to multiple identical keys in the list. Hence, multiple occurences of the same key cause the last occurence to be inserted. On error an exceptionError::Simpleis thrown. - deleteBean (ARRAY)
-
Delete elements from the list of beans in the collection. Returns the number of deleted elements. On error an exception
Error::Simpleis thrown. - existsBean (ARRAY)
-
Returns the count of items in
ARRAYthat are in the list of beans in the collection. - keysBean ()
-
Returns an
ARRAYcontaining the keys of the list of beans in the collection. - valuesBean ([KEY_ARRAY])
-
Returns an
ARRAYcontaining the values of the list of beans in the collection. IfKEY_ARRAYcontains one or moreKEYs the values related to theKEYs are returned. If noKEYs specified all values are returned. - setLicense (VALUE)
-
Set the software license for the PerlBean collection.
VALUEis the value. On error an exceptionError::Simpleis thrown. - getLicense ()
-
Returns the software license for the PerlBean collection.
- write (DIRECTORY)
-
Write the hierarchy of Perl class code to
DIRECTORY.DIRECTORYis a directory name. On error an exceptionError::Simpleis thrown.
SEE ALSO
PerlBean, PerlBean::Attribute, PerlBean::Attribute::Boolean, PerlBean::Attribute::Factory, PerlBean::Attribute::Multi, PerlBean::Attribute::Multi::Ordered, PerlBean::Attribute::Multi::Unique, PerlBean::Attribute::Multi::Unique::Associative, PerlBean::Attribute::Multi::Unique::Ordered, PerlBean::Attribute::Single
BUGS
None known (yet.)
HISTORY
First development: December 2002
AUTHOR
Vincenzo Zocca
COPYRIGHT
Copyright 2002 by Vincenzo Zocca
LICENSE
This file is part of the PerlBean module hierarchy for Perl by Vincenzo Zocca.
The PerlBean module hierarchy is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
The PerlBean module hierarchy is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with the PerlBean module hierarchy; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA