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