Oracle Coherence for C++ API
Release 3.6.0.0

E15728-01

coherence/util/filter/ContainsFilter.hpp

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