00001 /* 00002 * ContainsAllFilter.hpp 00003 * 00004 * Copyright (c) 2000, 2010, 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_CONTAINS_ALL_FILTER_HPP 00017 #define COH_CONTAINS_ALL_FILTER_HPP 00018 00019 #include "coherence/lang.ns" 00020 00021 #include "coherence/util/Set.hpp" 00022 #include "coherence/util/ValueExtractor.hpp" 00023 #include "coherence/util/filter/ComparisonFilter.hpp" 00024 #include "coherence/util/filter/IndexAwareFilter.hpp" 00025 00026 COH_OPEN_NAMESPACE3(coherence,util,filter) 00027 00028 00029 /** 00030 * Filter which tests a Collection or ObjectArray value returned from 00031 * a method invocation for containment of all values in a Set. 00032 * 00033 * More formally, if the specified extractor returns a Collection, 00034 * #evaluate is functionally equivalent to the following 00035 * code: 00036 * <pre> 00037 * return ((Collection) extract(o))->containsAll((Collection) getValue()); 00038 * </pre> 00039 * If the specified method returns an ObjectArray, #evaluate is functionally 00040 * equivalent to the following code: 00041 * <pre> 00042 * return Collections->asList((ObjectArray::View) extract(o))->containsAll( 00043 * (Collection) getValue()); 00044 * </pre> 00045 * @author djl 2008.04.07 00046 */ 00047 class COH_EXPORT ContainsAllFilter 00048 : public class_spec<ContainsAllFilter, 00049 extends<ComparisonFilter>, 00050 implements<IndexAwareFilter> > 00051 { 00052 friend class factory<ContainsAllFilter>; 00053 00054 // ----- constructors --------------------------------------------------- 00055 00056 protected: 00057 /** 00058 * Default constructor (necessary for the PortableObject interface). 00059 */ 00060 ContainsAllFilter(); 00061 00062 /** 00063 * Construct an ContainsAllFilter for testing containment of the given 00064 * Set of values. 00065 * 00066 * @param vExtractor the ValueExtractor used by this filter 00067 * @param vSetValues the Set of values that a Collection or Object array 00068 * is tested to contain 00069 */ 00070 ContainsAllFilter(ValueExtractor::View vExtractor, 00071 Set::View vSetValues); 00072 00073 00074 // ----- ContainsAllFilter interface ------------------------------------ 00075 00076 protected: 00077 /** 00078 * Evaluate the specified extracted value. 00079 * 00080 * @param vExtracted an extracted value to evaluate 00081 */ 00082 virtual bool evaluateExtracted(Object::View vExtracted) const; 00083 00084 00085 // ----- IndexAwareFilter interface ------------------------------------- 00086 00087 public: 00088 /** 00089 * {@inheritDoc} 00090 */ 00091 virtual size32_t calculateEffectiveness(Map::View vMapIndexes, 00092 Set::View vSetKeys) const; 00093 00094 /** 00095 * {@inheritDoc} 00096 */ 00097 virtual Filter::View applyIndex(Map::View vMapIndexes, 00098 Set::Handle hSetKeys) const; 00099 }; 00100 00101 COH_CLOSE_NAMESPACE3 00102 00103 #endif // COH_CONTAINS_ALL_FILTER_HPP