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-2008
5  * Oracle. All rights reserved.
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  * $Id$
20  */
21 
22 #ifndef _EVENTHANDLER_HPP
23 #define _EVENTHANDLER_HPP
24 
25 #include <xqilla/framework/XQillaExport.hpp>
28 
29 #include <xercesc/util/XercesDefs.hpp>
30 
31 class XQILLA_API EventHandler
32 {
33 public:
34  virtual ~EventHandler() {};
35 
38  virtual void setLocationInfo(const LocationInfo *location) {}
39 
41  virtual void startDocumentEvent(const XMLCh *documentURI, const XMLCh *encoding) = 0;
43  virtual void endDocumentEvent() = 0;
45  virtual void startElementEvent(const XMLCh *prefix, const XMLCh *uri, const XMLCh *localname) = 0;
47  virtual void endElementEvent(const XMLCh *prefix, const XMLCh *uri, const XMLCh *localname,
48  const XMLCh *typeURI, const XMLCh *typeName) = 0;
50  virtual void piEvent(const XMLCh *target, const XMLCh *value) = 0;
52  virtual void textEvent(const XMLCh *value) = 0;
54  virtual void textEvent(const XMLCh *chars, unsigned int length) = 0;
56  virtual void commentEvent(const XMLCh *value) = 0;
58  virtual void attributeEvent(const XMLCh *prefix, const XMLCh *uri, const XMLCh *localname, const XMLCh *value,
59  const XMLCh *typeURI, const XMLCh *typeName) = 0;
61  virtual void namespaceEvent(const XMLCh *prefix, const XMLCh *uri) = 0;
63  virtual void atomicItemEvent(AnyAtomicType::AtomicObjectType type, const XMLCh *value,
64  const XMLCh *typeURI, const XMLCh *typeName) {}
66  virtual void endEvent() = 0;
67 };
68 
69 class XQILLA_API EventFilter : public EventHandler
70 {
71 public:
73  : next_(next)
74  {
75  }
76 
77  void setNextEventHandler(EventHandler *next)
78  {
79  next_ = next;
80  }
81 
82  virtual void setLocationInfo(const LocationInfo *location)
83  {
84  next_->setLocationInfo(location);
85  }
86 
87  virtual void startDocumentEvent(const XMLCh *documentURI, const XMLCh *encoding)
88  {
89  next_->startDocumentEvent(documentURI, encoding);
90  }
91 
92  virtual void endDocumentEvent()
93  {
94  next_->endDocumentEvent();
95  }
96 
97  virtual void startElementEvent(const XMLCh *prefix, const XMLCh *uri, const XMLCh *localname)
98  {
99  next_->startElementEvent(prefix, uri, localname);
100  }
101 
102  virtual void endElementEvent(const XMLCh *prefix, const XMLCh *uri, const XMLCh *localname,
103  const XMLCh *typeURI, const XMLCh *typeName)
104  {
105  next_->endElementEvent(prefix, uri, localname, typeURI, typeName);
106  }
107 
108  virtual void piEvent(const XMLCh *target, const XMLCh *value)
109  {
110  next_->piEvent(target, value);
111  }
112 
113  virtual void textEvent(const XMLCh *value)
114  {
115  next_->textEvent(value);
116  }
117 
118  virtual void textEvent(const XMLCh *chars, unsigned int length)
119  {
120  next_->textEvent(chars, length);
121  }
122 
123  virtual void commentEvent(const XMLCh *value)
124  {
125  next_->commentEvent(value);
126  }
127 
128  virtual void attributeEvent(const XMLCh *prefix, const XMLCh *uri, const XMLCh *localname, const XMLCh *value,
129  const XMLCh *typeURI, const XMLCh *typeName)
130  {
131  next_->attributeEvent(prefix, uri, localname, value, typeURI, typeName);
132  }
133 
134  virtual void namespaceEvent(const XMLCh *prefix, const XMLCh *uri)
135  {
136  next_->namespaceEvent(prefix, uri);
137  }
138 
139  virtual void atomicItemEvent(AnyAtomicType::AtomicObjectType type, const XMLCh *value, const XMLCh *typeURI,
140  const XMLCh *typeName)
141  {
142  next_->atomicItemEvent(type, value, typeURI, typeName);
143  }
144 
145  virtual void endEvent()
146  {
147  next_->endEvent();
148  }
149 
150 protected:
152 };
153 
154 static inline const XMLCh *emptyToNull(const XMLCh * const in)
155 {
156  return (in == 0 || *in == 0) ? 0 : in;
157 }
158 
159 #endif