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

E47891-01

coherence/util/extractor/AbstractExtractor.hpp

00001 /*
00002 * AbstractExtractor.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_ABSTRACT_EXTRACTOR_HPP
00017 #define COH_ABSTRACT_EXTRACTOR_HPP
00018 
00019 #include "coherence/lang.ns"
00020 
00021 #include "coherence/io/pof/PortableObject.hpp"
00022 #include "coherence/util/MapTrigger.hpp"
00023 #include "coherence/util/QueryMap.hpp"
00024 #include "coherence/util/ValueExtractor.hpp"
00025 #include "coherence/util/comparator/QueryMapComparator.hpp"
00026 
00027 COH_OPEN_NAMESPACE3(coherence,util,extractor)
00028 
00029 using coherence::io::pof::PortableObject;
00030 using coherence::util::comparator::QueryMapComparator;
00031 
00032 
00033 /**
00034 * Abstract base for ValueExtractor implementations.  It provides common
00035 * functionality that allows any extending extractor to be used as a value
00036 * Comparator.
00037 *
00038 * Starting with Coherence 3.5, when used to extract information that is
00039 * coming from a Map, subclasses have the additional ability to operate
00040 * against the Map::Entry instead of just the value. In other words, like the
00041 * EntryExtractor class, this allows an extractor implementation to
00042 * extract a desired value using all available information on the
00043 * corresponding Map::Entry object and is intended to be used in advanced
00044 * custom scenarios, when application code needs to look at both key and
00045 * value at the same time or can make some very specific assumptions regarding
00046 * to the implementation details of the underlying Entry object. To maintain
00047 * full backwards compatibility, the default behavior remains to extract from
00048 * the Value property of the Map::Entry.
00049 *
00050 * <b>Note:</b> subclasses are responsible for initialization and POF
00051 * serialization of the {@link #m_nTarget} field.
00052 *
00053 * @author djl  2008.03.10
00054 */
00055 class COH_EXPORT AbstractExtractor
00056     : public abstract_spec<AbstractExtractor,
00057         extends<Object>,
00058         implements<ValueExtractor, QueryMapComparator, PortableObject> >
00059     {
00060     // ----- constructors ---------------------------------------------------
00061 
00062     protected:
00063         /**
00064         * @internal
00065         */
00066         AbstractExtractor();
00067 
00068 
00069     // ----- ValueExtractor interface ---------------------------------------
00070 
00071     public:
00072         /**
00073         * {@inheritDoc}
00074         */
00075         virtual Object::Holder extract(Object::Holder ohTarget) const;
00076 
00077 
00078     // ----- QueryMapComparator interface -----------------------------------
00079 
00080     public:
00081         /**
00082         * {@inheritDoc}
00083         */
00084         virtual int32_t compareEntries(QueryMap::Entry::View vEntry1,
00085                 QueryMap::Entry::View vEntry2) const;
00086 
00087 
00088     // ----- Comparator interface -------------------------------------------
00089 
00090     public:
00091         /**
00092         * {@inheritDoc}
00093         */
00094         virtual int32_t compare(Object::View v1, Object::View v2) const;
00095 
00096 
00097     // ----- subclassing support --------------------------------------------
00098 
00099     public:
00100         /**
00101         * Extract the value from the passed Entry object. The returned value
00102         * should follow the conventions outlined in the {@link #extract}
00103         * method. By overriding this method, an extractor implementation is
00104         * able to extract a desired value using all available information on
00105         * the corresponding Map::Entry object and is intended to be used in
00106         * advanced custom scenarios, when application code needs to look at
00107         * both key and value at the same time or can make some very specific
00108         * assumptions regarding to the implementation details of the
00109         * underlying Entry object.
00110         *
00111         * @param ohEntry  an Entry object to extract a desired value from
00112         *
00113         * @return the extracted value
00114         *
00115         * @since Coherence 3.5
00116         */
00117         virtual Object::Holder extractFromEntry(
00118                 Map::Entry::Holder ohEntry) const;
00119 
00120         /**
00121         * Extract the value from the "original value" of the passed Entry
00122         * object.  This method's conventions are exactly the same as for the
00123         * {@link #extractFromEntry} method.
00124         *
00125         * @param ohEntry  an Entry object whose original value should be used
00126         *                 to extract the desired value from
00127         *
00128         * @return the extracted value or NULL if the original value is not
00129         *         present
00130         *
00131         * @since Coherence 3.6
00132         */
00133         virtual Object::Holder extractOriginalFromEntry(
00134                 MapTrigger::Entry::Holder ohEntry) const;
00135 
00136 
00137     // ----- constants ------------------------------------------------------
00138 
00139     public:
00140         /**
00141         * Indicates that the {@link #extractFromEntry} operation should use
00142         * the Entry's value.
00143         *
00144         * @since Coherence 3.5
00145         */
00146         static const int32_t value = 0;
00147 
00148         /**
00149         * Indicates that the {@link #extractFromEntry} operation should use
00150         * the Entry's value.
00151         *
00152         * @since Coherence 3.5
00153         */
00154         static const int32_t key = 1;
00155 
00156 
00157     // ----- data members ---------------------------------------------------
00158 
00159     protected:
00160         /**
00161         * Specifies which part of the entry should be used by the
00162         * {@link #extractFromEntry} operation. Legal values are {@link #value}
00163         * (default) or {@link #key}.
00164         *
00165         * <b>Note:</b> subclasses are responsible for initialization and POF
00166         * serialization of this field.
00167         *
00168         * @since Coherence 3.5
00169         */
00170         int32_t m_nTarget;
00171     };
00172 
00173 COH_CLOSE_NAMESPACE3
00174 
00175 #endif // COH_ABSTRACT_EXTRACTOR_HPP
Copyright © 2000, 2014, Oracle and/or its affiliates. All rights reserved.