coherence/util/extractor/MultiExtractor.hpp

00001 /*
00002 * MultiExtractor.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_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 
00062     // ----- AbstractExtractor methods --------------------------------------
00063 
00064     public:
00065         /**
00066         * {@inheritDoc}
00067         */
00068         virtual Object::Holder extract(Object::Holder ohTarget) const;
00069 
00070         /**
00071         * Extract the value from the passed entry. The underlying extractors
00072         * are applied sequentially, so a result of a previous extractor serves
00073         * as a target object for a next one. A value of NULL prevents any
00074         * further extractions and is returned immediately. For intrinsic types,
00075         * the returned value is expected to be a standard wrapper type in the
00076         * same manner that reflection works; for example, int32_t would be
00077         * returned as a Integer32.
00078         */
00079         virtual Object::Holder extractFromEntry(Map::Entry::Holder ohEntry) const;
00080 
00081 
00082     // ----- QueryMapComparator interface -----------------------------------
00083 
00084     public:
00085         /**
00086         * {@inheritDoc}
00087         */
00088         virtual int32_t compareEntries(QueryMap::Entry::View vEntry1,
00089                 QueryMap::Entry::View vEntry2) const;
00090 
00091 
00092     // ----- helpers --------------------------------------------------------
00093 
00094     public:
00095         /**
00096         * Parse a comma-delimited sequence of method names and instantiate
00097         * a corresponding array ValueExtractor objects. Individual array
00098         * elements will be either ReflectionExtractor or ChainedExtractor
00099         * objects.
00100         *
00101         * @param vsNames  a comma-delimited sequence of method names
00102         *
00103         * @return an array of ValueExtractor objects
00104         */
00105         static ObjectArray::View createExtractors(String::View vsNames);
00106     };
00107 
00108 COH_CLOSE_NAMESPACE3
00109 
00110 #endif // COH_MULTI_EXTRACTOR_HPP
Copyright (c) 2000, 2009, Oracle and/or its affiliates. All rights reserved.