00001 /* 00002 * PofExtractor.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_POF_EXTRACTOR_HPP 00017 #define COH_POF_EXTRACTOR_HPP 00018 00019 #include "coherence/lang.ns" 00020 00021 #include "coherence/io/pof/PofReader.hpp" 00022 #include "coherence/io/pof/PofWriter.hpp" 00023 #include "coherence/io/pof/PortableObject.hpp" 00024 #include "coherence/io/pof/reflect/PofNavigator.hpp" 00025 #include "coherence/util/extractor/AbstractExtractor.hpp" 00026 00027 COH_OPEN_NAMESPACE3(coherence,util,extractor) 00028 00029 using coherence::io::pof::PofReader; 00030 using coherence::io::pof::PofWriter; 00031 using coherence::io::pof::reflect::PofNavigator; 00032 00033 00034 /** 00035 * POF-based ValueExtractor implementation. 00036 * 00037 * @author as/gm 2009.04.02 00038 * @since Coherence 3.5 00039 */ 00040 class COH_EXPORT PofExtractor 00041 : public class_spec<PofExtractor, 00042 extends<AbstractExtractor>, 00043 implements<PortableObject> > 00044 { 00045 friend class factory<PofExtractor>; 00046 00047 // ----- constructors --------------------------------------------------- 00048 00049 protected: 00050 /** 00051 * Default constructor (for backward compatibility). 00052 */ 00053 PofExtractor(); 00054 00055 /** 00056 * Constructs a PofExtractor based on a property index. 00057 * <p/> 00058 * This constructor is equivalent to: 00059 * <pre> 00060 * PofExtractor::View vExtractor = 00061 * PofExtractor::create(SimplePofPath::create(iProp), VALUE); 00062 * </pre> 00063 * 00064 * @param iProp property index 00065 */ 00066 PofExtractor(int32_t iProp); 00067 00068 /** 00069 * Constructs a PofExtractor based on a property path and the entry 00070 * extraction target. 00071 * 00072 * @param vNavigator POF navigator 00073 * @param nTarget one of the {@link #VALUE} or {@link #KEY} values 00074 */ 00075 PofExtractor(PofNavigator::View vNavigator, int32_t nTarget = VALUE); 00076 00077 00078 // ----- AbstractExtractor methods --------------------------------------- 00079 00080 public: 00081 /** 00082 * Extract the value from the passed Entry object. The returned value 00083 * should follow the conventions outlined in the {@link #extract} 00084 * method. 00085 * <p/> 00086 * This method will always throw a 00087 * {@link UnsupportedOperationException} if called directly by the 00088 * C++ client application, as its execution is only meaningful within 00089 * the cluster. 00090 * <p/> 00091 * It is expected that this extractor will only be used against 00092 * POF-encoded binary entries within a remote partitioned cache. 00093 * 00094 * @param entry an Entry object to extract a desired value from 00095 * 00096 * @throws UnsupportedOperationException always, as it is expected 00097 * that this extractor will only be executed within the 00098 * cluster. 00099 * 00100 * @return the extracted value 00101 */ 00102 virtual Object::Holder extractFromEntry(Map::Entry::Holder ohEntry) const; 00103 00104 00105 // ----- PortableObject interface --------------------------------------- 00106 00107 public: 00108 /** 00109 * {@inheritDoc} 00110 */ 00111 virtual void readExternal(PofReader::Handle hIn); 00112 00113 /** 00114 * {@inheritDoc} 00115 */ 00116 virtual void writeExternal(PofWriter::Handle hOut) const; 00117 00118 00119 // ----- Object interface ----------------------------------------------- 00120 00121 public: 00122 /** 00123 * Compare the PofExtractor with another object to determine equality. 00124 * Two PofExtractor objects are considered equal iff their paths are 00125 * equal and they have the same target (key or value). 00126 * 00127 * @return true iff this PofExtractor and the passed object are 00128 * equivalent 00129 */ 00130 virtual bool equals(Object::View v) const; 00131 00132 /** 00133 * Determine a hash value for the PofExtractor object according to the 00134 * general {@link Object#hashCode()} contract. 00135 * 00136 * @return an integer hash value for this PofExtractor object 00137 */ 00138 virtual size32_t hashCode() const; 00139 00140 /** 00141 * Return a human-readable description for this PofExtractor. 00142 * 00143 * @return a String description of the PofExtractor 00144 */ 00145 virtual void toStream(std::ostream& out) const; 00146 00147 00148 // ----- accessors ------------------------------------------------------ 00149 00150 public: 00151 /** 00152 * Obtain the PofPath for this extractor. 00153 * 00154 * @return the PofPath value 00155 */ 00156 virtual PofNavigator::View getNavigator() const; 00157 00158 00159 // ----- data members --------------------------------------------------- 00160 00161 private: 00162 /** 00163 * POF navigator. 00164 */ 00165 FinalView<PofNavigator> m_vNavigator; 00166 }; 00167 00168 COH_CLOSE_NAMESPACE3 00169 00170 #endif // #define COH_POF_EXTRACTOR_HPP