00001 /* 00002 * Copyright (c) 2000, 2020, Oracle and/or its affiliates. 00003 * 00004 * Licensed under the Universal Permissive License v 1.0 as shown at 00005 * http://oss.oracle.com/licenses/upl. 00006 */ 00007 #ifndef COH_CHAINED_EXTRACTOR_HPP 00008 #define COH_CHAINED_EXTRACTOR_HPP 00009 00010 #include "coherence/lang.ns" 00011 00012 #include "coherence/util/ValueExtractor.hpp" 00013 #include "coherence/util/Map.hpp" 00014 #include "coherence/util/extractor/AbstractCompositeExtractor.hpp" 00015 00016 COH_OPEN_NAMESPACE3(coherence,util,extractor) 00017 00018 00019 /** 00020 * Composite ValueExtractor implementation based on an array of extractors. 00021 * The extractors in the array are applied sequentially left-to-right, so a 00022 * result of a previous extractor serves as a target object for a next one. 00023 * 00024 * @author djl 2008.03.07 00025 * 00026 * @see ChainedExtractor 00027 */ 00028 class COH_EXPORT ChainedExtractor 00029 : public class_spec<ChainedExtractor, 00030 extends<AbstractCompositeExtractor> > 00031 { 00032 friend class factory<ChainedExtractor>; 00033 00034 // ----- constructors --------------------------------------------------- 00035 00036 protected: 00037 /** 00038 * Default constructor (necessary for the PortableObject interface). 00039 */ 00040 ChainedExtractor(); 00041 00042 /** 00043 * Return a ChainedExtractor based on a specified ValueExtractor array. 00044 * 00045 * @param vaExtractor the ValueExtractor array 00046 */ 00047 ChainedExtractor(ObjectArray::View vaExtractor); 00048 00049 /** 00050 * Construct a ChainedExtractor based on two extractors. 00051 * 00052 * @param vExtractor1 the ValueExtractor 00053 * @param vExtractor2 the ValueExtractor 00054 */ 00055 ChainedExtractor(ValueExtractor::View vExtractor1, 00056 ValueExtractor::View vExtractor2); 00057 00058 private: 00059 /** 00060 * Blocked copy constructor. 00061 */ 00062 ChainedExtractor(const ChainedExtractor&); 00063 00064 00065 // ----- AbstractExtractor methods -------------------------------------- 00066 00067 public: 00068 /** 00069 * {@inheritDoc} 00070 */ 00071 virtual Object::Holder extract(Object::Holder ohTarget) const; 00072 00073 /** 00074 * Extract the value from the passed entry. The underlying extractors 00075 * are applied sequentially, so a result of a previous extractor serves 00076 * as a target object for a next one. A value of null prevents any 00077 * further extractions and is returned immediately. For intrinsic types, 00078 * the returned value is expected to be a standard wrapper type in the 00079 * same manner that reflection works; for example, int would be 00080 * returned as a Integer32. 00081 */ 00082 virtual Object::Holder extractFromEntry(Map::Entry::Holder ohEntry) const; 00083 00084 00085 // ----- helpers -------------------------------------------------------- 00086 00087 public: 00088 /** 00089 * Parse a dot-delimited sequence of method names and instantiate 00090 * a corresponding array of {@link ReflectionExtractor} objects. 00091 * 00092 * @param vsName a dot-delimited sequence of method names 00093 * 00094 * @return an array of {@link ReflectionExtractor} objects 00095 */ 00096 static ObjectArray::View createExtractors(String::View vsName); 00097 }; 00098 00099 COH_CLOSE_NAMESPACE3 00100 00101 #endif // COH_CHAINED_EXTRACTOR_HPP