Xalan-C++ API Reference 1.12.0
ExtensionFunctionHandler.hpp
Go to the documentation of this file.
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18
19#if !defined(XALAN_EXTENSIONFUNCTIONHANDLER_HEADER_GUARD)
20#define XALAN_EXTENSIONFUNCTIONHANDLER_HEADER_GUARD
21
22
23
24// Base include file. Must be first.
26
27
28
30
31
32
35
36
37
39
40
41
43
44
45
46namespace XALAN_CPP_NAMESPACE {
47
48
49
50class XObjectPtr;
51
52
53
54/**
55 * Class handling an extension namespace for XPath. Provides functions
56 * to test a function's existence and call a function
57 */
59{
60
61public:
62
63 /**
64 * Construct a new extension namespace handler for a given extension NS.
65 * This doesn't do anything - just hang on to the namespace URI.
66 *
67 * @param namespaceUri the extension namespace URI that I'm implementing
68 */
70 MemoryManager& theManager);
71
72 /**
73 * Construct a new extension namespace handler given all the information
74 * needed.
75 *
76 * @param namespaceUri the extension namespace URI that I'm implementing
77 * @param funcNames string containing list of functions of extension NS
78 * @param lang language of code implementing the extension
79 * @param srcURL value of src attribute (if any) - treated as a URL
80 * or a classname depending on the value of lang. If
81 * srcURL is not null, then scriptSrc is ignored.
82 * @param scriptSrc the actual script code (if any)
83 */
85 MemoryManager& theManager,
88 const XalanDOMString& lang,
91
92
93 virtual
95
96 MemoryManager&
98 {
99 return m_namespaceUri.getMemoryManager();
100 }
101
102 /**
103 * Set function local parts of extension NS.
104 *
105 * @param functions whitespace separated list of function names defined
106 * by this extension namespace.
107 */
108 virtual void
110
111 /**
112 * Set the script data for this extension NS. If srcURL is !null then
113 * the script body is read from that URL. If not the scriptSrc is used
114 * as the src. This method does not actually execute anything - that's
115 * done when the component is first hit by the user by an element or
116 * a function call.
117 *
118 * @param lang language of the script.
119 * @param srcURL value of src attribute (if any) - treated as a URL
120 * or a classname depending on the value of lang. If
121 * srcURL is not null, then scriptSrc is ignored.
122 * @param scriptSrc the actual script code (if any)
123 */
124 virtual void
126 const XalanDOMString& lang,
127 const XalanDOMString& srcURL,
129
130 /**
131 * Tests whether a certain function name is known within this namespace.
132 *
133 * @param function name of the function being tested
134 * @return true if its known, false if not.
135 */
136 virtual bool
137 isFunctionAvailable(const XalanDOMString& function) const;
138
139 /// Vector of pointers to function arguments
141
143
144 /**
145 * Process a call to a function.
146 *
147 * @param funcName Function name.
148 * @param args The arguments of the function call.
149 *
150 * @return the return value of the function evaluation.
151 *
152 * @exception XSLProcessorException thrown if something goes wrong
153 * while running the extension handler.
154 * @exception MalformedURLException if loading trouble
155 * @exception FileNotFoundException if loading trouble
156 * @exception IOException if loading trouble
157 * @exception SAXException if parsing trouble
158 */
159
160 virtual XObjectPtr
163 const ArgVectorType& args);
164
165protected:
166
167 XalanDOMString m_namespaceUri; // uri of the extension namespace
168 XalanDOMString m_scriptLang; // scripting language of implementation
169 XalanDOMString m_scriptSrc; // script source to run (if any)
170 XalanDOMString m_scriptSrcURL; // URL of source of script (if any)
171
172 void* m_javaObject; // object for javaclass engine
173
174 StringSetType m_functions; // functions of namespace
175
176 // BSFManager mgr = new BSFManager (); // mgr used to run scripts
177
178 bool m_componentStarted; // true when the scripts in a
179
180 // component description (if any) have been run
181
182 /**
183 * Start the component up by executing any script that needs to run
184 * at startup time. This needs to happen before any functions can be
185 * called on the component.
186 *
187 * @exception XPathProcessorException if something bad happens.
188 */
189 virtual void
191
192 static const XalanDOMChar s_tokenDelimiterCharacters[];
193};
194
195
196
197}
198
199
200
201#endif // XALAN_EXTENSIONFUNCTIONHANDLER_HEADER_GUARD
#define XALAN_XSLT_EXPORT
#define XALAN_CPP_NAMESPACE
Xalan-C++ namespace, including major and minor version.
Class handling an extension namespace for XPath.
XalanVector< void * > ArgVectorType
Vector of pointers to function arguments.
virtual void setScript(const XalanDOMString &lang, const XalanDOMString &srcURL, const XalanDOMString &scriptSrc)
Set the script data for this extension NS.
virtual void setFunctions(const XalanDOMString &funcNames)
Set function local parts of extension NS.
ExtensionFunctionHandler(MemoryManager &theManager, const XalanDOMString &namespaceUri, const XalanDOMString &funcNames, const XalanDOMString &lang, const XalanDOMString &srcURL, const XalanDOMString &scriptSrc)
Construct a new extension namespace handler given all the information needed.
virtual bool isFunctionAvailable(const XalanDOMString &function) const
Tests whether a certain function name is known within this namespace.
ExtensionFunctionHandler(const XalanDOMString &namespaceUri, MemoryManager &theManager)
Construct a new extension namespace handler for a given extension NS.
virtual XObjectPtr callFunction(const XalanDOMString &funcName, const ArgVectorType &args)
Process a call to a function.
virtual void startupComponent()
Start the component up by executing any script that needs to run at startup time.
Class to hold XObjectPtr return types.
Definition XObject.hpp:884