00001 /* 00002 * MapValuesCollection.hpp 00003 * 00004 * Copyright (c) 2000, 2014, 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_MAP_VALUES_COLLECTION_HPP 00017 #define COH_MAP_VALUES_COLLECTION_HPP 00018 00019 #include "coherence/lang.ns" 00020 00021 #include "coherence/util/ConverterCollections.hpp" 00022 00023 COH_OPEN_NAMESPACE2(coherence,util) 00024 00025 00026 /** 00027 * A wrapper class that provides the Collection interface for the value 00028 * collection of a map. It's returned by the default implementation of the 00029 * AbstractMap::values() method. MapValuesCollection is based on the 00030 * ConverterCollections functionality which will convert a map's entrySet 00031 * into a KeySet 00032 * 00033 * Note that because this ConverterSet is based on the Map's entrySet, 00034 * all write operations on the set must be converted out to a method on 00035 * the Map, not the keyset. 00036 * 00037 * @author nsa 2008.01.30 00038 */ 00039 class COH_EXPORT MapValuesCollection 00040 : public class_spec<MapValuesCollection, 00041 extends<ConverterCollections::ConverterCollection> > 00042 { 00043 friend class factory<MapValuesCollection>; 00044 00045 // ----- constructors --------------------------------------------------- 00046 00047 protected: 00048 /** 00049 * Create a WrapperCollections#AbstractWrapperCollection which 00050 * delegates to the specified Collection. 00051 * 00052 * @param hMapDelegate the underlying map 00053 */ 00054 MapValuesCollection(Map::Handle hMapDelegate); 00055 00056 /** 00057 * Create a WrapperCollections#AbstractWrapperCollection which 00058 * delegates to the specified Collection. 00059 * 00060 * @param vMapDelegate the underlying map 00061 */ 00062 MapValuesCollection(Map::View vMapDelegate); 00063 00064 00065 // ----- Collection interface ------------------------------------------- 00066 00067 public: 00068 /** 00069 * @{inheritDoc} 00070 */ 00071 virtual bool remove(Object::View v); 00072 00073 /** 00074 * @{inheritDoc} 00075 */ 00076 virtual bool removeAll(Collection::View vc); 00077 00078 /** 00079 * @{inheritDoc} 00080 */ 00081 virtual bool retainAll(Collection::View vc); 00082 00083 /** 00084 * @{inheritDoc} 00085 */ 00086 virtual bool contains(Object::View v) const; 00087 00088 /** 00089 * @{inheritDoc} 00090 */ 00091 virtual bool containsAll(Collection::View vc) const; 00092 00093 00094 // ----- accessors ------------------------------------------------------ 00095 00096 protected: 00097 /** 00098 * Return the delegate Map instance. 00099 * 00100 * @return the delegate Map instance 00101 */ 00102 virtual Map::Handle getMapDelegate(); 00103 00104 /** 00105 * Return the delegate Map instance. 00106 * 00107 * @return the delegate Map instance 00108 */ 00109 virtual Map::View getMapDelegate() const; 00110 00111 00112 // ----- inner class: ValueConverter ------------------------------------ 00113 00114 public: 00115 /** 00116 * Convert a Map::Entry into a Map::Entry::Key 00117 */ 00118 class ValueConverter 00119 : public class_spec<ValueConverter, 00120 extends<Object>, 00121 implements<Converter> > 00122 { 00123 friend class factory<ValueConverter>; 00124 00125 // ----- constructor ---------------------------------------- 00126 00127 protected: 00128 /** 00129 * Create a new ValueConverter 00130 */ 00131 ValueConverter(); 00132 00133 // ----- Converter interface -------------------------------- 00134 00135 public: 00136 /** 00137 * Convert an {@link coherence::lang::Object Object} referenced 00138 * by the supplied holder. 00139 * 00140 * @param oh the holder to the Object to convert 00141 * 00142 * @return the holder to the converted Object 00143 */ 00144 virtual Object::Holder convert(Object::Holder oh) const; 00145 00146 /** 00147 * Return a singleton instance of the ValueConverter. 00148 */ 00149 static ValueConverter::View getInstance(); 00150 }; 00151 00152 00153 // ----- data members --------------------------------------------------- 00154 00155 protected: 00156 /** 00157 * The Map to which this KeySet is tied 00158 */ 00159 FinalHolder<Map> f_thMapDelegate; 00160 }; 00161 00162 COH_CLOSE_NAMESPACE2 00163 00164 #endif // COH_MAP_VALUES_COLLECTION_HPP