coherence/util/TypedCollections.hpp

00001 /*
00002 * TypedCollections.hpp
00003 *
00004 * Copyright (c) 2000, 2009, Oracle and/or its affiliates. All rights reserved.
00005 *
00006 * Oracle is a registered trademarks of Oracle Corporation and/or its
00007 * affiliates.
00008 *
00009 * This software is the confidential and proprietary information of Oracle
00010 * Corporation. You shall not disclose such confidential and proprietary
00011 * information and shall use it only in accordance with the terms of the
00012 * license agreement you entered into with Oracle.
00013 *
00014 * This notice may not be removed or altered.
00015 */
00016 #ifndef COH_TYPED_COLLECTIONS_HPP
00017 #define COH_TYPED_COLLECTIONS_HPP
00018 
00019 #include "coherence/lang.ns"
00020 
00021 #include "coherence/util/Collection.hpp"
00022 #include "coherence/util/Converter.hpp"
00023 #include "coherence/util/ConverterCollections.hpp"
00024 #include "coherence/util/Iterator.hpp"
00025 #include "coherence/util/List.hpp"
00026 #include "coherence/util/Map.hpp"
00027 #include "coherence/util/Set.hpp"
00028 #include "coherence/util/WrapperCollections.hpp"
00029 
00030 COH_OPEN_NAMESPACE2(coherence,util)
00031 
00032 
00033 /**
00034 * A collection of wrapper classes which expose an underlying collection's
00035 * contents as explicit types rather then just as Objects.  Esentially these
00036 * are auto-casting collections.
00037 *
00038 * Each typed collection is templated based on one or more handle types
00039 * to a const coherence::lang::Object Object. For instance:
00040 * <tt>TypedCollection<String::View></tt> or
00041 * <tt>TypedMap<String::View, Integer32::View></tt>
00042 *
00043 * Alternate handle types may also be used for added functionalty,
00044 * for example: <tt>TypedMap<String::View, BoxHandle<const Integer32> ></tt>
00045 * produces a TypedMap which will auto-box the supplied values to Integer32,
00046 * making statements such as <tt>hMap->put("abc", 456)</tt> possible.
00047 *
00048 * These typed wrappers only provide a convenience over the underlying
00049 * collection. Thus they cannot guarantee that external usage of the
00050 * the underlying collection will not violate the restrictions imposed by the
00051 * wrapper. For instance Objects of a type other then those specified by
00052 * this template may exist within the collection.  Any retrieval of those
00053 * elements from the wrapper will result in ClassCastException.
00054 * External usage is possible anytime the typed wrapper is passed by its
00055 * inherited collection interface, i.e. passing a TypedMap as a plain Map.
00056 *
00057 * Member functions which take no input parameters cannot have their return
00058 * type changed. Instead there will be an auxilary function with the same name
00059 * plus a "Typed" suffix, e.g. TypedMap::keySetTyped().
00060 *
00061 * Example useage:
00062 * @code
00063 * typedef TypedCollections::TypedMap<String::View, Integer32::Handle> StringIntMap;
00064 * StringIntMap::Handle hMap = StringIntMap::create(HashMap::create());
00065 *
00066 * hMap->put("abc", Integer32::create(123));  // String's auto-boxing is utilized
00067 * Integer32::Handle hInt = hMap->get("abc"); // no cast of return type required
00068 * @endcode
00069 *
00070 * @author mf  2007.07.05
00071 */
00072 class COH_EXPORT TypedCollections
00073     {
00074     // ----- inner class: TypedIterator -------------------------------------
00075 
00076     public:
00077         /**
00078         * Typed wrapper over Iterator interface.
00079         */
00080         template<class T>
00081         class TypedIterator
00082             : public cloneable_spec<TypedIterator<T>,
00083                 extends<WrapperCollections::AbstractWrapperIterator> >
00084             {
00085             friend class factory<TypedIterator<T> >;
00086             typedef typename TypedIterator::super super;
00087 
00088             // ----- typedefs -------------------------------------------
00089 
00090             public:
00091                 /**
00092                 * The type of the handles returned by this iterator,
00093                 * e.g. String::View.
00094                 */
00095                 typedef T ValueType;
00096 
00097 
00098             // ----- constructors ---------------------------------------
00099 
00100             protected:
00101                 /**
00102                 * Create a new TypedIterator over the given Iterator.
00103                 *
00104                 * @param hIterDelegate a general "Object" Iterator to wrap
00105                 *        around
00106                 */
00107                 TypedIterator(Iterator::Handle hIterDelegate)
00108                     : super(hIterDelegate)
00109                     {
00110                     }
00111 
00112                 /**
00113                 * Copy constructor
00114                 */
00115                 TypedIterator(const TypedIterator& that)
00116                     : super(that)
00117                     {
00118                     }
00119 
00120             // ----- TypedIterator interface ----------------------------
00121 
00122             public:
00123                 /**
00124                 * The typed version of the method Iterator::next. Return the
00125                 * next element in the iteration.
00126                 *
00127                 * @return the next element in the iteration.
00128                 *
00129                 * @throws coherence::lang::NoSuchElementException
00130                 *         if iteration has no more elements.
00131                 * @throws ClassCastException
00132                 *         if the typed collection is broken by external usage
00133                 */
00134                 virtual ValueType nextTyped()
00135                     {
00136                     return cast<ValueType>(super::next());
00137                     }
00138             };
00139 
00140 
00141     // ----- inner class: TypedListIterator ---------------------------------
00142 
00143     public:
00144         /**
00145         * Typed wrapper over ListIterator interface.
00146         */
00147         template<class T>
00148         class TypedListIterator
00149             : public cloneable_spec<TypedListIterator<T>,
00150                 extends<WrapperCollections::AbstractWrapperListIterator> >
00151             {
00152             friend class factory<TypedListIterator<T> >;
00153             typedef typename TypedListIterator::super super;
00154 
00155             // ----- typedefs -------------------------------------------
00156 
00157             public:
00158                 /**
00159                 * The type of the handles returned by this iterator,
00160                 * e.g. String::View.
00161                 */
00162                 typedef T ValueType;
00163 
00164 
00165             // ----- constructors ---------------------------------------
00166 
00167             protected:
00168                 /**
00169                 * Create a new TypedListIterator over the given ListIterator.
00170                 *
00171                 * @param hIterDelegate a general "Object" Iterator to wrap
00172                 *        around
00173                 */
00174                 TypedListIterator(ListIterator::Handle hIterDelegate)
00175                     : super(hIterDelegate)
00176                     {
00177                     }
00178 
00179                 /**
00180                 * Copy constructor.
00181                 */
00182                 TypedListIterator(const TypedListIterator& that)
00183                     : super(that)
00184                     {
00185                     }
00186 
00187 
00188             // ----- TypedIterator interface ----------------------------
00189 
00190             public:
00191                 /**
00192                 * The typed version of the method Iterator::next. Return the
00193                 * next element in the iteration.
00194                 *
00195                 * @return the next element in the iteration.
00196                 *
00197                 * @throws coherence::lang::NoSuchElementException
00198                 *         if iteration has no more elements.
00199                 * @throws ClassCastException
00200                 *         if the typed collection is broken by external usage
00201                 */
00202                 virtual ValueType nextTyped()
00203                     {
00204                     return cast<ValueType>(super::next());
00205                     }
00206 
00207 
00208             // ----- ListIterator interface -----------------------------
00209 
00210             public:
00211                 /**
00212                 * The typed version of the method ListIterator::previous.
00213                 * <p> Return the previous element in the iteration.
00214                 *
00215                 * @return the previous element in the iteration.
00216                 *
00217                 * @throws coherence::lang::NoSuchElementException
00218                 *         if iteration has no previous elements.
00219                 * @throws ClassCastException
00220                 *         if the typed collection is broken by external usage
00221                 */
00222                 virtual ValueType previousTyped()
00223                     {
00224                     return cast<ValueType>(super::previous());
00225                     }
00226 
00227 
00228             // ----- ListMuterator interface ----------------------------
00229 
00230             public:
00231                 /**
00232                 * The typed version of the method ListIterator::add.
00233                 * <p>
00234                 * Insert the specified element immediatly before the element
00235                 * to be returned from the next call to the next() method. A
00236                 * subsequent call to next() will not return the added
00237                 * element, while a call to previous() would return the added
00238                 * element.
00239                 *
00240                 * @param v  the element to add
00241                 *
00242                 * @throws UnsupportedOperationException if addition is not
00243                 *         supported
00244                 */
00245                 virtual void add(ValueType v)
00246                     {
00247                     super::add(v);
00248                     }
00249 
00250                 using super::add;
00251 
00252                 /**
00253                 * The typed version of the method ListIterator::set.
00254                 * <p>
00255                 * Replace the last element returned by next() or previous() with
00256                 * the specified element.
00257                 *
00258                 * @param oh  the element to store
00259                 *
00260                 * @throws UnsupportedOperationException if set is not supported
00261                 */
00262                 virtual void set(ValueType v)
00263                     {
00264                     super::set(v);
00265                     }
00266 
00267                 using super::set;
00268             };
00269 
00270 
00271         // ---- inner class: TypedCollection --------------------------------
00272 
00273         /**
00274         * Typed wrapper over Collection interface.
00275         */
00276         template<class T>
00277         class TypedCollection
00278             : public cloneable_spec<TypedCollection<T>,
00279                 extends<WrapperCollections::AbstractWrapperCollection> >
00280             {
00281             friend class factory<TypedCollection<T> >;
00282             typedef typename TypedCollection::this_spec super;
00283 
00284             // ----- typedefs -------------------------------------------
00285 
00286             public:
00287                 /**
00288                 * The type of the objects stored in this collection, that
00289                 * e.g. String::View.
00290                 */
00291                 typedef T ValueType;
00292 
00293                 /**
00294                 * The type of the iterator over this collection.
00295                 */
00296                 typedef TypedIterator<T> Iterator;
00297 
00298 
00299             // ----- constructors ---------------------------------------
00300 
00301             protected:
00302                 /**
00303                 * Create a new TypedCollection over the given Collection.
00304                 *
00305                 * @param ohCollDelegate  the Collection to delegate to
00306                 */
00307                 TypedCollection(Collection::Holder ohCollDelegate)
00308                     : super(ohCollDelegate)
00309                     {
00310                     }
00311 
00312                 /**
00313                 * Copy constructor.
00314                 */
00315                 TypedCollection(const TypedCollection& that)
00316                     : super(that)
00317                     {
00318                     }
00319 
00320 
00321             // ----- TypedCollection interface --------------------------
00322 
00323             public:
00324                 /**
00325                 * The typed version of the method Collection::iterator.
00326                 * Return a handle to an TypedIterator over the elements in
00327                 * this collection.
00328                 *
00329                 * @return a TypedIterator over the elements in this
00330                 *         collection
00331                 */
00332                 virtual typename TypedCollection::Iterator::Handle iteratorTyped() const
00333                     {
00334                     return TypedCollection::Iterator::create(super::iterator());
00335                     }
00336 
00337                 /**
00338                 * The typed version of the method Collection::iterator.
00339                 * Return a handle to an TypedIterator over the elements in
00340                 * this collection.
00341                 *
00342                 * @return a TypedIterator over the elements in this
00343                 *         collection
00344                 */
00345                 virtual typename TypedCollection::Iterator::Handle iteratorTyped()
00346                     {
00347                     return TypedCollection::Iterator::create(super::iterator());
00348                     }
00349 
00350                 /**
00351                 * {@inheritDoc}
00352                 */
00353                 virtual coherence::util::Iterator::Handle iterator() const
00354                     {
00355                     return iteratorTyped();
00356                     }
00357 
00358                 /**
00359                 * {@inheritDoc}
00360                 */
00361                 virtual coherence::util::Muterator::Handle iterator()
00362                     {
00363                     return iteratorTyped();
00364                     }
00365 
00366                 /**
00367                 * {@inheritDoc}
00368                 */
00369                 using super::contains;
00370 
00371                 /**
00372                 * The typed version of the method Collection::contains.
00373                 *
00374                 * Return true if this collection contains the specified
00375                 * element.
00376                 *
00377                 * @param v element whose presence in this collection is to
00378                 *          be tested
00379                 *
00380                 * @return true if this collection contains the specified
00381                 *         element
00382                 */
00383                 virtual bool contains(ValueType v) const
00384                     {
00385                     return super::contains(v);
00386                     }
00387 
00388                 /**
00389                 * {@inheritDoc}
00390                 */
00391                 using super::add;
00392 
00393                 /**
00394                 * The typed version of the method Collection::add. Ensure
00395                 * that this collection contains the specified element.
00396                 *
00397                 * @param v element whose presence in this collection is to be
00398                 *          ensured
00399                 *
00400                 * @return true if this collection changed as a result of the
00401                 *         call
00402                 *
00403                 * @throws coherence::lang::UnsupportedOperationException
00404                 *         if the #add() operation is not supported by this
00405                 *         collection
00406                 */
00407                 virtual bool add(ValueType v)
00408                     {
00409                     return super::add(v);
00410                     }
00411 
00412                 /**
00413                 * {@inheritDoc}
00414                 */
00415                 using super::remove;
00416 
00417                 /**
00418                 * The typed version of the method Collection::remove. Remove
00419                 * a single instance of the specified element from this
00420                 * collection, if it is present.
00421                 *
00422                 * @param v element to be removed from this collection, if
00423                 *          present
00424                 *
00425                 * @return true if this collection changed as a result of
00426                 *         the call
00427                 *
00428                 * @throws coherence::lang::UnsupportedOperationException
00429                 *         if the #remove() operation is not supported by this
00430                 *         collection
00431                 */
00432                 virtual bool remove(ValueType v)
00433                     {
00434                     return super::remove(v);
00435                     }
00436 
00437                 /**
00438                 * {@inheritDoc}
00439                 */
00440                 using super::addAll;
00441 
00442                 /**
00443                 * The typed version of the method Collection::addAll.
00444                 *
00445                 * Add all of the elements in the specified collection to this
00446                 * collection.
00447                 *
00448                 * @param vtc TypedCollection of elements to be inserted into
00449                 *            this collection
00450                 *
00451                 * @return true if this collection changed as a result of
00452                 *         the call
00453                 *
00454                 * @throws coherence::lang::NullPointerException
00455                 *         if the specified collection is NULL
00456                 * @throws coherence::lang::UnsupportedOperationException
00457                 *         if the #add() operation is not supported by this
00458                 *         collection
00459                 */
00460                 virtual bool addAll(typename TypedCollection::View vtc)
00461                     {
00462                     return super::addAll(vtc);
00463                     }
00464 
00465                 /**
00466                 * {@inheritDoc}
00467                 */
00468                 using super::removeAll;
00469 
00470                 /**
00471                 * The typed version of the method Collection::removeAll.
00472                 *
00473                 * Remove all this collection's elements that are also
00474                 * contained in the specified typed collection.
00475                 *
00476                 * @param vtc elements to be removed from this collection
00477                 *
00478                 * @return true if this collection changed as a result of
00479                 *         the call
00480                 *
00481                 * @throws coherence::lang::NullPointerException
00482                 *         if the specified collection is NULL
00483                 * @throws coherence::lang::UnsupportedOperationException
00484                 *         if the #remove() operation is not supported by this
00485                 *         collection
00486                 */
00487                 virtual bool removeAll(typename TypedCollection::View vtc)
00488                     {
00489                     return super::removeAll(vtc);
00490                     }
00491 
00492                 /**
00493                 * {@inheritDoc}
00494                 */
00495                 using super::retainAll;
00496 
00497                 /**
00498                 * The typed version of the method Collection::retainAll.
00499                 *
00500                 * Retain only the elements in this collection that are
00501                 * contained in the specified typed collection.
00502                 *
00503                 * @param vtc elements to be retained in this collection
00504                 *
00505                 * @return true if this collection changed as a result of
00506                 *         the call
00507                 *
00508                 * @throws coherence::lang::NullPointerException
00509                 *         if the specified collection is NULL
00510                 * @throws coherence::lang::UnsupportedOperationException
00511                 *         if the #remove() operation is not supported by this
00512                 *         collection
00513                 */
00514                 virtual bool retainAll(typename TypedCollection::View vtc)
00515                     {
00516                     return super::retainAll(vtc);
00517                     }
00518             };
00519 
00520 
00521         // ----- inner class: TypedSet --------------------------------------
00522 
00523         /**
00524         * Typed wrapper over Set interface.
00525         */
00526         template<class T>
00527         class TypedSet
00528             : public cloneable_spec<TypedSet<T>,
00529                 extends<WrapperCollections::AbstractWrapperSet> >
00530             {
00531             friend class factory<TypedSet<T> >;
00532             typedef typename TypedSet::super super;
00533 
00534             // ----- typedefs -------------------------------------------
00535 
00536             public:
00537                 /**
00538                 * The type of the objects stored in this set, that
00539                 * e.g. String::View.
00540                 */
00541                 typedef T ValueType;
00542 
00543                 /**
00544                 * The type of the iterator over this set.
00545                 */
00546                 typedef TypedIterator<T> Iterator;
00547 
00548 
00549             // ----- constructors ---------------------------------------
00550 
00551             protected:
00552                 /**
00553                 * Create a new TypedSet over the given Set.
00554                 *
00555                 * @param ohSetDelegate  the Set to delegate to
00556                 */
00557                 TypedSet(Set::Holder ohSetDelegate)
00558                     : super(ohSetDelegate)
00559                     {
00560                     }
00561 
00562                 /**
00563                 * Copy constructor.
00564                 */
00565                 TypedSet(const TypedSet& that)
00566                     : super(that)
00567                     {
00568                     }
00569 
00570 
00571             // ----- TypedSet interface ---------------------------------
00572 
00573             public:
00574                 /**
00575                 * {@inheritDoc}
00576                 */
00577                 using super::contains;
00578 
00579                 /**
00580                 * The typed version of the method Collection::contains.
00581                 * Return true if this set contains the specified element.
00582                 *
00583                 * @param v element whose presence in this set is to be tested
00584                 *
00585                 * @return true if this collection contains the specified
00586                 *         element
00587                 */
00588                 virtual bool contains(ValueType v) const
00589                     {
00590                     return super::contains(v);
00591                     }
00592 
00593                 /**
00594                 * The typed version of the method Collection::iterator.
00595                 * Return a handle to an TypedIterator over the elements in
00596                 * this set.
00597                 *
00598                 * @return a TypedIterator over the elements in this
00599                 *         set
00600                 */
00601                 virtual typename TypedSet::Iterator::Handle iteratorTyped() const
00602                     {
00603                     return TypedSet::Iterator::create(super::iterator());
00604                     }
00605 
00606                 /**
00607                 * The typed version of the method Collection::iterator.
00608                 * Return a handle to an TypedIterator over the elements in
00609                 * this set.
00610                 *
00611                 * @return a TypedIterator over the elements in this
00612                 *         set
00613                 */
00614                 virtual typename TypedSet::Iterator::Handle iteratorTyped()
00615                     {
00616                     return TypedSet::Iterator::create(super::iterator());
00617                     }
00618 
00619                 /**
00620                 * {@inheritDoc}
00621                 */
00622                 virtual coherence::util::Iterator::Handle iterator() const
00623                     {
00624                     return iteratorTyped();
00625                     }
00626 
00627                 /**
00628                 * {@inheritDoc}
00629                 */
00630                 virtual coherence::util::Muterator::Handle iterator()
00631                     {
00632                     return iteratorTyped();
00633                     }
00634 
00635                 /**
00636                 * {@inheritDoc}
00637                 */
00638                 using super::add;
00639 
00640                 /**
00641                 * The typed version of the method Set::add. Add the specified
00642                 * element to this set if it is not already present.
00643                 *
00644                 * @param v element to be added to this set.
00645                 *
00646                 * @return true if this set changed as a result of the
00647                 *         call
00648                 *
00649                 * @throws coherence::lang::UnsupportedOperationException
00650                 *         if the #add() operation is not supported by this
00651                 *         set
00652                 */
00653                 virtual bool add(ValueType v)
00654                     {
00655                     return super::add(v);
00656                     }
00657 
00658                 /**
00659                 * {@inheritDoc}
00660                 */
00661                 using super::remove;
00662 
00663                 /**
00664                 * The typed version of the method Collection::remove. Remove
00665                 * the specified element from this set, if it is present.
00666                 *
00667                 * @param v element to be removed from this set, if present
00668                 *
00669                 * @return true if this set changed as a result of
00670                 *         the call
00671                 *
00672                 * @throws coherence::lang::UnsupportedOperationException
00673                 *         if the #remove() operation is not supported by this
00674                 *         set
00675                 */
00676                 virtual bool remove(ValueType v)
00677                     {
00678                     return super::remove(v);
00679                     }
00680 
00681                 /**
00682                 * {@inheritDoc}
00683                 */
00684                 using super::addAll;
00685 
00686                 /**
00687                 * The typed version of the method Collection::addAll.
00688                 *
00689                 * Add all of the elements in the specified TypedCollection to
00690                 * this set.
00691                 *
00692                 * @param vtc TypedCollection of elements to be inserted into
00693                 *            this set
00694                 *
00695                 * @return true if this set changed as a result of the call
00696                 *
00697                 * @throws coherence::lang::NullPointerException
00698                 *         if the specified collection is NULL
00699                 * @throws coherence::lang::UnsupportedOperationException
00700                 *         if the #add() operation is not supported by this set
00701                 */
00702                 virtual bool addAll(typename
00703                                 TypedCollection<ValueType>::View vtc)
00704                     {
00705                     return super::addAll(vtc);
00706                     }
00707 
00708                 /**
00709                 * The typed version of the method Collection::addAll.
00710                 *
00711                 * Add all of the elements in the specified TypedCollection to
00712                 * this set.
00713                 *
00714                 * @param htc TypedCollection of elements to be inserted into
00715                 *            this set
00716                 *
00717                 * @return true if this set changed as a result of the call
00718                 *
00719                 * @throws coherence::lang::NullPointerException
00720                 *         if the specified collection is NULL
00721                 * @throws coherence::lang::UnsupportedOperationException
00722                 *         if the #add() operation is not supported by this set
00723                 */
00724                 virtual bool addAll(typename
00725                                 TypedCollection<ValueType>::Handle htc)
00726                     {
00727                     return super::addAll(htc);
00728                     }
00729 
00730                 /**
00731                 * The typed version of the method Collection::addAll.
00732                 *
00733                 * Add all of the elements in the specified TypedSet to this
00734                 * set.
00735                 *
00736                 * @param vts TypedSet of elements to be inserted into
00737                 *            this set
00738                 *
00739                 * @return true if this set changed as a result of the call
00740                 *
00741                 * @throws coherence::lang::NullPointerException
00742                 *         if the specified collection is NULL
00743                 * @throws coherence::lang::UnsupportedOperationException
00744                 *         if the #add() operation is not supported by this set
00745                 */
00746                 virtual bool addAll(typename TypedSet<ValueType>::View vts)
00747                     {
00748                     return super::addAll(vts);
00749                     }
00750 
00751                 /**
00752                 * The typed version of the method Collection::addAll.
00753                 *
00754                 * Add all of the elements in the specified TypedSet to this
00755                 * set.
00756                 *
00757                 * @param hts TypedSet of elements to be inserted into
00758                 *            this set
00759                 *
00760                 * @return true if this set changed as a result of the call
00761                 *
00762                 * @throws coherence::lang::NullPointerException
00763                 *         if the specified collection is NULL
00764                 * @throws coherence::lang::UnsupportedOperationException
00765                 *         if the #add() operation is not supported by this set
00766                 */
00767                 virtual bool addAll(typename TypedSet<ValueType>::Handle hts)
00768                     {
00769                     return super::addAll(hts);
00770                     }
00771 
00772                 /**
00773                 * {@inheritDoc}
00774                 */
00775                 using super::removeAll;
00776 
00777                 /**
00778                 * The typed version of the method Collection::removeAll.
00779                 *
00780                 * Remove all this set's elements that are also contained in
00781                 * the specified typed collection.
00782                 *
00783                 * @param vtc elements to be removed from this set
00784                 *
00785                 * @return true if this set changed as a result of
00786                 *         the call
00787                 *
00788                 * @throws coherence::lang::NullPointerException
00789                 *         if the specified collection is NULL
00790                 * @throws coherence::lang::UnsupportedOperationException
00791                 *         if the #remove() operation is not supported by this
00792                 *         set
00793                 */
00794                 virtual bool removeAll(typename
00795                                 TypedCollection<ValueType>::View vtc)
00796                     {
00797                     return super::removeAll(vtc);
00798                     }
00799 
00800                 /**
00801                 * The typed version of the method Collection::removeAll.
00802                 *
00803                 * Remove all this set's elements that are also contained in
00804                 * the specified typed collection.
00805                 *
00806                 * @param htc elements to be removed from this set
00807                 *
00808                 * @return true if this set changed as a result of
00809                 *         the call
00810                 *
00811                 * @throws coherence::lang::NullPointerException
00812                 *         if the specified collection is NULL
00813                 * @throws coherence::lang::UnsupportedOperationException
00814                 *         if the #remove() operation is not supported by this
00815                 *         set
00816                 */
00817                 virtual bool removeAll(typename
00818                                 TypedCollection<ValueType>::Handle htc)
00819                     {
00820                     return super::removeAll(htc);
00821                     }
00822 
00823                 /**
00824                 * The typed version of the method Collection::removeAll.
00825                 *
00826                 * Remove all this set's elements that are also contained in
00827                 * the specified typed set.
00828                 *
00829                 * @param vts elements to be removed from this set
00830                 *
00831                 * @return true if this set changed as a result of
00832                 *         the call
00833                 *
00834                 * @throws coherence::lang::NullPointerException
00835                 *         if the specified collection is NULL
00836                 * @throws coherence::lang::UnsupportedOperationException
00837                 *         if the #remove() operation is not supported by this
00838                 *         set
00839                 */
00840                 virtual bool removeAll(typename
00841                                 TypedSet<ValueType>::View vts)
00842                     {
00843                     return super::removeAll(vts);
00844                     }
00845 
00846                 /**
00847                 * The typed version of the method Collection::removeAll.
00848                 *
00849                 * Remove all this set's elements that are also contained in
00850                 * the specified typed set.
00851                 *
00852                 * @param hts elements to be removed from this set
00853                 *
00854                 * @return true if this set changed as a result of
00855                 *         the call
00856                 *
00857                 * @throws coherence::lang::NullPointerException
00858                 *         if the specified collection is NULL
00859                 * @throws coherence::lang::UnsupportedOperationException
00860                 *         if the #remove() operation is not supported by this
00861                 *         set
00862                 */
00863                 virtual bool removeAll(typename
00864                                 TypedSet<ValueType>::Handle hts)
00865                     {
00866                     return super::removeAll(hts);
00867                     }
00868 
00869                 /**
00870                 * {@inheritDoc}
00871                 */
00872                 using super::retainAll;
00873 
00874                 /**
00875                 * The typed version of the method Collection::retainAll.
00876                 *
00877                 * Retain only the elements in this set that are
00878                 * contained in the specified typed collection.
00879                 *
00880                 * @param vtc elements to be retained in this set
00881                 *
00882                 * @return true if this set changed as a result of
00883                 *         the call
00884                 *
00885                 * @throws coherence::lang::NullPointerException
00886                 *         if the specified collection is NULL
00887                 * @throws coherence::lang::UnsupportedOperationException
00888                 *         if the #remove() operation is not supported by this
00889                 *         set
00890                 */
00891                 virtual bool retainAll(typename
00892                                 TypedCollection<ValueType>::View vtc)
00893                     {
00894                     return super::retainAll(vtc);
00895                     }
00896 
00897                 /**
00898                 * The typed version of the method Collection::retainAll.
00899                 *
00900                 * Retain only the elements in this set that are
00901                 * contained in the specified typed collection.
00902                 *
00903                 * @param htc elements to be retained in this set
00904                 *
00905                 * @return true if this set changed as a result of
00906                 *         the call
00907                 *
00908                 * @throws coherence::lang::NullPointerException
00909                 *         if the specified collection is NULL
00910                 * @throws coherence::lang::UnsupportedOperationException
00911                 *         if the #remove() operation is not supported by this
00912                 *         set
00913                 */
00914                 virtual bool retainAll(typename
00915                                 TypedCollection<ValueType>::Handle htc)
00916                     {
00917                     return super::retainAll(htc);
00918                     }
00919 
00920                 /**
00921                 * The typed version of the method Collection::retainAll.
00922                 *
00923                 * Retain only the elements in this set that are
00924                 * contained in the specified typed set.
00925                 *
00926                 * @param vts elements to be retained in this set
00927                 *
00928                 * @return true if this set changed as a result of
00929                 *         the call
00930                 *
00931                 * @throws coherence::lang::NullPointerException
00932                 *         if the specified collection is NULL
00933                 * @throws coherence::lang::UnsupportedOperationException
00934                 *         if the #remove() operation is not supported by this
00935                 *         set
00936                 */
00937                 virtual bool retainAll(typename
00938                                 TypedSet<ValueType>::View vts)
00939                     {
00940                     return super::retainAll(vts);
00941                     }
00942 
00943                 /**
00944                 * The typed version of the method Collection::retainAll.
00945                 *
00946                 * Retain only the elements in this set that are
00947                 * contained in the specified typed set.
00948                 *
00949                 * @param hts elements to be retained in this set
00950                 *
00951                 * @return true if this set changed as a result of
00952                 *         the call
00953                 *
00954                 * @throws coherence::lang::NullPointerException
00955                 *         if the specified collection is NULL
00956                 * @throws coherence::lang::UnsupportedOperationException
00957                 *         if the #remove() operation is not supported by this
00958                 *         set
00959                 */
00960                 virtual bool retainAll(typename
00961                                 TypedSet<ValueType>::Handle hts)
00962                     {
00963                     return super::retainAll(hts);
00964                     }
00965 
00966                 /**
00967                 * Convert a TypedSet to a TypedCollection, wrapping the same
00968                 * underlying Collection::Handle.
00969                 *
00970                 * @return a handle to the new TypedCollection
00971                 */
00972                 virtual typename TypedCollection<ValueType>::Handle
00973                     asTypedCollection()
00974                     {
00975                     return TypedCollection<ValueType>::create(
00976                         cast<Collection::Handle>(super::getDelegate()));
00977                     }
00978 
00979                 /**
00980                 * Convert a TypedSet to a TypedCollection, wrapping the same
00981                 * underlying Collection::View.
00982                 *
00983                 * @return a view to the new TypedCollection
00984                 */
00985                 virtual typename TypedCollection<ValueType>::View
00986                     asTypedCollection() const
00987                     {
00988                     return TypedCollection<ValueType>::create(
00989                         cast<Collection::View>(super::getDelegate()));
00990                     }
00991             };
00992 
00993 
00994         // ----- inner class: TypedEntry ------------------------------------
00995 
00996         /**
00997         * Typed wrapper over Map::Entry interface. Both key and value objects
00998         * are typed. The types of key and value may differ.
00999         */
01000         template<class K, class V>
01001         class TypedEntry
01002             : public cloneable_spec<TypedEntry<K, V>,
01003                 extends<WrapperCollections::AbstractWrapperEntry> >
01004             {
01005             friend class factory<TypedEntry<K, V> >;
01006             typedef typename TypedEntry::this_spec super;
01007 
01008             // ----- typedefs -------------------------------------------
01009 
01010             public:
01011                 /**
01012                 * The type of the keys, e.g. String::View.
01013                 */
01014                 typedef K KeyType;
01015 
01016                 /**
01017                 * The type the values, e.g. String::View.
01018                 */
01019                 typedef V ValueType;
01020 
01021 
01022             // ----- constructors ---------------------------------------
01023 
01024             protected:
01025                 /**
01026                 * Create a new TypedEntry over the given Map::Entry.
01027                 *
01028                 *
01029                 * @param ohEntryDelegate  the Entry to delegate to
01030                 */
01031                 TypedEntry(Map::Entry::Holder ohEntryDelegate)
01032                     : super(ohEntryDelegate)
01033                     {
01034                     }
01035 
01036                 /**
01037                 * Copy constructor.
01038                 */
01039                 TypedEntry(const TypedEntry& that)
01040                     : super(that)
01041                     {
01042                     }
01043 
01044 
01045             // ----- TypedEntry interface -------------------------------
01046 
01047             public:
01048                 /**
01049                 * The typed version of the method Map::Entry::getKey.
01050                 *
01051                 * Return the key corresponding to this entry.
01052                 *
01053                 * @return the key corresponding to this entry.
01054                 *
01055                 * @throws ClassCastException
01056                 *         if the typed entry is broken by external usage
01057                 */
01058                 virtual KeyType getKeyTyped() const
01059                     {
01060                     return cast<KeyType>(super::getKey());
01061                     }
01062 
01063                 /**
01064                 * The typed version of the method Map::Entry::getKey.
01065                 *
01066                 * Return the value corresponding to this entry.
01067                 *
01068                 * @return the value corresponding to this entry.
01069                 *
01070                 * @throws ClassCastException
01071                 *         if the typed entry is broken by external usage
01072                 */
01073                 virtual ValueType getValueTyped() const
01074                     {
01075                     return cast<ValueType>(super::getValue());
01076                     }
01077 
01078                 /**
01079                 * The typed version of the method Map::Entry::getKey.
01080                 *
01081                 * Return the value corresponding to this entry.
01082                 *
01083                 * @return the value corresponding to this entry.
01084                 *
01085                 * @throws ClassCastException
01086                 *         if the typed entry is broken by external usage
01087                 */
01088                 virtual ValueType getValueTyped()
01089                     {
01090                     return cast<ValueType>(super::getValue());
01091                     }
01092 
01093                 /**
01094                 * {@inheritDoc}
01095                 */
01096                 using super::setValue;
01097 
01098                 /**
01099                 * Update the value of the map entry.
01100                 *
01101                 * @param ohValue  the new value for the entry
01102                 *
01103                 * @return the prior value
01104                 */
01105                 virtual ValueType setValue(ValueType ohValue)
01106                     {
01107                     return cast<ValueType>(super::setValue(ohValue));
01108                     }
01109             };
01110 
01111 
01112         // ----- inner class: TypedMap --------------------------------------
01113 
01114         /**
01115         * Typed wrapper over Map interface.
01116         */
01117         template<class K, class V>
01118         class TypedMap
01119             : public cloneable_spec<TypedMap<K, V>,
01120                 extends<WrapperCollections::AbstractWrapperMap> >
01121             {
01122             friend class factory<TypedMap<K, V> >;
01123             typedef typename TypedMap::this_spec super;
01124 
01125             // ----- typedefs -------------------------------------------
01126 
01127             public:
01128                 /**
01129                 * The type of the map's keys, e.g. String::View.
01130                 */
01131                 typedef K KeyType;
01132 
01133                 /**
01134                 * The type of the map's values, e.g. String::View.
01135                 */
01136                 typedef V ValueType;
01137 
01138                 /**
01139                 * The type of the entries stored in this map.
01140                 */
01141                 typedef TypedEntry<KeyType, ValueType> Entry;
01142 
01143                 /**
01144                 * The type of the key set associated with this map.
01145                 */
01146                 typedef TypedSet<KeyType> KeySet;
01147 
01148                 /**
01149                 * The type of the values collection associated with this map.
01150                 */
01151                 typedef TypedCollection<ValueType> ValueCollection;
01152 
01153                 /**
01154                 * The type of the entry set associated with this map.
01155                 */
01156                 typedef TypedSet<typename Entry::View> EntrySet;
01157 
01158 
01159             // ----- inner class: EntryConverter ------------------------
01160 
01161             protected:
01162                 /**
01163                 * A converter from untyped to typed entries:
01164                 * Map::Entry -> TypedEntry
01165                 */
01166                 class EntryConverter
01167                     : public class_spec<EntryConverter,
01168                         extends<Object>,
01169                         implements<Converter> >
01170                     {
01171                     friend class factory<EntryConverter>;
01172 
01173                     // ----- constructors ---------------------------
01174 
01175                     protected:
01176                         /**
01177                         * Create new EntryConverter instance.
01178                         */
01179                         EntryConverter()
01180                             {
01181                             }
01182 
01183                         /**
01184                         * Copy constructor.
01185                         */
01186                         EntryConverter(const EntryConverter&)
01187                             {
01188                             }
01189 
01190 
01191                     // ----- Converter interface --------------------
01192 
01193                     public:
01194                         /**
01195                         * {@inheritDoc}
01196                         */
01197                         virtual Object::Holder convert(Object::Holder oh) const
01198                             {
01199                             typename Entry::View vEntry =
01200                                     cast<typename Entry::View>(oh, false);
01201                             if (vEntry == NULL)
01202                                 {
01203                                 // conversion from Map::Entry to
01204                                 // TypedMap::Entry required
01205                                 // maintain Object::Holder view/handle
01206                                 Map::Entry::Handle h =
01207                                         cast<Map::Entry::Handle>(oh, false);
01208                                 if (h == NULL)
01209                                     {
01210                                     return Entry::create(
01211                                             cast<Map::Entry::View>(oh));
01212                                     }
01213                                 return Entry::create(h);
01214                                 }
01215                             else
01216                                 {
01217                                 // no conversion necessary
01218                                 return oh;
01219                                 }
01220                             }
01221 
01222                     // ----- Object interface -----------------------
01223 
01224                     public:
01225                         /**
01226                         * {@inheritDoc}
01227                         */
01228                         virtual bool isImmutable() const
01229                             {
01230                             return true;
01231                             }
01232                     };
01233 
01234             // ----- constructors -----------------------------------
01235 
01236             protected:
01237                 /**
01238                 * Create a new TypedMap over the given Map.
01239                 *
01240                 * @param ohMapDelegate  the Map to delegate to
01241                 */
01242                 TypedMap(Map::Holder ohMapDelegate)
01243                     : super(ohMapDelegate),
01244                       m_vConverter(Object::self(), EntryConverter::create())
01245                     {
01246                     }
01247 
01248                 /**
01249                 * Copy constructor.
01250                 */
01251                 TypedMap(const TypedMap& that)
01252                     : super(that),
01253                       m_vConverter(Object::self(), EntryConverter::create())
01254                     {
01255                     }
01256 
01257 
01258             // ----- TypedMap interface -----------------------------
01259 
01260             public:
01261                 /**
01262                 * {@inheritDoc}
01263                 */
01264                 using super::containsKey;
01265 
01266                 /**
01267                 * The typed version of the method Map::containsKey.
01268                 *
01269                 * Return <tt>true</tt> if this map contains a mapping for the
01270                 * specified key.
01271                 *
01272                 * @param vKey key whose presence in this map is to be tested.
01273                 *
01274                 * @return <tt>true</tt> if this map contains a mapping for
01275                 *         the specified key.
01276                 */
01277                 virtual bool containsKey(KeyType vKey) const
01278                     {
01279                     return super::containsKey(vKey);
01280                     }
01281 
01282                 /**
01283                 * {@inheritDoc}
01284                 */
01285                 using super::containsValue;
01286 
01287                 /**
01288                 * The typed version of the method Map::containsValue.
01289                 *
01290                 * Return <tt>true</tt> if this map maps one or more keys to
01291                 * the specified value.
01292                 *
01293                 * @param ohValue value whose presence in this map is to be
01294                 *               tested.
01295                 *
01296                 * @return <tt>true</tt> if this map maps one or more keys to
01297                 *          the specified value.
01298                 */
01299                 virtual bool containsValue(ValueType ohValue) const
01300                     {
01301                     return super::containsValue(ohValue);
01302                     }
01303 
01304                 /**
01305                 * {@inheritDoc}
01306                 */
01307                 using super::get;
01308 
01309                 /**
01310                 * The typed version of the method Map::get.
01311                 *
01312                 * Return the value to which this map maps the specified key,
01313                 * if any.
01314                 *
01315                 * @param vKey key whose associated value is to be returned.
01316                 *
01317                 * @return the value to which this map maps the specified key,
01318                 *          or <tt>NULL</tt> if the map contains no mapping
01319                 *          for this key.
01320                 *
01321                 * @throws ClassCastException
01322                 *         if the typed map is broken by external usage
01323                 */
01324                 virtual ValueType get(KeyType vKey) const
01325                     {
01326                     return cast<ValueType>(super::get(vKey));
01327                     }
01328 
01329                 /**
01330                 * The typed version of the method Map::get.
01331                 *
01332                 * Return the value to which this map maps the specified key,
01333                 * if any.
01334                 *
01335                 * @param vKey key whose associated value is to be returned.
01336                 *
01337                 * @return the value to which this map maps the specified key,
01338                 *          or <tt>NULL</tt> if the map contains no mapping
01339                 *          for this key.
01340                 *
01341                 * @throws ClassCastException
01342                 *         if the typed map is broken by external usage
01343                 */
01344                 virtual ValueType get(KeyType vKey)
01345                     {
01346                     return cast<ValueType>(super::get(vKey));
01347                     }
01348 
01349                 /**
01350                 * {@inheritDoc}
01351                 */
01352                 using super::put;
01353 
01354                 /**
01355                 * The typed version of the method Map::put.
01356                 *
01357                 * Associate the specified value with the specified key in
01358                 * this map.
01359                 *
01360                 * @param vKey   key with which the specified value is to be
01361                 *               associated.
01362                 * @param ohValue value to be associated with the specified
01363                 *               key.
01364                 *
01365                 * @return previous value associated with specified key, or
01366                 *         <tt>NULL</tt> if there was no mapping for key.  A
01367                 *         <tt>NULL</tt> return can also indicate that the map
01368                 *         previously associated <tt>NULL</tt> with the
01369                 *         specified key.
01370                 *
01371                 * @throws coherence::lang::UnsupportedOperationException
01372                 *         if the #put() operation is not supported by this map
01373                 * @throws ClassCastException
01374                 *         if the typed map is broken by external usage
01375                 */
01376                 virtual ValueType put(KeyType vKey, ValueType ohValue)
01377                     {
01378                     return cast<ValueType>(super::put(vKey, ohValue));
01379                     }
01380 
01381                 /**
01382                 * {@inheritDoc}
01383                 */
01384                 using super::remove;
01385 
01386                 /**
01387                 * The typed version of the method Map::put.
01388                 *
01389                 * Remove the mapping for this key from this map if it
01390                 * is present.
01391                 *
01392                 * @param vKey key whose mapping is to be removed from
01393                 *             the map.
01394                 *
01395                 * @return previous value associated with specified key, or
01396                 *         <tt>NULL</tt> if there was no mapping for key.
01397                 *
01398                 * @throws coherence::lang::UnsupportedOperationException
01399                 *         if the #remove() operation is not supported by this
01400                 *         map
01401                 * @throws ClassCastException
01402                 *         if the typed map is broken by external usage
01403                 */
01404                 virtual ValueType remove(KeyType vKey)
01405                     {
01406                     return cast<ValueType>(super::remove(vKey));
01407                     }
01408 
01409                 /**
01410                 * {@inheritDoc}
01411                 */
01412                 using super::putAll;
01413 
01414                 /**
01415                 * The typed version of the method Map::putAll.
01416                 *
01417                 * Copy all of the mappings from the specified typed map
01418                 * to this map.
01419                 *
01420                 * @param vMap mappings to be stored in this map.
01421                 *
01422                 * @throws coherence::lang::UnsupportedOperationException
01423                 *         if the #put() operation is not supported by this
01424                 *         map
01425                 */
01426                 virtual void putAll(typename TypedMap::View vMap)
01427                     {
01428                     super::putAll(vMap);
01429                     }
01430 
01431                 /**
01432                 * The typed version of the method Map::keySet.
01433                 *
01434                 * Return a typed set view of the keys contained in this map.
01435                 *
01436                 * @return a typed set view of the keys contained in this map.
01437                 */
01438                 virtual typename KeySet::View keySetTyped() const
01439                     {
01440                     return KeySet::create(super::keySet());
01441                     }
01442 
01443                 /**
01444                 * The typed version of the method Map::keySet.
01445                 *
01446                 * Return a typed set view of the keys contained in this map.
01447                 *
01448                 * @return a typed set view of the keys contained in this map.
01449                 */
01450                 virtual typename KeySet::Handle keySetTyped()
01451                     {
01452                     return KeySet::create(super::keySet());
01453                     }
01454 
01455                 /**
01456                 * {@inheritDoc}
01457                 */
01458                 virtual Set::View keySet() const
01459                     {
01460                     return keySetTyped();
01461                     }
01462 
01463                 /**
01464                 * {@inheritDoc}
01465                 */
01466                 virtual Set::Handle keySet()
01467                     {
01468                     return keySetTyped();
01469                     }
01470 
01471                 /**
01472                 * The typed version of the method Map::values.
01473                 *
01474                 * Return a typed collection view of the values contained in
01475                 * this map.
01476                 *
01477                 * @return a typed collection view of the values contained in
01478                 *         this map.
01479                 */
01480                 virtual typename ValueCollection::View valuesTyped() const
01481                     {
01482                     return ValueCollection::create(super::values());
01483                     }
01484 
01485                 /**
01486                 * The typed version of the method Map::values.
01487                 *
01488                 * Return a typed collection view of the values contained in
01489                 * this map.
01490                 *
01491                 * @return a typed collection view of the values contained in
01492                 *         this map.
01493                 */
01494                 virtual typename ValueCollection::Handle valuesTyped()
01495                     {
01496                     return ValueCollection::create(super::values());
01497                     }
01498 
01499                 /**
01500                 * {@inheritDoc}
01501                 */
01502                 virtual Collection::View values() const
01503                     {
01504                     return valuesTyped();
01505                     }
01506 
01507                 /**
01508                 * {@inheritDoc}
01509                 */
01510                 virtual Collection::Handle values()
01511                     {
01512                     return valuesTyped();
01513                     }
01514 
01515                 /**
01516                 * The typed version of the method Map::entrySet.
01517                 *
01518                 * Return a typed set view of the mappings contained in
01519                 * this map.
01520                 *
01521                 * @return a typed set view of the mappings contained in
01522                 *         this map.
01523                 */
01524                 virtual typename EntrySet::View entrySetTyped() const
01525                     {
01526                     return EntrySet::create(cast<Set::View>(
01527                         ConverterCollections::ConverterSet::create(
01528                             super::entrySet(), m_vConverter,
01529                             (Converter::View) NULL)));
01530                     }
01531 
01532                 /**
01533                 * The typed version of the method Map::entrySet.
01534                 *
01535                 * Return a typed set view of the mappings contained in
01536                 * this map.
01537                 *
01538                 * @return a typed set view of the mappings contained in
01539                 *         this map.
01540                 */
01541                 virtual typename EntrySet::Handle entrySetTyped()
01542                     {
01543                     return EntrySet::create(cast<Set::Handle>(
01544                         ConverterCollections::ConverterSet::create(
01545                             super::entrySet(), m_vConverter,
01546                             (Converter::View) NULL)));
01547                     }
01548 
01549                 /**
01550                 * {@inheritDoc}
01551                 */
01552                 virtual Set::View entrySet() const
01553                     {
01554                     return entrySetTyped();
01555                     }
01556 
01557                 /**
01558                 * {@inheritDoc}
01559                 */
01560                 virtual Set::Handle entrySet()
01561                     {
01562                     return entrySetTyped();
01563                     }
01564 
01565 
01566             // ----- data members ---------------------------------------
01567 
01568             protected:
01569                 /**
01570                 * The converter used to convert untyped entries to typed ones
01571                 */
01572                 FinalView<EntryConverter> m_vConverter;
01573             };
01574 
01575 
01576         // ----- inner class: TypedList -------------------------------------
01577 
01578         /**
01579         * Typed wrapper over List interface.
01580         */
01581         template<class T>
01582         class TypedList
01583             : public cloneable_spec<TypedList<T>,
01584                 extends<WrapperCollections::AbstractWrapperList> >
01585             {
01586             friend class factory<TypedList<T> >;
01587             typedef typename TypedList::super super;
01588 
01589             // ----- typedefs -------------------------------------------
01590 
01591             public:
01592                 /**
01593                 * The type of the objects stored in this list,
01594                 * e.g. String::View.
01595                 */
01596                 typedef T ValueType;
01597 
01598                 /**
01599                 * The type of the iterator over this list.
01600                 */
01601                 typedef TypedIterator<ValueType> Iterator;
01602 
01603                 /**
01604                 * The type of the list iterator over this list.
01605                 */
01606                 typedef TypedListIterator<ValueType> ListIterator;
01607 
01608 
01609             // ----- constructors ---------------------------------------
01610 
01611             protected:
01612                 /**
01613                 * Create a new TypedList over the given List.
01614                 *
01615                 * @param ohListDelegate  the list to delegate to
01616                 */
01617                 TypedList(List::Holder ohListDelegate)
01618                     : super(ohListDelegate)
01619                     {
01620                     }
01621 
01622                 /**
01623                 * Copy constructor.
01624                 */
01625                 TypedList(const TypedList& that)
01626                     : super(that)
01627                     {
01628                     }
01629 
01630 
01631             // ----- TypedList interface --------------------------------
01632 
01633             public:
01634                 /**
01635                 * The typed version of the method List::get.
01636                 * <p>
01637                 * Return the element from the specified position in the list.
01638                 *
01639                 * @param i  the position of the item to return
01640                 *
01641                 * @return the element from the specified position in the list
01642                 *
01643                 * @throws coherence::lang::IndexOutOfBoundsException if the
01644                 *         index is out of range
01645                 *
01646                 * @throws ClassCastException
01647                 *         if the typed map is broken by external usage
01648                 */
01649                 virtual ValueType getTyped(size32_t i) const
01650                     {
01651                     return cast<ValueType>(super::get(i));
01652                     }
01653 
01654                 /**
01655                 * {@inheritDoc}
01656                 */
01657                 using super::contains;
01658 
01659                 /**
01660                 * The typed version of the method Collection::contains.
01661                 * Return true if this list contains the specified element.
01662                 *
01663                 * @param v element whose presence in this list is to be
01664                 *          tested
01665                 *
01666                 * @return true if this collection contains the specified
01667                 *         element
01668                 */
01669                 virtual bool contains(ValueType v) const
01670                     {
01671                     return super::contains(v);
01672                     }
01673 
01674                 /**
01675                 * The typed version of the method Collection::iterator.
01676                 * Return a handle to an TypedIterator over the elements in
01677                 * this list.
01678                 *
01679                 * @return a TypedIterator over the elements in this list
01680                 */
01681                 virtual typename TypedList::Iterator::Handle
01682                         iteratorTyped() const
01683                     {
01684                     return TypedList::Iterator::create(
01685                             Iterator::create(super::iterator()));
01686                     }
01687 
01688                 /**
01689                 * {@inheritDoc}
01690                 */
01691                 virtual coherence::util::Iterator::Handle iterator() const
01692                     {
01693                     return iteratorTyped();
01694                     }
01695 
01696                 /**
01697                 * {@inheritDoc}
01698                 */
01699                 virtual coherence::util::Muterator::Handle iterator()
01700                     {
01701                     return iteratorTyped();
01702                     }
01703 
01704                 /**
01705                 * The typed version of the method List::listIterator.
01706                 * <p>
01707                 * Return a handle to an TypedListIterator over the elements
01708                 * in this list.
01709                 *
01710                 * @return a TypedListIterator over the elements in this list
01711                 */
01712                 virtual typename TypedList::ListIterator::Handle
01713                         listIteratorTyped() const
01714                     {
01715                     return TypedList::ListIterator::create(
01716                             super::listIterator());
01717                     }
01718 
01719                 /**
01720                 * The typed version of the method List::listIterator.
01721                 * <p>
01722                 * Return a handle to an TypedListIterator over the elements
01723                 * in this list.
01724                 *
01725                 * @return a TypedListIterator over the elements in this list
01726                 */
01727                 virtual typename TypedList::ListIterator::Handle
01728                         listIteratorTyped()
01729                     {
01730                     return TypedList::ListIterator::create(
01731                         super::listIterator());
01732                     }
01733 
01734                 /**
01735                 * {@inheritDoc}
01736                 */
01737                 virtual coherence::util::ListIterator::Handle listIterator() const
01738                     {
01739                     return listIteratorTyped();
01740                     }
01741 
01742                 /**
01743                 * {@inheritDoc}
01744                 */
01745                 virtual coherence::util::ListMuterator::Handle listIterator()
01746                     {
01747                     return listIteratorTyped();
01748                     }
01749 
01750                 /**
01751                 * The typed version of the method Collection::iterator.
01752                 * <p> Return a handle to an TypedList Iterator over the
01753                 * elements in this list starting at the position specified.
01754                 *
01755                 * @param i  the position in the list that the iterator will
01756                 *           start at
01757                 *
01758                 * @return a TypedListIterator over the elements in this list
01759                 *         starting at the specified position in the list
01760                 */
01761                 virtual typename TypedList::ListIterator::Handle
01762                         listIteratorTyped(size32_t i) const
01763                     {
01764                     return TypedList::ListIterator::create(
01765                         super::listIterator(i));
01766                     }
01767 
01768                 /**
01769                 * The typed version of the method Collection::iterator.
01770                 * <p> Return a handle to an TypedList Iterator over the
01771                 * elements in this list starting at the position specified.
01772                 *
01773                 * @param i  the position in the list that the iterator will
01774                 *           start at
01775                 *
01776                 * @return a TypedListIterator over the elements in this list
01777                 *         starting at the specified position in the list
01778                 */
01779                 virtual typename TypedList::ListIterator::Handle
01780                         listIteratorTyped(size32_t i)
01781                     {
01782                     return TypedList::ListIterator::create(
01783                         super::listIterator(i));
01784                     }
01785 
01786                 /**
01787                 * {@inheritDoc}
01788                 */
01789                 virtual coherence::util::ListIterator::Handle
01790                         listIterator(size32_t i) const
01791                     {
01792                     return listIteratorTyped(i);
01793                     }
01794 
01795                 /**
01796                 * {@inheritDoc}
01797                 */
01798                 virtual coherence::util::ListMuterator::Handle
01799                         listIterator(size32_t i)
01800                     {
01801                     return listIteratorTyped(i);
01802                     }
01803 
01804                 /**
01805                 * {@inheritDoc}
01806                 */
01807                 using super::add;
01808 
01809                 /**
01810                 * The typed version of the method List::add. Add the
01811                 * specified element to this list if it is not already
01812                 * present.
01813                 *
01814                 * @param v element to be added to this list.
01815                 *
01816                 * @return true if this list changed as a result of the
01817                 *         call
01818                 *
01819                 * @throws coherence::lang::UnsupportedOperationException
01820                 *         if the #add() operation is not supported by this
01821                 *         list
01822                 */
01823                 virtual bool add(ValueType v)
01824                     {
01825                     return super::add(v);
01826                     }
01827 
01828                 /**
01829                 * {@inheritDoc}
01830                 */
01831                 using super::set;
01832 
01833                 /**
01834                 * The typed version of the method List::set.
01835                 * <p>
01836                 * Replace the element at the specified position in this list
01837                 * with the specified element.
01838                 *
01839                 * @param idx  the position in the list to replace
01840                 * @param v    the object to replace at the specified position
01841                 *
01842                 * @return the element at the specified position prior to this
01843                 *         operation
01844                 *
01845                 * @throw coherence::lang::IndexOutOfBoundsException if the
01846                 *        index is out of range
01847                 */
01848                 virtual ValueType set(size32_t idx, ValueType v)
01849                     {
01850                     return cast<ValueType>(super::set(idx, v));
01851                     }
01852 
01853                 /**
01854                 * {@inheritDoc}
01855                 */
01856                 using super::remove;
01857 
01858                 /**
01859                 * The typed version of the method Collection::remove. Remove
01860                 * the specified element from this list, if it is present.
01861                 *
01862                 * @param v element to be removed from this list, if present
01863                 *
01864                 * @return true if this list changed as a result of
01865                 *         the call
01866                 *
01867                 * @throws coherence::lang::UnsupportedOperationException
01868                 *         if the #remove() operation is not supported by this
01869                 *         list
01870                 */
01871                 virtual bool remove(ValueType v)
01872                     {
01873                     return super::remove(v);
01874                     }
01875 
01876                 /**
01877                 * The typed version of the method Collection::remove.
01878                 * <p> Remove the element at the specified position in the
01879                 * list.
01880                 *
01881                 * @param idx  the index from which to remove an element
01882                 *
01883                 * @return the element at the specified position prior to this
01884                 *         operation
01885                 *
01886                 * @throw coherence::lang::IndexOutOfBoundsException if the
01887                 *        index is out of range
01888                 */
01889                 virtual ValueType removeTyped(size32_t idx)
01890                     {
01891                     return cast<ValueType>(super::remove(idx));
01892                     }
01893 
01894                 /**
01895                 * {@inheritDoc}
01896                 */
01897                 using super::addAll;
01898 
01899                 /**
01900                 * The typed version of the method Collection::addAll.
01901                 *
01902                 * Add all of the elements in the specified TypedCollection to
01903                 * this list.
01904                 *
01905                 * @param vtc TypedCollection of elements to be inserted into
01906                 *            this list
01907                 *
01908                 * @return true if this list changed as a result of the call
01909                 *
01910                 * @throws coherence::lang::NullPointerException
01911                 *         if the specified collection is NULL
01912                 * @throws coherence::lang::UnsupportedOperationException
01913                 *         if the #add() operation is not supported by this
01914                 *         list
01915                 */
01916                 virtual bool addAll(typename
01917                                 TypedCollection<ValueType>::View vtc)
01918                     {
01919                     return super::addAll(vtc);
01920                     }
01921 
01922                 /**
01923                 * The typed version of the method Collection::addAll.
01924                 *
01925                 * Add all of the elements in the specified TypedCollection to
01926                 * this list.
01927                 *
01928                 * @param htc TypedCollection of elements to be inserted into
01929                 *            this list
01930                 *
01931                 * @return true if this list changed as a result of the call
01932                 *
01933                 * @throws coherence::lang::NullPointerException
01934                 *         if the specified collection is NULL
01935                 * @throws coherence::lang::UnsupportedOperationException
01936                 *         if the #add() operation is not supported by this
01937                 *         list
01938                 */
01939                 virtual bool addAll(typename
01940                                 TypedCollection<ValueType>::Handle htc)
01941                     {
01942                     return super::addAll(htc);
01943                     }
01944 
01945                 /**
01946                 * The typed version of the method Collection::addAll.
01947                 *
01948                 * Add all of the elements in the specified TypedList to this
01949                 * list.
01950                 *
01951                 * @param vtl TypedList of elements to be inserted into
01952                 *            this list
01953                 *
01954                 * @return true if this list changed as a result of the call
01955                 *
01956                 * @throws coherence::lang::NullPointerException
01957                 *         if the specified collection is NULL
01958                 * @throws coherence::lang::UnsupportedOperationException
01959                 *         if the #add() operation is not supported by this
01960                 *         list
01961                 */
01962                 virtual bool addAll(
01963                         typename TypedList<ValueType>::View vtl)
01964                     {
01965                     return super::addAll(vtl);
01966                     }
01967 
01968                 /**
01969                 * The typed version of the method Collection::addAll.
01970                 *
01971                 * Add all of the elements in the specified TypedList to this
01972                 * list.
01973                 *
01974                 * @param htl TypedList of elements to be inserted into
01975                 *            this list
01976                 *
01977                 * @return true if this list changed as a result of the call
01978                 *
01979                 * @throws coherence::lang::NullPointerException
01980                 *         if the specified collection is NULL
01981                 * @throws coherence::lang::UnsupportedOperationException
01982                 *         if the #add() operation is not supported by this
01983                 *         list
01984                 */
01985                 virtual bool addAll(
01986                         typename TypedList<ValueType>::Handle htl)
01987                     {
01988                     return super::addAll(htl);
01989                     }
01990 
01991                 /**
01992                 * {@inheritDoc}
01993                 */
01994                 using super::removeAll;
01995 
01996                 /**
01997                 * The typed version of the method Collection::removeAll.
01998                 *
01999                 * Remove all this list's elements that are also contained in
02000                 * the specified typed collection.
02001                 *
02002                 * @param vtc elements to be removed from this list
02003                 *
02004                 * @return true if this list changed as a result of
02005                 *         the call
02006                 *
02007                 * @throws coherence::lang::NullPointerException
02008                 *         if the specified collection is NULL
02009                 * @throws coherence::lang::UnsupportedOperationException
02010                 *         if the #remove() operation is not supported by this
02011                 *         list
02012                 */
02013                 virtual bool removeAll(typename
02014                                 TypedCollection<ValueType>::View vtc)
02015                     {
02016                     return super::removeAll(vtc);
02017                     }
02018 
02019                 /**
02020                 * The typed version of the method Collection::removeAll.
02021                 *
02022                 * Remove all this list's elements that are also contained in
02023                 * the specified typed collection.
02024                 *
02025                 * @param htc elements to be removed from this list
02026                 *
02027                 * @return true if this list changed as a result of
02028                 *         the call
02029                 *
02030                 * @throws coherence::lang::NullPointerException
02031                 *         if the specified collection is NULL
02032                 * @throws coherence::lang::UnsupportedOperationException
02033                 *         if the #remove() operation is not supported by this
02034                 *         list
02035                 */
02036                 virtual bool removeAll(typename
02037                                 TypedCollection<ValueType>::Handle htc)
02038                     {
02039                     return super::removeAll(htc);
02040                     }
02041 
02042                 /**
02043                 * The typed version of the method Collection::removeAll.
02044                 *
02045                 * Remove all this list's elements that are also contained in
02046                 * the specified typed list.
02047                 *
02048                 * @param vtl elements to be removed from this list
02049                 *
02050                 * @return true if this list changed as a result of
02051                 *         the call
02052                 *
02053                 * @throws coherence::lang::NullPointerException
02054                 *         if the specified collection is NULL
02055                 * @throws coherence::lang::UnsupportedOperationException
02056                 *         if the #remove() operation is not supported by this
02057                 *         list
02058                 */
02059                 virtual bool removeAll(typename
02060                                 TypedList<ValueType>::View vtl)
02061                     {
02062                     return super::removeAll(vtl);
02063                     }
02064 
02065                 /**
02066                 * The typed version of the method Collection::removeAll.
02067                 *
02068                 * Remove all this list's elements that are also contained in
02069                 * the specified typed list.
02070                 *
02071                 * @param htl elements to be removed from this list
02072                 *
02073                 * @return true if this list changed as a result of
02074                 *         the call
02075                 *
02076                 * @throws coherence::lang::NullPointerException
02077                 *         if the specified collection is NULL
02078                 * @throws coherence::lang::UnsupportedOperationException
02079                 *         if the #remove() operation is not supported by this
02080                 *         list
02081                 */
02082                 virtual bool removeAll(typename
02083                                 TypedList<ValueType>::Handle htl)
02084                     {
02085                     return super::removeAll(htl);
02086                     }
02087 
02088                 /**
02089                 * {@inheritDoc}
02090                 */
02091                 using super::retainAll;
02092 
02093                 /**
02094                 * The typed version of the method Collection::retainAll.
02095                 *
02096                 * Retain only the elements in this list that are
02097                 * contained in the specified typed collection.
02098                 *
02099                 * @param vtc elements to be retained in this list
02100                 *
02101                 * @return true if this list changed as a result of
02102                 *         the call
02103                 *
02104                 * @throws coherence::lang::NullPointerException
02105                 *         if the specified collection is NULL
02106                 * @throws coherence::lang::UnsupportedOperationException
02107                 *         if the #remove() operation is not supported by this
02108                 *         list
02109                 */
02110                 virtual bool retainAll(typename
02111                                 TypedCollection<ValueType>::View vtc)
02112                     {
02113                     return super::retainAll(vtc);
02114                     }
02115 
02116                 /**
02117                 * The typed version of the method Collection::retainAll.
02118                 *
02119                 * Retain only the elements in this list that are
02120                 * contained in the specified typed collection.
02121                 *
02122                 * @param htc elements to be retained in this list
02123                 *
02124                 * @return true if this list changed as a result of
02125                 *         the call
02126                 *
02127                 * @throws coherence::lang::NullPointerException
02128                 *         if the specified collection is NULL
02129                 * @throws coherence::lang::UnsupportedOperationException
02130                 *         if the #remove() operation is not supported by this
02131                 *         list
02132                 */
02133                 virtual bool retainAll(typename
02134                                 TypedCollection<ValueType>::Handle htc)
02135                     {
02136                     return super::retainAll(htc);
02137                     }
02138 
02139                 /**
02140                 * The typed version of the method Collection::retainAll.
02141                 *
02142                 * Retain only the elements in this list that are
02143                 * contained in the specified typed list.
02144                 *
02145                 * @param vtl elements to be retained in this list
02146                 *
02147                 * @return true if this list changed as a result of
02148                 *         the call
02149                 *
02150                 * @throws coherence::lang::NullPointerException
02151                 *         if the specified collection is NULL
02152                 * @throws coherence::lang::UnsupportedOperationException
02153                 *         if the #remove() operation is not supported by this
02154                 *         list
02155                 */
02156                 virtual bool retainAll(typename
02157                                 TypedList<ValueType>::View vtl)
02158                     {
02159                     return super::retainAll(vtl);
02160                     }
02161 
02162                 /**
02163                 * The typed version of the method Collection::retainAll.
02164                 *
02165                 * Retain only the elements in this list that are
02166                 * contained in the specified typed list.
02167                 *
02168                 * @param htl elements to be retained in this list
02169                 *
02170                 * @return true if this list changed as a result of
02171                 *         the call
02172                 *
02173                 * @throws coherence::lang::NullPointerException
02174                 *         if the specified collection is NULL
02175                 * @throws coherence::lang::UnsupportedOperationException
02176                 *         if the #remove() operation is not supported by this
02177                 *         list
02178                 */
02179                 virtual bool retainAll(typename
02180                                 TypedList<ValueType>::Handle htl)
02181                     {
02182                     return super::retainAll(htl);
02183                     }
02184 
02185                 /**
02186                 * Convert a TypedList to a TypedCollection, wrapping the same
02187                 * underlying Collection::Handle.
02188                 *
02189                 * @return a handle to the new TypedCollection
02190                 */
02191                 virtual typename TypedCollection<ValueType>::Handle
02192                         asTypedCollection()
02193                     {
02194                     return TypedCollection<ValueType>::create(
02195                         cast<Collection::Handle>(super::getDelegate()));
02196                     }
02197 
02198                 /**
02199                 * Convert a TypedList to a TypedCollection, wrapping the same
02200                 * underlying Collection::View.
02201                 *
02202                 * @return a view to the new TypedCollection
02203                 */
02204                 virtual typename TypedCollection<ValueType>::View
02205                         asTypedCollection() const
02206                     {
02207                     return TypedCollection<ValueType>::create(
02208                         cast<Collection::View>(super::getDelegate()));
02209                     }
02210 
02211                 /**
02212                 * The typed version of the method Collection::subList.
02213                 * <p> Return a new typed list containing the contents of the
02214                 * list between the specified fromIndex (inclusive) and
02215                 * toIndex (exclusive).
02216                 *
02217                 * @param fromIndex  the start position in this list to create
02218                 *                   the sublist from (inclusive).
02219                 * @param toIndex    the end position in this list to end the
02220                 *                   sublist at (exclusive).
02221                 *
02222                 * @return the new typed sublist of this typed list
02223                 */
02224                 virtual typename TypedList::Handle subListTyped(
02225                         size32_t fromIndex, size32_t toIndex)
02226                     {
02227                     return create(super::subList(fromIndex, toIndex));
02228                     }
02229 
02230                 /**
02231                 * The typed version of the method Collection::subList.
02232                 * <p> Return a new typed list containing the contents of the
02233                 * list between the specified fromIndex (inclusive) and
02234                 * toIndex (exclusive).
02235                 *
02236                 * @param fromIndex  the start position in this list to create
02237                 *                   the sublist from (inclusive).
02238                 * @param toIndex    the end position in this list to end the
02239                 *                   sublist at (exclusive).
02240                 *
02241                 * @return the new typed sublist of this typed list
02242                 */
02243                 virtual typename TypedList::Handle subListTyped(
02244                         size32_t fromIndex, size32_t toIndex) const
02245                     {
02246                     return create(super::subList(fromIndex, toIndex));
02247                     }
02248             };
02249     };
02250 
02251 COH_CLOSE_NAMESPACE2
02252 
02253 #endif // COH_TYPED_COLLECTIONS_HPP
Copyright (c) 2000, 2009, Oracle and/or its affiliates. All rights reserved.