//================================================================================================== // D a t a _ s t r u c t u r e Java // E x t e n s i o n // E x t e n d a b l e C o l l e c t i o n // By Bruno Bachelet //================================================================================================== // Copyright (c) 1999-2016 // Bruno Bachelet - bruno@nawouak.net - http://www.nawouak.net // // This file is part of the B++ Library. This library is free software; you can redistribute it // and/or modify it under the terms of the GNU Library General Public License as published by the // Free Software Foundation; either version 2 of the License, or (at your option) any later // version. // // This library 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 Library General Public License for more details (http://www.gnu.org).
/*DESCRIPTION*/ /* This module provides a class to manage a collection of extendable objects. */
// Package //--------------------------------------------------------------------------------------- package bpp.data_structure.extension;
// Importation //----------------------------------------------------------------------------------- import java.util.Collection; import java.util.Iterator;
@SuppressWarnings("unchecked")
// E x t e n d a b l e C o l l e c t i o n Class //------------------------------------------------ /*CLASS ExtendableCollection */ /* Represents a collection of extendable objects. It allows to manage the additional properties of these objets through property maps. */ public class ExtendableCollection extends ExtendableContainer implements Collection { //---------------------------------------------------------------------------------------Attributes protected Collection atCollection; // Collection object that is actually wrapped. //--------------------------------------------------------------------------------------Constructor /*METHOD ExtendableCollection */ /* Builds an extendable collection around an existing collection. */ public ExtendableCollection(Collection agCollection) { super(); atCollection=agCollection; } //----------------------------------------------------------------------------------------------Add /*METHOD ExtendableCollection */ /* Adds the specified element to the collection. */ public boolean add(Object agObject) { attachProperties((ExtendableObject)agObject); return (atCollection.add(agObject)); } //-------------------------------------------------------------------------------------------AddAll /*METHOD ExtendableCollection */ /* Adds all the elements in the specified collection to this collection. <B>Not implemented yet.</B> */ public boolean addAll(Collection agCollection) { return (atCollection.addAll(agCollection)); } //--------------------------------------------------------------------------------------------Clear /*METHOD ExtendableCollection */ /* Removes all the elements from the collection. */ public void clear() { Iterator lcIterator = iterator();
while (lcIterator.hasNext()) detachProperties((ExtendableObject)lcIterator.next()); atCollection.clear(); } //-----------------------------------------------------------------------------------------Contains /*METHOD ExtendableCollection */ /* Returns <CODE>true</CODE> if the collection contains the specified element. */ public boolean contains(Object agObject) { return (atCollection.contains(agObject)); } //--------------------------------------------------------------------------------------ContainsAll /*METHOD ExtendableCollection */ /* Returns <CODE>true</CODE> if the collection contains all the elements in the specified collection. */ public boolean containsAll(Collection agCollection) { return (atCollection.containsAll(agCollection)); } //-------------------------------------------------------------------------------------------Equals /*METHOD ExtendableCollection */ /* Compares the specified object with the collection for equality. */ public boolean equals(Object agObject) { return (atCollection.equals(agObject)); } //-----------------------------------------------------------------------------------------HashCode /*METHOD ExtendableCollection */ /* Returns the hash code value for the collection. */ public int hashCode() { return (atCollection.hashCode()); } //------------------------------------------------------------------------------------------IsEmpty /*METHOD ExtendableCollection */ /* Returns <CODE>true</CODE> if the collection contains no element. */ public boolean isEmpty() { return (atCollection.isEmpty()); } //-----------------------------------------------------------------------------------------Iterator /*METHOD ExtendableCollection */ /* Returns an iterator over the elements in the collection. */ public Iterator iterator() { return (atCollection.iterator()); } //-------------------------------------------------------------------------------------------Remove /*METHOD ExtendableCollection */ /* Removes a single instance of the specified element from the collection, if it is present. */ public boolean remove(Object agObject) { detachProperties((ExtendableObject)agObject); return (atCollection.remove(agObject)); } //----------------------------------------------------------------------------------------RemoveAll /*METHOD ExtendableCollection */ /* Removes all the collection's elements that are also contained in the specified collection. <B>Not implemented yet.</B> */ public boolean removeAll(Collection agCollection) { return (atCollection.removeAll(agCollection)); } //----------------------------------------------------------------------------------------RetainAll /*METHOD ExtendableCollection */ /* Retains only the elements in the collection that are contained in the specified collection. <B>Not implemented yet.</B> */ public boolean retainAll(Collection agCollection) { return (atCollection.retainAll(agCollection)); } //---------------------------------------------------------------------------------------------Size /*METHOD ExtendableCollection */ /* Returns the number of elements in the collection. */ public int size() { return (atCollection.size()); } //------------------------------------------------------------------------------------------ToArray /*METHOD ExtendableCollection */ /* Returns an array containing all the elements in the collection. */ public Object[] toArray() { return (atCollection.toArray()); } //------------------------------------------------------------------------------------------ToArray /*METHOD ExtendableCollection */ /* Returns an array containing all the elements in this collection. The runtime type of the returned array is that of the specified array. */ public Object[] toArray(Object[] agArray) { return (atCollection.toArray(agArray)); } }
// End //------------------------------------------------------------------------------------------- |
|