SourceForge.net Logo
EventHandler.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2001, 2008,
3  * DecisionSoft Limited. All rights reserved.
4  * Copyright (c) 2004, 2018 Oracle and/or its affiliates. All rights reserved.
5  *
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 
20 #ifndef _EVENTHANDLER_HPP
21 #define _EVENTHANDLER_HPP
22 
23 #include <xqilla/framework/XQillaExport.hpp>
26 
27 #include <xercesc/util/XercesDefs.hpp>
28 
29 class XQILLA_API EventHandler
30 {
31 public:
32  virtual ~EventHandler() {};
33 
36  virtual void setLocationInfo(const LocationInfo *location) {}
37 
39  virtual void startDocumentEvent(const XMLCh *documentURI, const XMLCh *encoding) = 0;
41  virtual void endDocumentEvent() = 0;
43  virtual void startElementEvent(const XMLCh *prefix, const XMLCh *uri, const XMLCh *localname) = 0;
45  virtual void endElementEvent(const XMLCh *prefix, const XMLCh *uri, const XMLCh *localname,
46  const XMLCh *typeURI, const XMLCh *typeName) = 0;
48  virtual void piEvent(const XMLCh *target, const XMLCh *value) = 0;
50  virtual void textEvent(const XMLCh *value) = 0;
52  virtual void textEvent(const XMLCh *chars, unsigned int length) = 0;
54  virtual void commentEvent(const XMLCh *value) = 0;
56  virtual void attributeEvent(const XMLCh *prefix, const XMLCh *uri, const XMLCh *localname, const XMLCh *value,
57  const XMLCh *typeURI, const XMLCh *typeName) = 0;
59  virtual void namespaceEvent(const XMLCh *prefix, const XMLCh *uri) = 0;
61  virtual void atomicItemEvent(AnyAtomicType::AtomicObjectType type, const XMLCh *value,
62  const XMLCh *typeURI, const XMLCh *typeName) {}
64  virtual void endEvent() = 0;
65 };
66 
67 class XQILLA_API EventFilter : public EventHandler
68 {
69 public:
71  : next_(next)
72  {
73  }
74 
76  {
77  next_ = next;
78  }
79 
80  virtual void setLocationInfo(const LocationInfo *location)
81  {
82  next_->setLocationInfo(location);
83  }
84 
85  virtual void startDocumentEvent(const XMLCh *documentURI, const XMLCh *encoding)
86  {
87  next_->startDocumentEvent(documentURI, encoding);
88  }
89 
90  virtual void endDocumentEvent()
91  {
92  next_->endDocumentEvent();
93  }
94 
95  virtual void startElementEvent(const XMLCh *prefix, const XMLCh *uri, const XMLCh *localname)
96  {
97  next_->startElementEvent(prefix, uri, localname);
98  }
99 
100  virtual void endElementEvent(const XMLCh *prefix, const XMLCh *uri, const XMLCh *localname,
101  const XMLCh *typeURI, const XMLCh *typeName)
102  {
103  next_->endElementEvent(prefix, uri, localname, typeURI, typeName);
104  }
105 
106  virtual void piEvent(const XMLCh *target, const XMLCh *value)
107  {
108  next_->piEvent(target, value);
109  }
110 
111  virtual void textEvent(const XMLCh *value)
112  {
113  next_->textEvent(value);
114  }
115 
116  virtual void textEvent(const XMLCh *chars, unsigned int length)
117  {
118  next_->textEvent(chars, length);
119  }
120 
121  virtual void commentEvent(const XMLCh *value)
122  {
123  next_->commentEvent(value);
124  }
125 
126  virtual void attributeEvent(const XMLCh *prefix, const XMLCh *uri, const XMLCh *localname, const XMLCh *value,
127  const XMLCh *typeURI, const XMLCh *typeName)
128  {
129  next_->attributeEvent(prefix, uri, localname, value, typeURI, typeName);
130  }
131 
132  virtual void namespaceEvent(const XMLCh *prefix, const XMLCh *uri)
133  {
134  next_->namespaceEvent(prefix, uri);
135  }
136 
137  virtual void atomicItemEvent(AnyAtomicType::AtomicObjectType type, const XMLCh *value, const XMLCh *typeURI,
138  const XMLCh *typeName)
139  {
140  next_->atomicItemEvent(type, value, typeURI, typeName);
141  }
142 
143  virtual void endEvent()
144  {
145  next_->endEvent();
146  }
147 
148 protected:
150 };
151 
152 static inline const XMLCh *emptyToNull(const XMLCh * const in)
153 {
154  return (in == 0 || *in == 0) ? 0 : in;
155 }
156 
157 #endif
Definition: EventHandler.hpp:67
virtual void startElementEvent(const XMLCh *prefix, const XMLCh *uri, const XMLCh *localname)
Handles the start of an element node as an event.
Definition: EventHandler.hpp:95
EventFilter(EventHandler *next)
Definition: EventHandler.hpp:70
Definition: EventHandler.hpp:29
virtual ~EventHandler()
Definition: EventHandler.hpp:32
virtual void endDocumentEvent()
Handles a document node as an event.
Definition: EventHandler.hpp:90
virtual void textEvent(const XMLCh *chars, unsigned int length)
Handles a text node as an event.
Definition: EventHandler.hpp:116
AtomicObjectType
Definition: AnyAtomicType.hpp:34
static const XMLCh * emptyToNull(const XMLCh *const in)
Definition: EventHandler.hpp:152
virtual void namespaceEvent(const XMLCh *prefix, const XMLCh *uri)
Handles a namespace binding as an event.
Definition: EventHandler.hpp:132
virtual void setLocationInfo(const LocationInfo *location)
Recieves a LocationInfo object that is owned by the caller, and will be updated with the current loca...
Definition: EventHandler.hpp:80
virtual void startDocumentEvent(const XMLCh *documentURI, const XMLCh *encoding)
Handles a document node as an event.
Definition: EventHandler.hpp:85
virtual void atomicItemEvent(AnyAtomicType::AtomicObjectType type, const XMLCh *value, const XMLCh *typeURI, const XMLCh *typeName)
Handles an atomic item as an event.
Definition: EventHandler.hpp:61
virtual void attributeEvent(const XMLCh *prefix, const XMLCh *uri, const XMLCh *localname, const XMLCh *value, const XMLCh *typeURI, const XMLCh *typeName)
Handles an attribute node as an event.
Definition: EventHandler.hpp:126
virtual void setLocationInfo(const LocationInfo *location)
Recieves a LocationInfo object that is owned by the caller, and will be updated with the current loca...
Definition: EventHandler.hpp:36
virtual void endEvent()
Called when all events have been reported.
Definition: EventHandler.hpp:143
EventHandler * next_
Definition: EventHandler.hpp:149
virtual void endElementEvent(const XMLCh *prefix, const XMLCh *uri, const XMLCh *localname, const XMLCh *typeURI, const XMLCh *typeName)
Handles the end of an element node as an event.
Definition: EventHandler.hpp:100
virtual void piEvent(const XMLCh *target, const XMLCh *value)
Handles a processing instruction node as an event.
Definition: EventHandler.hpp:106
A class that gives records a location in the query.
Definition: LocationInfo.hpp:29
virtual void commentEvent(const XMLCh *value)
Handles a comment node as an event.
Definition: EventHandler.hpp:121
virtual void atomicItemEvent(AnyAtomicType::AtomicObjectType type, const XMLCh *value, const XMLCh *typeURI, const XMLCh *typeName)
Handles an atomic item as an event.
Definition: EventHandler.hpp:137
virtual void textEvent(const XMLCh *value)
Handles a text node as an event.
Definition: EventHandler.hpp:111
void setNextEventHandler(EventHandler *next)
Definition: EventHandler.hpp:75