Oracle® Fusion Middleware C++ API Reference for Oracle Coherence
12c (12.2.1.4.0)

E90870-01

coherence/util/filter/BetweenFilter.hpp

00001 /*
00002 * BetweenFilter.hpp
00003 *
00004 * Copyright (c) 2000, 2019, 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_BETWEEN_FILTER_HPP
00017 #define COH_BETWEEN_FILTER_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/SortedMap.hpp"
00025 #include "coherence/util/ValueExtractor.hpp"
00026 #include "coherence/util/filter/AndFilter.hpp"
00027 #include "coherence/util/filter/ExtractorFilter.hpp"
00028 #include "coherence/util/filter/IndexAwareFilter.hpp"
00029 
00030 COH_OPEN_NAMESPACE3(coherence,util,filter)
00031 
00032 using coherence::io::pof::PofReader;
00033 using coherence::io::pof::PofWriter;
00034 using coherence::io::pof::PortableObject;
00035 
00036 
00037 /**
00038 * Filter which compares the result of a method invocation with a value for
00039 * "Between" condition.  We use the standard ISO/IEC 9075:1992 semantic,
00040 * according to which "X between Y and Z" is equivalent to "X >= Y && X <= Z".
00041 * In a case when either result of a method invocation or a value to compare
00042 * are equal to null, the <tt>evaluate</tt> test yields <tt>false</tt>.
00043 * This approach is equivalent to the way the NULL values are handled by SQL.
00044 *
00045 * @author djl  2008.04.07
00046 * @author jk   2014.05.19
00047 */
00048 class COH_EXPORT BetweenFilter
00049     : public class_spec<BetweenFilter,
00050       extends<AndFilter> >
00051     {
00052     friend class factory<BetweenFilter>;
00053 
00054     // ----- constructors ---------------------------------------------------
00055 
00056     protected:
00057         /**
00058         * Default constructor (necessary for the PortableObject interface).
00059         */
00060         BetweenFilter();
00061 
00062         /**
00063         * Construct a BetweenFilter for testing "Between" condition.
00064         *
00065         * @param vExtractor  the ValueExtractor to use by this filter
00066         * @param vFrom      the object to compare the "Greater or Equals"
00067         *                   boundary with
00068         * @param vTo        the object to compare the "Less or Equals" boundary
00069         *                   with
00070         */
00071         BetweenFilter(ValueExtractor::View vExtractor, Comparable::View vFrom,
00072                 Comparable::View vTo);
00073 
00074         /**
00075          * Construct a BetweenFilter for testing "Between" condition.
00076          *
00077          * @param vExtractor          The ValueExtractor to be used by this filter
00078          * @param vLowerBound         The lower bound of the range
00079          * @param vUpperBound         The upper bound of the range
00080          * @param fIncludeLowerBound  A flag indicating whether values matching
00081          *                            the lower bound evaluate to true
00082          * @param fIncludeUpperBound  A flag indicating whether values matching
00083          *                            the upper bound evaluate to true
00084          */
00085         BetweenFilter(ValueExtractor::View vExtractor, Comparable::View vLowerBound,
00086                 Comparable::View vUpperBound, bool fIncludeLowerBound,
00087                 bool fIncludeUpperBound);
00088 
00089     private:
00090         /**
00091         * Blocked copy constructor.
00092         */
00093         BetweenFilter(const BetweenFilter&);
00094 
00095     // ----- EntryFilter interface ------------------------------------------
00096 
00097     public:
00098         /**
00099          * {@inheritDoc}
00100          */
00101         virtual bool evaluateEntry(Map::Entry::View vEntry) const;
00102 
00103 
00104     // ----- Filter interface -----------------------------------------------
00105 
00106     public:
00107         /**
00108          * {@inheritDoc}
00109          */
00110         virtual bool evaluate(Object::View v) const;
00111 
00112     // ----- IndexAwareFilter interface -------------------------------------
00113 
00114     public:
00115         /**
00116          * {@inheritDoc}
00117          */
00118         virtual size32_t calculateEffectiveness(Map::View vMapIndexes,
00119         Set::View vSetKeys) const;
00120 
00121         /**
00122          * {@inheritDoc}
00123          */
00124         virtual Filter::View applyIndex(Map::View vMapIndexes,
00125         Set::Handle hSetKeys) const;
00126 
00127     // ----- Object interface -----------------------------------------------
00128 
00129     public:
00130         /**
00131          * {@inheritDoc}
00132          */
00133         virtual TypedHandle<const String> toString() const;
00134 
00135     // ----- helper methods -------------------------------------------------
00136 
00137     protected:
00138 
00139         virtual Filter::View applySortedIndex(SortedMap::View vIndexContent,
00140             Set::Handle hSetKeys) const;
00141 
00142         virtual bool evaluateExtracted(Object::View vExtracted) const;
00143 
00144     // ----- data member accessors ------------------------------------------
00145 
00146     public:
00147         /**
00148         * Obtain the ValueExtractor used by this filter.
00149         *
00150         * @return the ValueExtractor::View used by this filter
00151         */
00152         virtual ValueExtractor::View getValueExtractor() const;
00153 
00154         /**
00155          * Obtain the lower bound of the range used by this filter.
00156          *
00157          * @return the lower bound Object::View used by this filter
00158          */
00159         virtual Comparable::View getLowerBound() const;
00160 
00161         /**
00162          * Obtain the upper bound of the range used by this filter.
00163          *
00164          * @return the upper bound Object::View used by this filter
00165          */
00166         virtual Comparable::View getUpperBound() const;
00167 
00168         /**
00169          * Obtain the flag indicating whether extracted values matching the
00170          * lower bound of the range used by this filter will evaluate to true.
00171          *
00172          * @return the flag indicating whether extracted values matching the
00173          * lower bound of the range used by this filter will evaluate to true.
00174          */
00175         virtual bool isLowerBoundInclusive() const;
00176 
00177         /**
00178          * Obtain the flag indicating whether extracted values matching the
00179          * upper bound of the range used by this filter will evaluate to true.
00180          *
00181          * @return the flag indicating whether extracted values matching the
00182          * upper bound of the range used by this filter will evaluate to true.
00183          */
00184         virtual bool isUpperBoundInclusive() const;
00185     };
00186 
00187 COH_CLOSE_NAMESPACE3
00188 
00189 #endif // COH_BETWEEN_FILTER_HPP
Copyright © 2000, 2019, Oracle and/or its affiliates. All rights reserved.