coherence/util/NullImplementation.hpp

00001 /*
00002 * NullImplementation.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_NULL_IMPLEMENTATION_HPP
00017 #define COH_NULL_IMPLEMENTATION_HPP
00018 
00019 #include "coherence/lang.ns"
00020 
00021 #include "coherence/io/pof/PofReader.hpp"
00022 #include "coherence/io/pof/PofWriter.hpp"
00023 #include "coherence/io/pof/PortableObject.hpp"
00024 #include "coherence/util/AbstractSet.hpp"
00025 #include "coherence/util/Filter.hpp"
00026 #include "coherence/util/MapListener.hpp"
00027 #include "coherence/util/ObservableMap.hpp"
00028 #include "coherence/util/ValueExtractor.hpp"
00029 
00030 COH_OPEN_NAMESPACE2(coherence,util)
00031 
00032 using coherence::io::pof::PofReader;
00033 using coherence::io::pof::PofWriter;
00034 using coherence::io::pof::PortableObject;
00035 using coherence::util::AbstractSet;
00036 using coherence::util::MapListener;
00037 using coherence::util::ObservableMap;
00038 using coherence::util::ValueExtractor;
00039 
00040 /**
00041 * A collection of classes that do nothing.
00042 * For each class implemented, a factory method will exist following the
00043 * naming convention "get" plus the class or interface name.
00044 *
00045 * @author gm  2008.07.28
00046 */
00047 class COH_EXPORT NullImplementation
00048     {
00049     // ----- NullImplementation interface -----------------------------------
00050 
00051     public:
00052         /**
00053         * Returns an instance of the empty ObjectArray.
00054         */
00055         static ObjectArray::Handle getArray();
00056 
00057         /**
00058         * Returns an instance of the NullIterator.
00059         */
00060         static Iterator::Handle getIterator();
00061 
00062         /**
00063         * Returns an instance of the NullMuterator.
00064         */
00065         static Muterator::Handle getMuterator();
00066 
00067         /**
00068         * Returns an instance of the NullSet.
00069         */
00070         static Set::Handle getSet();
00071 
00072         /**
00073         * Returns an instance of the NullCollection.
00074         */
00075         static Collection::Handle getCollection();
00076 
00077         /**
00078         * Returns an instance of the NullMap.
00079         */
00080         static Map::Handle getMap();
00081 
00082         /**
00083         * Returns an instance of the NullObservableMap.
00084         */
00085         static ObservableMap::Handle getObservableMap();
00086 
00087         /**
00088         * Returns an instance of the NullValueExtractor.
00089         */
00090         static ValueExtractor::Handle getValueExtractor();
00091 
00092     // ----- Inner class: NullMuterator -------------------------------------
00093 
00094     public:
00095         class COH_EXPORT NullMuterator
00096             : public class_spec<NullMuterator,
00097                      extends<Object>,
00098                      implements<Muterator> >
00099             {
00100             friend class factory<NullImplementation::NullMuterator>;
00101 
00102             // ----- constructors ---------------------------------------
00103 
00104             protected:
00105                 /**
00106                 * Default constructor.
00107                 */
00108                 NullMuterator();
00109 
00110 
00111             // ----- Iterator interface ---------------------------------
00112 
00113             public:
00114                 /**
00115                 * {@inheritDoc}
00116                 */
00117                 virtual bool hasNext() const;
00118 
00119                 /**
00120                 * {@inheritDoc}
00121                 */
00122                 virtual Object::Holder next();
00123 
00124                 /**
00125                 * {@inheritDoc}
00126                 */
00127                 virtual void remove();
00128 
00129             public:
00130                 static Handle getInstance();
00131             };
00132 
00133 
00134     // ----- Inner class: NullSet -------------------------------------------
00135     public:
00136         class COH_EXPORT NullSet
00137             : public cloneable_spec<NullSet,
00138                      extends<AbstractSet>,
00139                      implements<PortableObject> >
00140             {
00141             friend class factory<NullImplementation::NullSet>;
00142 
00143             // ----- constructors ---------------------------------------
00144 
00145             protected:
00146                 /**
00147                 * Default constructor (for PortableObject).
00148                 */
00149                 NullSet();
00150 
00151                 /**
00152                 * Copy constructor.
00153                 */
00154                 NullSet(const NullSet& that);
00155 
00156 
00157             // ----- Set interface --------------------------------------
00158 
00159             public:
00160 
00161                 /**
00162                 * {@inheritDoc}
00163                 */
00164                 virtual bool contains(Object::View v) const;
00165 
00166                 /**
00167                 * {@inheritDoc}
00168                 */
00169                 virtual Iterator::Handle iterator() const;
00170 
00171                 /**
00172                 * {@inheritDoc}
00173                 */
00174                 virtual Muterator::Handle iterator();
00175 
00176                 /**
00177                 * {@inheritDoc}
00178                 */
00179                 virtual ObjectArray::Handle toArray(
00180                         ObjectArray::Handle hao = NULL) const;
00181 
00182                 /**
00183                 * {@inheritDoc}
00184                 */
00185                 virtual bool add(Object::Holder oh);
00186 
00187                 /**
00188                 * {@inheritDoc}
00189                 */
00190                 virtual bool remove(Object::View v);
00191 
00192                 /**
00193                 * {@inheritDoc}
00194                 */
00195                 virtual bool containsAll(Collection::View vc) const;
00196 
00197                 /**
00198                 * {@inheritDoc}
00199                 */
00200                 virtual bool addAll(Collection::View vc);
00201 
00202                 /**
00203                 * {@inheritDoc}
00204                 */
00205                 virtual bool removeAll(Collection::View vc);
00206 
00207                 /**
00208                 * {@inheritDoc}
00209                 */
00210                 virtual bool retainAll(Collection::View vc);
00211 
00212                 /**
00213                 * {@inheritDoc}
00214                 */
00215                 virtual size32_t size() const;
00216 
00217                 /**
00218                 * {@inheritDoc}
00219                 */
00220                 virtual bool isEmpty() const;
00221 
00222                 /**
00223                 * {@inheritDoc}
00224                 */
00225                 virtual void clear();
00226 
00227 
00228             // ----- PortableObject interface ---------------------------
00229 
00230             public:
00231                 /**
00232                 * {@inheritDoc}
00233                 */
00234                 virtual void readExternal(PofReader::Handle hIn);
00235 
00236                 /**
00237                 * {@inheritDoc}
00238                 */
00239                 virtual void writeExternal(PofWriter::Handle hOut) const;
00240 
00241 
00242             // ----- Object interface -----------------------------------
00243 
00244             public:
00245                 /**
00246                 * {@inheritDoc}
00247                 */
00248           virtual bool equals(Object::View v) const;
00249 
00250             public:
00251                 static Handle getInstance();
00252             };
00253 
00254     // ----- Inner class: NullCollection ------------------------------------
00255     public:
00256         class COH_EXPORT NullCollection
00257             : public cloneable_spec<NullCollection,
00258                      extends<Object>,
00259                      implements<Collection, PortableObject> >
00260             {
00261             friend class factory<NullImplementation::NullCollection>;
00262 
00263             // ----- constructors ---------------------------------------
00264 
00265             protected:
00266                 /**
00267                 * Default constructor (for PortableObject).
00268                 */
00269                 NullCollection();
00270 
00271                 /**
00272                 * Copy constructor.
00273                 */
00274                 NullCollection(const NullCollection& that);
00275 
00276 
00277             // ----- Collection interface -------------------------------
00278 
00279             public:
00280                 /**
00281                 * {@inheritDoc}
00282                 */
00283                 virtual bool contains(Object::View v) const;
00284 
00285                 /**
00286                 * {@inheritDoc}
00287                 */
00288                 virtual Iterator::Handle iterator() const;
00289 
00290                 /**
00291                 * {@inheritDoc}
00292                 */
00293                 virtual Muterator::Handle iterator();
00294 
00295                 /**
00296                 * {@inheritDoc}
00297                 */
00298                 virtual ObjectArray::Handle toArray(
00299                         ObjectArray::Handle hoa = NULL) const;
00300 
00301                 /**
00302                 * {@inheritDoc}
00303                 */
00304                 virtual bool add(Object::Holder oh);
00305 
00306                 /**
00307                 * {@inheritDoc}
00308                 */
00309                 virtual bool remove(Object::View v);
00310 
00311                 /**
00312                 * {@inheritDoc}
00313                 */
00314                 virtual bool containsAll(Collection::View vc) const;
00315 
00316                 /**
00317                 * {@inheritDoc}
00318                 */
00319                 virtual bool addAll(Collection::View vc);
00320 
00321                 /**
00322                 * {@inheritDoc}
00323                 */
00324                 virtual bool removeAll(Collection::View vc);
00325 
00326                 /**
00327                 * {@inheritDoc}
00328                 */
00329                 virtual bool retainAll(Collection::View vc);
00330 
00331                 /**
00332                 * {@inheritDoc}
00333                 */
00334                 virtual size32_t size() const;
00335 
00336                 /**
00337                 * {@inheritDoc}
00338                 */
00339                 virtual bool isEmpty() const;
00340 
00341                 /**
00342                 * {@inheritDoc}
00343                 */
00344                 virtual void clear();
00345 
00346 
00347             // ----- PortableObject interface ---------------------------
00348 
00349             public:
00350                 /**
00351                 * {@inheritDoc}
00352                 */
00353                 virtual void readExternal(PofReader::Handle hIn);
00354 
00355                 /**
00356                 * {@inheritDoc}
00357                 */
00358                 virtual void writeExternal(PofWriter::Handle hOut) const;
00359 
00360 
00361             // ----- Object interface -----------------------------------
00362 
00363             public:
00364                 /**
00365                 * {@inheritDoc}
00366                 */
00367           virtual bool equals(Object::View v) const;
00368 
00369             public:
00370                 static Handle getInstance();
00371             };
00372 
00373     // ----- Inner class: NullMap --------------------------------------------
00374 
00375     public:
00376         class COH_EXPORT NullMap
00377             : public cloneable_spec<NullMap,
00378                      extends<Object>,
00379                      implements<Map, PortableObject> >
00380             {
00381             friend class factory<NullImplementation::NullMap>;
00382 
00383             // ----- constructors ---------------------------------------
00384 
00385             protected:
00386                 /**
00387                 * Default constructor (for PortableObject).
00388                 */
00389                 NullMap();
00390 
00391                 /**
00392                 * Copy constructor.
00393                 */
00394                 NullMap(const NullMap& that);
00395 
00396 
00397             // ----- Map interface ---------------------------------------
00398 
00399             public:
00400                 /**
00401                 * {@inheritDoc}
00402                 */
00403                 virtual size32_t size() const;
00404 
00405                 /**
00406                 * {@inheritDoc}
00407                 */
00408                 virtual bool isEmpty() const;
00409 
00410                 /**
00411                 * {@inheritDoc}
00412                 */
00413                 virtual void clear();
00414 
00415                 /**
00416                 * {@inheritDoc}
00417                 */
00418                 virtual bool containsKey(Object::View vKey) const;
00419 
00420                 /**
00421                 * {@inheritDoc}
00422                 */
00423                 virtual bool containsValue(Object::View vValue) const;
00424 
00425                 /**
00426                 * {@inheritDoc}
00427                 */
00428                 virtual Object::Holder get(Object::View vKey) const;
00429 
00430                 /**
00431                 * {@inheritDoc}
00432                 */
00433                 virtual Object::Holder get(Object::View vKey);
00434 
00435                 /**
00436                 * {@inheritDoc}
00437                 */
00438                 virtual Object::Holder put(Object::View vKey,
00439                         Object::Holder ohValue);
00440 
00441                 /**
00442                 * {@inheritDoc}
00443                 */
00444                 virtual Object::Holder remove(Object::View vKey);
00445 
00446                 /**
00447                 * {@inheritDoc}
00448                 */
00449                 virtual void putAll(Map::View vMap);
00450 
00451                 /**
00452                 * {@inheritDoc}
00453                 */
00454                 virtual Set::View keySet() const;
00455 
00456                 /**
00457                 * {@inheritDoc}
00458                 */
00459                 virtual Set::Handle keySet();
00460 
00461                 /**
00462                 * {@inheritDoc}
00463                 */
00464                 virtual Collection::View values() const;
00465 
00466                 /**
00467                 * {@inheritDoc}
00468                 */
00469                 virtual Collection::Handle values();
00470 
00471                 /**
00472                 * {@inheritDoc}
00473                 */
00474                 virtual Set::View entrySet() const;
00475 
00476                 /**
00477                 * {@inheritDoc}
00478                 */
00479                 virtual Set::Handle entrySet();
00480 
00481 
00482             // ----- PortableObject interface ---------------------------
00483 
00484             public:
00485                 /**
00486                 * {@inheritDoc}
00487                 */
00488                 virtual void readExternal(PofReader::Handle hIn);
00489 
00490                 /**
00491                 * {@inheritDoc}
00492                 */
00493                 virtual void writeExternal(PofWriter::Handle hOut) const;
00494 
00495 
00496             // ----- Object interface -----------------------------------
00497 
00498             public:
00499                 /**
00500                 * {@inheritDoc}
00501                 */
00502           virtual bool equals(Object::View v) const;
00503 
00504             public:
00505                 static Handle getInstance();
00506             };
00507 
00508 
00509     // ----- Inner class: NullObservableMap ---------------------------------
00510 
00511     public:
00512         class COH_EXPORT NullObservableMap
00513             : public cloneable_spec<NullObservableMap,
00514                      extends<NullMap>,
00515                      implements<ObservableMap> >
00516             {
00517             friend class factory<NullImplementation::NullObservableMap>;
00518 
00519             // ----- constructors ---------------------------------------
00520 
00521             protected:
00522                 /**
00523                 * Default constructor (for PortableObject).
00524                 */
00525                 NullObservableMap();
00526 
00527                 /**
00528                 * Copy constructor.
00529                 */
00530                 NullObservableMap(const NullObservableMap& that);
00531 
00532 
00533             // ----- ObservableMap interface ----------------------------
00534 
00535             public:
00536                 /**
00537                 * {@inheritDoc}
00538                 */
00539                 virtual void addKeyListener(MapListener::Handle hListener,
00540                         Object::View vKey, bool fLite);
00541 
00542                 /**
00543                 * {@inheritDoc}
00544                 */
00545                 virtual void removeKeyListener(MapListener::Handle hListener,
00546                         Object::View vKey);
00547 
00548                 /**
00549                 * {@inheritDoc}
00550                 */
00551                 virtual void addFilterListener(MapListener::Handle hListener,
00552                         Filter::View vFilter, bool fLite);
00553 
00554                 /**
00555                 * {@inheritDoc}
00556                 */
00557                 virtual void removeFilterListener(MapListener::Handle hListener,
00558                         Filter::View vFilter);
00559 
00560             public:
00561                 static Handle getInstance();
00562             };
00563 
00564 
00565     // ----- Inner class: NullValueExtractor --------------------------------
00566 
00567     public:
00568         class COH_EXPORT NullValueExtractor
00569             : public class_spec<NullValueExtractor,
00570                      extends<Object>,
00571                      implements<ValueExtractor> >
00572             {
00573             friend class factory<NullImplementation::NullValueExtractor>;
00574 
00575             // ----- constructors ---------------------------------------
00576 
00577             protected:
00578                 /**
00579                 * Default constructor (for PortableObject).
00580                 */
00581                 NullValueExtractor();
00582 
00583 
00584             // ----- ValueExtractor interface ---------------------------
00585 
00586             public:
00587                 /**
00588                 * {@inheritDoc}
00589                 */
00590                 virtual Object::Holder extract(Object::Holder ohTarget) const;
00591 
00592 
00593             // ----- Object interface -----------------------------------
00594 
00595             public:
00596                 /**
00597                 * {@inheritDoc}
00598                 */
00599                 virtual bool equals(Object::View v) const;
00600 
00601                 /**
00602                 * {@inheritDoc}
00603                 */
00604                 virtual size32_t hashCode() const;
00605 
00606 
00607             // ----- PortableObject interface ---------------------------
00608 
00609             public:
00610                 /**
00611                 * {@inheritDoc}
00612                 */
00613                 virtual void readExternal(PofReader::Handle hIn);
00614 
00615                 /**
00616                 * {@inheritDoc}
00617                 */
00618                 virtual void writeExternal(PofWriter::Handle hOut) const;
00619 
00620             public:
00621                 static Handle getInstance();
00622             };
00623     };
00624 
00625 COH_CLOSE_NAMESPACE2
00626 
00627 #endif // COH_NULL_IMPLEMENTATION_HPP
Copyright (c) 2000, 2009, Oracle and/or its affiliates. All rights reserved.