Xalan-C++ API Reference  1.12.0
XPathExecutionContextDefault.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 #if !defined(XPATHEXECUTIONCONTEXTDEFAULT_HEADER_GUARD_1357924680)
19 #define XPATHEXECUTIONCONTEXTDEFAULT_HEADER_GUARD_1357924680
20 
21 
22 
23 // Base include file. Must be first.
25 
26 
27 
30 
31 
32 
34 
35 
36 
37 // Base class include file.
39 
40 
41 
43 
44 
45 
48 
49 
50 
51 namespace XALAN_CPP_NAMESPACE {
52 
53 
54 
55 class DOMSupport;
56 class XPathEnvSupport;
57 class XalanQName;
58 
59 
60 
61 /**
62  * A basic implementation of the class XPathExecutionContext.
63  */
65 {
66 public:
67 
70 
71  /**
72  * Construct an XPathExecutionContextDefault object
73  *
74  * @param theXPathEnvSupport XPathEnvSupport class instance
75  * @param theDOMSupport DOMSupport class instance
76  * @param theXobjectFactory factory class instance for XObjects
77  * @param theCurrentNode current node in the source tree
78  * @param theContextNodeList node list for current context
79  * @param thePrefixResolver pointer to prefix resolver to use
80  */
82  XPathEnvSupport& theXPathEnvSupport,
83  DOMSupport& theDOMSupport,
84  XObjectFactory& theXObjectFactory,
85  XalanNode* theCurrentNode = 0,
86  const NodeRefListBase* theContextNodeList = 0,
87  const PrefixResolver* thePrefixResolver = 0);
88 
89  /**
90  * Construct an XPathExecutionContextDefault object
91  *
92  * @param theXPathEnvSupport XPathEnvSupport class instance
93  * @param theXObjectFactory factory class instance for XObjects
94  * @param theCurrentNode current node in the source tree
95  * @param theContextNodeList node list for current context
96  * @param thePrefixResolver pointer to prefix resolver to use
97  */
98  explicit
100  MemoryManager& theManager,
101  XalanNode* theCurrentNode = 0,
102  const NodeRefListBase* theContextNodeList = 0,
103  const PrefixResolver* thePrefixResolver = 0);
104 
106  create(
107  MemoryManager& theManager,
108  XalanNode* theCurrentNode = 0,
109  const NodeRefListBase* theContextNodeList = 0,
110  const PrefixResolver* thePrefixResolver = 0);
111 
112  virtual
114 
115 
116  /**
117  * Get the XPathEnvSupport instance.
118  *
119  * @return a pointer to the instance.
120  */
123  {
124  return m_xpathEnvSupport;
125  }
126 
127  /**
128  * Set the XPathEnvSupport instance.
129  *
130  * @param theSupport a reference to the instance to use.
131  */
132  void
134  {
135  m_xpathEnvSupport = theSupport;
136  }
137 
138  /**
139  * Set the DOMSupport instance.
140  *
141  * @param theDOMSupport a reference to the instance to use.
142  */
143  void
144  setDOMSupport(DOMSupport* theDOMSupport)
145  {
146  m_domSupport = theDOMSupport;
147  }
148 
149  /**
150  * Set the XObjectFactory instance.
151  *
152  * @param theFactory a reference to the instance to use.
153  */
154  void
155  setXObjectFactory(XObjectFactory* theXObjectFactory)
156  {
157  m_xobjectFactory = theXObjectFactory;
158  }
159 
160  /**
161  * Get a reference to the scratch QNameByValue instance.
162  *
163  * @return A reference to a QNameByValue instance.
164  */
167  {
168  return m_scratchQName;
169  }
170 
171  virtual void doFormatNumber(
172  double number,
173  const XalanDOMString& pattern,
174  const XalanDecimalFormatSymbols* theDFS,
175  XalanDOMString& theResult,
176  const XalanNode* context = 0,
177  const Locator* locator = 0);
178 
179  // These interfaces are inherited from XPathExecutionContext...
180 
181  virtual void
182  reset();
183 
184  virtual XalanNode*
185  getCurrentNode() const;
186 
187  virtual void
188  pushCurrentNode(XalanNode* theCurrentNode);
189 
190  virtual void
191  popCurrentNode();
192 
193  virtual bool
194  isNodeAfter(
195  const XalanNode& node1,
196  const XalanNode& node2) const;
197 
198  virtual void
199  pushContextNodeList(const NodeRefListBase& theList);
200 
201  virtual void
202  popContextNodeList();
203 
204  virtual const NodeRefListBase&
205  getContextNodeList() const;
206 
207  virtual size_type
208  getContextNodeListLength() const;
209 
210  virtual size_type
211  getContextNodeListPosition(const XalanNode& contextNode) const;
212 
213  virtual bool
214  elementAvailable(const XalanQName& theQName) const;
215 
216  virtual bool
217  elementAvailable(
218  const XalanDOMString& theName,
219  const Locator* locator) const;
220 
221  virtual bool
222  functionAvailable(const XalanQName& theQName) const;
223 
224  virtual bool
225  functionAvailable(
226  const XalanDOMString& theName,
227  const Locator* locator) const;
228 
229  virtual const XObjectPtr
230  extFunction(
231  const XalanDOMString& theNamespace,
232  const XalanDOMString& functionName,
233  XalanNode* context,
234  const XObjectArgVectorType& argVec,
235  const Locator* locator);
236 
237  virtual XalanDocument*
238  parseXML(
239  MemoryManager& theManager,
240  const XalanDOMString& urlString,
241  const XalanDOMString& base,
242  ErrorHandler* theErrorHandler = 0) const;
243 
244  virtual MutableNodeRefList*
245  borrowMutableNodeRefList();
246 
247  virtual bool
248  returnMutableNodeRefList(MutableNodeRefList* theList);
249 
250  virtual MutableNodeRefList*
251  createMutableNodeRefList(MemoryManager& theManager) const;
252 
253  virtual XalanDOMString&
254  getCachedString();
255 
256  virtual bool
257  releaseCachedString(XalanDOMString& theString);
258 
259  virtual void
260  getNodeSetByKey(
261  XalanNode* context,
262  const XalanQName& qname,
263  const XalanDOMString& ref,
264  const Locator* locator,
265  MutableNodeRefList& nodelist);
266 
267  virtual void
268  getNodeSetByKey(
269  XalanNode* context,
270  const XalanDOMString& name,
271  const XalanDOMString& ref,
272  const Locator* locator,
273  MutableNodeRefList& nodelist);
274 
275  virtual const XObjectPtr
276  getVariable(
277  const XalanQName& name,
278  const Locator* locator = 0);
279 
280  virtual const PrefixResolver*
281  getPrefixResolver() const;
282 
283  virtual void
284  setPrefixResolver(const PrefixResolver* thePrefixResolver);
285 
286  virtual const XalanDOMString*
287  getNamespaceForPrefix(const XalanDOMString& prefix) const;
288 
289  virtual const XalanDOMString&
290  findURIFromDoc(const XalanDocument* owner) const;
291 
292  virtual const XalanDOMString&
293  getUnparsedEntityURI(
294  const XalanDOMString& theName,
295  const XalanDocument& theDocument) const;
296 
297  virtual XalanDocument*
298  getSourceDocument(const XalanDOMString& theURI) const;
299 
300  virtual void
301  setSourceDocument(
302  const XalanDOMString& theURI,
303  XalanDocument* theDocument);
304 
305  virtual void formatNumber(
306  double number,
307  const XalanDOMString& pattern,
308  XalanDOMString& theResult,
309  const XalanNode* context = 0,
310  const Locator* locator = 0);
311 
312  virtual void formatNumber(
313  double number,
314  const XalanDOMString& pattern,
315  const XalanDOMString& dfsName,
316  XalanDOMString& theResult,
317  const XalanNode* context = 0,
318  const Locator* locator = 0);
319 
320 
321  // These interfaces are inherited from ExecutionContext...
322 
323  virtual void
324  problem(
325  eSource source,
326  eClassification classification,
327  const XalanDOMString& msg,
328  const Locator* locator,
329  const XalanNode* sourceNode);
330 
331  virtual void
332  problem(
333  eSource source,
334  eClassification classification,
335  const XalanDOMString& msg,
336  const XalanNode* sourceNode);
337 
338  virtual void
339  error(
340  const XalanDOMString& msg,
341  const XalanNode* sourceNode = 0,
342  const Locator* locator = 0) const;
343 
344  virtual void
345  warn(
346  const XalanDOMString& msg,
347  const XalanNode* sourceNode = 0,
348  const Locator* locator = 0) const;
349 
350  virtual void
351  message(
352  const XalanDOMString& msg,
353  const XalanNode* sourceNode = 0,
354  const Locator* locator = 0) const;
355 
356  virtual bool
357  shouldStripSourceNode(const XalanText& node);
358 
359 protected:
360 
361  typedef XalanObjectCache<
366 
367  enum { eNodeListCacheListSize = 50 };
368 
370  {
372  m_node(0),
373  m_index(0)
374  {
375  }
376 
377  void
379  {
380  if (m_node != 0)
381  {
382  m_node = 0;
383  }
384  }
385 
387 
389  };
390 
392 
394 
396 
398 
400 
402 
404 
406 
408 
410 
411  static const NodeRefList s_dummyList;
412 };
413 
414 
415 
416 }
417 
418 
419 
420 #endif // XPATHEXECUTIONCONTEXTDEFAULT_HEADER_GUARD_1357924680
xalanc::XPathExecutionContextDefault::m_prefixResolver
const PrefixResolver * m_prefixResolver
Definition: XPathExecutionContextDefault.hpp:399
xalanc::XPathExecutionContextDefault::ContextNodeListPositionCache::clear
void clear()
Definition: XPathExecutionContextDefault.hpp:378
MutableNodeRefList.hpp
xalanc::XPathExecutionContextDefault::m_scratchQName
XalanQNameByValue m_scratchQName
Definition: XPathExecutionContextDefault.hpp:409
XALAN_CPP_NAMESPACE
#define XALAN_CPP_NAMESPACE
Xalan-C++ namespace, including major and minor version.
Definition: XalanVersion.hpp:76
xalanc::XPathExecutionContextDefault::m_contextNodeListStack
ContextNodeListStackType m_contextNodeListStack
Definition: XPathExecutionContextDefault.hpp:397
xalanc::XalanNode
Definition: XalanNode.hpp:38
xalanc::XPathExecutionContextDefault::m_xpathEnvSupport
XPathEnvSupport * m_xpathEnvSupport
Definition: XPathExecutionContextDefault.hpp:391
XalanDOMString.hpp
xalanc::XalanVector< XalanNode * >
xalanc::XalanText
Definition: XalanText.hpp:40
xalanc::XalanDecimalFormatSymbols
Definition: XalanDecimalFormatSymbols.hpp:40
xalanc::MutableNodeRefList
Local implementation of MutableNodeRefList.
Definition: MutableNodeRefList.hpp:46
xalanc::XPathExecutionContextDefault::s_dummyList
static const NodeRefList s_dummyList
Definition: XPathExecutionContextDefault.hpp:411
xalanc::XPathExecutionContextDefault::setXPathEnvSupport
void setXPathEnvSupport(XPathEnvSupport *theSupport)
Set the XPathEnvSupport instance.
Definition: XPathExecutionContextDefault.hpp:133
xalanc::NodeRefList
Local implementation of NodeRefList.
Definition: NodeRefList.hpp:43
xalanc::XalanDocument
Definition: XalanDocument.hpp:36
xalanc::size_type
size_t size_type
Definition: XalanMap.hpp:46
xalanc::XPathExecutionContextDefault::m_currentPattern
XalanDOMString m_currentPattern
Definition: XPathExecutionContextDefault.hpp:401
XalanVector.hpp
XalanQNameByValue.hpp
XALAN_XPATH_EXPORT
#define XALAN_XPATH_EXPORT
Definition: XPathDefinitions.hpp:35
xalanc::ClearCacheResetFunctor< MutableNodeRefList >
xalanc::XObjectPtr
Class to hold XObjectPtr return types.
Definition: XObject.hpp:883
xalanc::XalanDOMStringCache
Definition: XalanDOMStringCache.hpp:44
xalanc::XPathExecutionContextDefault::m_cachedPosition
ContextNodeListPositionCache m_cachedPosition
Definition: XPathExecutionContextDefault.hpp:407
xalanc::XPathExecutionContextDefault::m_domSupport
DOMSupport * m_domSupport
Definition: XPathExecutionContextDefault.hpp:393
xalanc::XPathExecutionContextDefault::NodeListCacheType
XalanObjectCache< MutableNodeRefList, DefaultCacheCreateFunctorMemMgr< MutableNodeRefList >, DeleteFunctor< MutableNodeRefList >, ClearCacheResetFunctor< MutableNodeRefList > > NodeListCacheType
Definition: XPathExecutionContextDefault.hpp:365
xalanc::DefaultCacheCreateFunctorMemMgr< MutableNodeRefList >
xalanc::XalanObjectCache
Definition: XalanObjectCache.hpp:263
xalanc::XPathExecutionContextDefault::ContextNodeListPositionCache
Definition: XPathExecutionContextDefault.hpp:369
xalanc::XPathExecutionContext::size_type
NodeRefListBase::size_type size_type
Definition: XPathExecutionContext.hpp:88
xalanc::XPathExecutionContextDefault
A basic implementation of the class XPathExecutionContext.
Definition: XPathExecutionContextDefault.hpp:64
xalanc::XPathExecutionContextDefault::ContextNodeListPositionCache::m_node
const XalanNode * m_node
Definition: XPathExecutionContextDefault.hpp:386
xalanc::DeleteFunctor< MutableNodeRefList >
xalanc::XPathExecutionContextDefault::getXPathEnvSupport
XPathEnvSupport * getXPathEnvSupport() const
Get the XPathEnvSupport instance.
Definition: XPathExecutionContextDefault.hpp:122
XalanObjectCache.hpp
xalanc::XalanQNameByValue
Definition: XalanQNameByValue.hpp:49
xalanc::PrefixResolver
This class defines an interface for classes that resolve namespace prefixes to their URIs.
Definition: PrefixResolver.hpp:39
XPathExecutionContext.hpp
xalanc::DOMSupport
Definition: DOMSupport.hpp:41
xalanc::XPathExecutionContextDefault::setDOMSupport
void setDOMSupport(DOMSupport *theDOMSupport)
Set the DOMSupport instance.
Definition: XPathExecutionContextDefault.hpp:144
xalanc::XPathExecutionContextDefault::m_currentNodeStack
CurrentNodeStackType m_currentNodeStack
Definition: XPathExecutionContextDefault.hpp:395
xalanc::XPathEnvSupport
Definition: XPathEnvSupport.hpp:60
xalanc::XPathExecutionContext
Definition: XPathExecutionContext.hpp:82
xalanc::NodeRefListBase
Local implementation of NodeRefList.
Definition: NodeRefListBase.hpp:44
xalanc::XalanQName
Class to represent a qualified name.
Definition: XalanQName.hpp:70
xalanc::XPathExecutionContextDefault::m_stringCache
XalanDOMStringCache m_stringCache
Definition: XPathExecutionContextDefault.hpp:405
xalanc::XPathExecutionContextDefault::getScratchQName
XalanQNameByValue & getScratchQName() const
Get a reference to the scratch QNameByValue instance.
Definition: XPathExecutionContextDefault.hpp:166
xalanc::XalanDOMString
Definition: XalanDOMString.hpp:45
xalanc::XPathExecutionContextDefault::ContextNodeListStackType
XalanVector< const NodeRefListBase * > ContextNodeListStackType
Definition: XPathExecutionContextDefault.hpp:69
xalanc::XPathExecutionContextDefault::setXObjectFactory
void setXObjectFactory(XObjectFactory *theXObjectFactory)
Set the XObjectFactory instance.
Definition: XPathExecutionContextDefault.hpp:155
xalanc::XPathExecutionContextDefault::ContextNodeListPositionCache::m_index
size_type m_index
Definition: XPathExecutionContextDefault.hpp:388
xalanc::XObjectFactory
This class handles the creation of XObjects and manages their lifetime.
Definition: XObjectFactory.hpp:53
xalanc::XPathExecutionContextDefault::ContextNodeListPositionCache::ContextNodeListPositionCache
ContextNodeListPositionCache()
Definition: XPathExecutionContextDefault.hpp:371
xalanc::XPathExecutionContextDefault::CurrentNodeStackType
XalanVector< XalanNode * > CurrentNodeStackType
Definition: XPathExecutionContextDefault.hpp:68
xalanc::XPathExecutionContextDefault::m_nodeListCache
NodeListCacheType m_nodeListCache
Definition: XPathExecutionContextDefault.hpp:403
XPathDefinitions.hpp
XalanDOMStringCache.hpp