coherence/util/extractor/ChainedExtractor.hpp

00001 /*
00002 * ChainedExtractor.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_CHAINED_EXTRACTOR_HPP
00017 #define COH_CHAINED_EXTRACTOR_HPP
00018 
00019 #include "coherence/lang.ns"
00020 
00021 #include "coherence/util/ValueExtractor.hpp"
00022 #include "coherence/util/Map.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 * The extractors in the array are applied sequentially left-to-right, so a
00031 * result of a previous extractor serves as a target object for a next one.
00032 *
00033 * @author djl 2008.03.07
00034 *
00035 * @see ChainedExtractor
00036 */
00037 class COH_EXPORT ChainedExtractor
00038     : public class_spec<ChainedExtractor,
00039         extends<AbstractCompositeExtractor> >
00040     {
00041     friend class factory<ChainedExtractor>;
00042 
00043     // ----- constructors ---------------------------------------------------
00044 
00045     protected:
00046         /**
00047         * Default constructor (necessary for the PortableObject interface).
00048         */
00049         ChainedExtractor();
00050 
00051         /**
00052         * Return a ChainedExtractor based on a specified array.
00053         *
00054         * @param vaExtractor  the ValueExtractor array
00055         */
00056         ChainedExtractor(ObjectArray::View vaExtractor);
00057 
00058         /**
00059         * Construct a ChainedExtractor based on two extractors.
00060         *
00061         * @param vExtractor1  the ValueExtractor
00062         * @param vExtractor2  the ValueExtractor
00063         */
00064         ChainedExtractor(ValueExtractor::View vExtractor1,
00065                 ValueExtractor::View vExtractor2);
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, int would be
00083         * returned as a Integer32.
00084         */
00085         virtual Object::Holder extractFromEntry(Map::Entry::Holder ohEntry) const;
00086 
00087 
00088     // ----- helpers --------------------------------------------------------
00089 
00090     public:
00091         /**
00092         * Parse a dot-delimited sequence of method names and instantiate
00093         * a corresponding array of {@link ReflectionExtractor} objects.
00094         *
00095         * @param vsName  a dot-delimited sequence of method names
00096         *
00097         * @return an array of {@link ReflectionExtractor} objects
00098         */
00099         static ObjectArray::View createExtractors(String::View vsName);
00100     };
00101 
00102 COH_CLOSE_NAMESPACE3
00103 
00104 #endif // COH_CHAINED_EXTRACTOR_HPP
Copyright (c) 2000, 2009, Oracle and/or its affiliates. All rights reserved.