00001 /* 00002 * MultiExtractor.hpp 00003 * 00004 * Copyright (c) 2000, 2013, 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_MULTI_EXTRACTOR_HPP 00017 #define COH_MULTI_EXTRACTOR_HPP 00018 00019 #include "coherence/lang.ns" 00020 00021 #include "coherence/util/QueryMap.hpp" 00022 #include "coherence/util/ValueExtractor.hpp" 00023 #include "coherence/util/extractor/AbstractCompositeExtractor.hpp" 00024 00025 COH_OPEN_NAMESPACE3(coherence,util,extractor) 00026 00027 00028 /** 00029 * Composite ValueExtractor implementation based on an array of extractors. 00030 * All extractors in the array are applied to the same target object and the 00031 * result of the extraction is a List of extracted values. 00032 * 00033 * Common scenarios for using the MultiExtractor involve the DistinctValues or 00034 * GroupAggregator aggregators, that allow clients to collect all distinct 00035 * combinations of a given set of attributes or collect and run additional 00036 * aggregation against the corresponding groups of entries. 00037 * 00038 * @author djl 2008.04.09 00039 */ 00040 class COH_EXPORT MultiExtractor 00041 : public class_spec<MultiExtractor, 00042 extends<AbstractCompositeExtractor> > 00043 { 00044 friend class factory<MultiExtractor>; 00045 00046 // ----- constructors --------------------------------------------------- 00047 00048 protected: 00049 /** 00050 * Default constructor (necessary for the PortableObject interface). 00051 */ 00052 MultiExtractor(); 00053 00054 /** 00055 * Construct a MultiExtractor. 00056 * 00057 * @param vaExtractor the ValueExtractor array 00058 */ 00059 MultiExtractor(ObjectArray::View vaExtractor); 00060 00061 private: 00062 /** 00063 * Blocked copy constructor. 00064 */ 00065 MultiExtractor(const MultiExtractor&); 00066 00067 00068 // ----- AbstractExtractor methods -------------------------------------- 00069 00070 public: 00071 /** 00072 * {@inheritDoc} 00073 */ 00074 virtual Object::Holder extract(Object::Holder ohTarget) const; 00075 00076 /** 00077 * Extract the value from the passed entry. The underlying extractors 00078 * are applied sequentially, so a result of a previous extractor serves 00079 * as a target object for a next one. A value of NULL prevents any 00080 * further extractions and is returned immediately. For intrinsic types, 00081 * the returned value is expected to be a standard wrapper type in the 00082 * same manner that reflection works; for example, int32_t would be 00083 * returned as a Integer32. 00084 */ 00085 virtual Object::Holder extractFromEntry(Map::Entry::Holder ohEntry) const; 00086 00087 00088 // ----- QueryMapComparator interface ----------------------------------- 00089 00090 public: 00091 /** 00092 * {@inheritDoc} 00093 */ 00094 virtual int32_t compareEntries(QueryMap::Entry::View vEntry1, 00095 QueryMap::Entry::View vEntry2) const; 00096 00097 00098 // ----- helpers -------------------------------------------------------- 00099 00100 public: 00101 /** 00102 * Parse a comma-delimited sequence of method names and instantiate 00103 * a corresponding array ValueExtractor objects. Individual array 00104 * elements will be either ReflectionExtractor or ChainedExtractor 00105 * objects. 00106 * 00107 * @param vsNames a comma-delimited sequence of method names 00108 * 00109 * @return an array of ValueExtractor objects 00110 */ 00111 static ObjectArray::View createExtractors(String::View vsNames); 00112 }; 00113 00114 COH_CLOSE_NAMESPACE3 00115 00116 #endif // COH_MULTI_EXTRACTOR_HPP