00001 /* 00002 * Licensed to the Apache Software Foundation (ASF) under one 00003 * or more contributor license agreements. See the NOTICE file 00004 * distributed with this work for additional information 00005 * regarding copyright ownership. The ASF licenses this file 00006 * to you under the Apache License, Version 2.0 (the "License"); 00007 * you may not use this file except in compliance with the License. 00008 * You may obtain a copy of the License at 00009 * 00010 * http://www.apache.org/licenses/LICENSE-2.0 00011 * 00012 * Unless required by applicable law or agreed to in writing, software 00013 * distributed under the License is distributed on an "AS IS" BASIS, 00014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00015 * See the License for the specific language governing permissions and 00016 * limitations under the License. 00017 */ 00018 00019 #if !defined(XALAN_EXTENSIONFUNCTIONHANDLER_HEADER_GUARD) 00020 #define XALAN_EXTENSIONFUNCTIONHANDLER_HEADER_GUARD 00021 00022 00023 00024 // Base include file. Must be first. 00025 #include <xalanc/XSLT/XSLTDefinitions.hpp> 00026 00027 00028 00029 #include <xalanc/XalanDOM/XalanDOMString.hpp> 00030 00031 00032 00033 #include <xalanc/Include/XalanVector.hpp> 00034 #include <xalanc/Include/XalanSet.hpp> 00035 00036 00037 00038 #include <xalanc/PlatformSupport/DOMStringHelper.hpp> 00039 00040 00041 00042 #include <xalanc/XPath/XObject.hpp> 00043 00044 00045 00046 XALAN_CPP_NAMESPACE_BEGIN 00047 00048 00049 00050 class XObjectPtr; 00051 00052 00053 00054 /** 00055 * Class handling an extension namespace for XPath. Provides functions 00056 * to test a function's existence and call a function 00057 */ 00058 class XALAN_XSLT_EXPORT ExtensionFunctionHandler 00059 { 00060 00061 public: 00062 00063 /** 00064 * Construct a new extension namespace handler for a given extension NS. 00065 * This doesn't do anything - just hang on to the namespace URI. 00066 * 00067 * @param namespaceUri the extension namespace URI that I'm implementing 00068 */ 00069 ExtensionFunctionHandler(const XalanDOMString& namespaceUri, 00070 MemoryManager& theManager); 00071 00072 /** 00073 * Construct a new extension namespace handler given all the information 00074 * needed. 00075 * 00076 * @param namespaceUri the extension namespace URI that I'm implementing 00077 * @param funcNames string containing list of functions of extension NS 00078 * @param lang language of code implementing the extension 00079 * @param srcURL value of src attribute (if any) - treated as a URL 00080 * or a classname depending on the value of lang. If 00081 * srcURL is not null, then scriptSrc is ignored. 00082 * @param scriptSrc the actual script code (if any) 00083 */ 00084 ExtensionFunctionHandler( 00085 MemoryManager& theManager, 00086 const XalanDOMString& namespaceUri, 00087 const XalanDOMString& funcNames, 00088 const XalanDOMString& lang, 00089 const XalanDOMString& srcURL, 00090 const XalanDOMString& scriptSrc); 00091 00092 00093 virtual 00094 ~ExtensionFunctionHandler(); 00095 00096 MemoryManager& 00097 getMemoryManager() 00098 { 00099 return m_namespaceUri.getMemoryManager(); 00100 } 00101 00102 /** 00103 * Set function local parts of extension NS. 00104 * 00105 * @param functions whitespace separated list of function names defined 00106 * by this extension namespace. 00107 */ 00108 virtual void 00109 setFunctions(const XalanDOMString& funcNames); 00110 00111 /** 00112 * Set the script data for this extension NS. If srcURL is !null then 00113 * the script body is read from that URL. If not the scriptSrc is used 00114 * as the src. This method does not actually execute anything - that's 00115 * done when the component is first hit by the user by an element or 00116 * a function call. 00117 * 00118 * @param lang language of the script. 00119 * @param srcURL value of src attribute (if any) - treated as a URL 00120 * or a classname depending on the value of lang. If 00121 * srcURL is not null, then scriptSrc is ignored. 00122 * @param scriptSrc the actual script code (if any) 00123 */ 00124 virtual void 00125 setScript( 00126 const XalanDOMString& lang, 00127 const XalanDOMString& srcURL, 00128 const XalanDOMString& scriptSrc); 00129 00130 /** 00131 * Tests whether a certain function name is known within this namespace. 00132 * 00133 * @param function name of the function being tested 00134 * @return true if its known, false if not. 00135 */ 00136 virtual bool 00137 isFunctionAvailable(const XalanDOMString& function) const; 00138 00139 /// Vector of pointers to function arguments 00140 typedef XalanVector<void*> ArgVectorType; 00141 00142 typedef XalanSet<XalanDOMString> StringSetType; 00143 00144 /** 00145 * Process a call to a function. 00146 * 00147 * @param funcName Function name. 00148 * @param args The arguments of the function call. 00149 * 00150 * @return the return value of the function evaluation. 00151 * 00152 * @exception XSLProcessorException thrown if something goes wrong 00153 * while running the extension handler. 00154 * @exception MalformedURLException if loading trouble 00155 * @exception FileNotFoundException if loading trouble 00156 * @exception IOException if loading trouble 00157 * @exception SAXException if parsing trouble 00158 */ 00159 00160 virtual XObjectPtr 00161 callFunction( 00162 const XalanDOMString& funcName, 00163 const ArgVectorType& args); 00164 00165 protected: 00166 00167 XalanDOMString m_namespaceUri; // uri of the extension namespace 00168 XalanDOMString m_scriptLang; // scripting language of implementation 00169 XalanDOMString m_scriptSrc; // script source to run (if any) 00170 XalanDOMString m_scriptSrcURL; // URL of source of script (if any) 00171 00172 void* m_javaObject; // object for javaclass engine 00173 00174 StringSetType m_functions; // functions of namespace 00175 00176 // BSFManager mgr = new BSFManager (); // mgr used to run scripts 00177 00178 bool m_componentStarted; // true when the scripts in a 00179 00180 // component description (if any) have been run 00181 00182 /** 00183 * Start the component up by executing any script that needs to run 00184 * at startup time. This needs to happen before any functions can be 00185 * called on the component. 00186 * 00187 * @exception XPathProcessorException if something bad happens. 00188 */ 00189 virtual void 00190 startupComponent(); 00191 00192 static const XalanDOMChar s_tokenDelimiterCharacters[]; 00193 }; 00194 00195 00196 00197 XALAN_CPP_NAMESPACE_END 00198 00199 00200 00201 #endif // XALAN_EXTENSIONFUNCTIONHANDLER_HEADER_GUARD
Doxygen and GraphViz are used to generate this API documentation from the Xalan-C header files.
Xalan-C++ XSLT Processor Version 1.11 |
|