GME  13
SAX2XMLFilterImpl.cpp
Go to the documentation of this file.
00001 /*
00002  * Licensed to the Apache Software Foundation (ASF) under one or more
00003  * contributor license agreements.  See the NOTICE file distributed with
00004  * this work for additional information regarding copyright ownership.
00005  * The ASF licenses this file to You under the Apache License, Version 2.0
00006  * (the "License"); you may not use this file except in compliance with
00007  * the License.  You may obtain a copy of the License at
00008  *
00009  *      http://www.apache.org/licenses/LICENSE-2.0
00010  *
00011  * Unless required by applicable law or agreed to in writing, software
00012  * distributed under the License is distributed on an "AS IS" BASIS,
00013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  * See the License for the specific language governing permissions and
00015  * limitations under the License.
00016  */
00017 
00018 /*
00019  * $Id: SAX2XMLFilterImpl.cpp 673975 2008-07-04 09:23:56Z borisk $
00020  */
00021 
00022 #include <xercesc/parsers/SAX2XMLFilterImpl.hpp>
00023 
00024 XERCES_CPP_NAMESPACE_BEGIN
00025 
00026 SAX2XMLFilterImpl::SAX2XMLFilterImpl(SAX2XMLReader* parent) :
00027     fParentReader(0)
00028     , fDocHandler(0)
00029     , fDTDHandler(0)
00030     , fEntityResolver(0)
00031     , fErrorHandler(0)
00032 {
00033     setParent(parent);
00034 }
00035 
00036 SAX2XMLFilterImpl::~SAX2XMLFilterImpl()
00037 {
00038 }
00039 
00040 // ---------------------------------------------------------------------------
00041 //  SAX2XMLFilterImpl: XMLFilter impl
00042 // ---------------------------------------------------------------------------
00043 void SAX2XMLFilterImpl::setParent(SAX2XMLReader* parent)
00044 {
00045     if(fParentReader)
00046     {
00047         fParentReader->setEntityResolver(0);
00048         fParentReader->setDTDHandler(0);
00049         fParentReader->setContentHandler(0);
00050         fParentReader->setErrorHandler(0);
00051     }
00052     fParentReader=parent;
00053     if(fParentReader)
00054     {
00055         fParentReader->setEntityResolver(this);
00056         fParentReader->setDTDHandler(this);
00057         fParentReader->setContentHandler(this);
00058         fParentReader->setErrorHandler(this);
00059     }
00060 }
00061 
00062 bool SAX2XMLFilterImpl::getExitOnFirstFatalError() const
00063 {
00064     if(fParentReader)
00065         fParentReader->getExitOnFirstFatalError();
00066     return false;
00067 }
00068 
00069 bool SAX2XMLFilterImpl::getValidationConstraintFatal() const
00070 {
00071     if(fParentReader)
00072         fParentReader->getValidationConstraintFatal();
00073     return false;
00074 }
00075 
00076 Grammar* SAX2XMLFilterImpl::getRootGrammar()
00077 {
00078     if(fParentReader)
00079         fParentReader->getRootGrammar();
00080     return NULL;
00081 }
00082 
00083 const XMLCh* SAX2XMLFilterImpl::getURIText(unsigned int uriId) const
00084 {
00085     if(fParentReader)
00086         fParentReader->getURIText(uriId);
00087     return NULL;
00088 }
00089 
00090 XMLFilePos SAX2XMLFilterImpl::getSrcOffset() const
00091 {
00092     if(fParentReader)
00093         fParentReader->getSrcOffset();
00094     return 0;
00095 }
00096 
00097 // ---------------------------------------------------------------------------
00098 //  SAX2XMLFilterImpl Validator functions
00099 // ---------------------------------------------------------------------------
00100 void SAX2XMLFilterImpl::setValidator(XMLValidator* valueToAdopt)
00101 {
00102     if(fParentReader)
00103         fParentReader->setValidator(valueToAdopt);
00104 }
00105 
00106 XMLValidator* SAX2XMLFilterImpl::getValidator() const
00107 {
00108     if(fParentReader)
00109         return fParentReader->getValidator();
00110         return 0;
00111 }
00112 
00113 // ---------------------------------------------------------------------------
00114 //  SAX2XMLReader Interface
00115 // ---------------------------------------------------------------------------
00116 XMLSize_t SAX2XMLFilterImpl::getErrorCount() const
00117 {
00118     if(fParentReader)
00119         return fParentReader->getErrorCount();
00120     return 0;
00121 }
00122 
00123 void SAX2XMLFilterImpl::setExitOnFirstFatalError(const bool newState)
00124 {
00125     if(fParentReader)
00126         fParentReader->setExitOnFirstFatalError(newState);
00127 }
00128 
00129 void SAX2XMLFilterImpl::setValidationConstraintFatal(const bool newState)
00130 {
00131     if(fParentReader)
00132         fParentReader->setValidationConstraintFatal(newState);
00133 }
00134 
00135 void SAX2XMLFilterImpl::parse (const   InputSource&    source)
00136 {
00137     if(fParentReader)
00138         fParentReader->parse(source);
00139 }
00140 
00141 void SAX2XMLFilterImpl::parse (const   XMLCh* const    systemId)
00142 {
00143     if(fParentReader)
00144         fParentReader->parse(systemId);
00145 }
00146 
00147 void SAX2XMLFilterImpl::parse (const   char* const     systemId)
00148 {
00149     if(fParentReader)
00150         fParentReader->parse(systemId);
00151 }
00152 
00153 // ---------------------------------------------------------------------------
00154 //  SAX2XMLFilterImpl: Progressive parse methods
00155 // ---------------------------------------------------------------------------
00156 bool SAX2XMLFilterImpl::parseFirst( const   XMLCh* const    systemId
00157                             ,       XMLPScanToken&  toFill)
00158 {
00159     if(fParentReader)
00160         return fParentReader->parseFirst(systemId, toFill);
00161     return false;
00162 }
00163 
00164 bool SAX2XMLFilterImpl::parseFirst( const   char* const     systemId
00165                             ,       XMLPScanToken&  toFill)
00166 {
00167     if(fParentReader)
00168         fParentReader->parseFirst(systemId, toFill);
00169     return false;
00170 }
00171 
00172 bool SAX2XMLFilterImpl::parseFirst( const   InputSource&    source
00173                             ,       XMLPScanToken&  toFill)
00174 {
00175     if(fParentReader)
00176         fParentReader->parseFirst(source, toFill);
00177     return false;
00178 }
00179 
00180 bool SAX2XMLFilterImpl::parseNext(XMLPScanToken& token)
00181 {
00182     if(fParentReader)
00183         fParentReader->parseNext(token);
00184     return false;
00185 }
00186 
00187 void SAX2XMLFilterImpl::parseReset(XMLPScanToken& token)
00188 {
00189     if(fParentReader)
00190         fParentReader->parseReset(token);
00191 }
00192 
00193 // ---------------------------------------------------------------------------
00194 //  SAX2XMLFilterImpl: Features and Properties
00195 // ---------------------------------------------------------------------------
00196 
00197 void SAX2XMLFilterImpl::setFeature(const XMLCh* const name, const bool value)
00198 {
00199     if(fParentReader)
00200         fParentReader->setFeature(name,value);
00201 }
00202 
00203 bool SAX2XMLFilterImpl::getFeature(const XMLCh* const name) const
00204 {
00205     if(fParentReader)
00206         return fParentReader->getFeature(name);
00207     return false;
00208 }
00209 
00210 void SAX2XMLFilterImpl::setProperty(const XMLCh* const name, void* value)
00211 {
00212     if(fParentReader)
00213         fParentReader->setProperty(name,value);
00214 }
00215 
00216 void* SAX2XMLFilterImpl::getProperty(const XMLCh* const name) const
00217 {
00218     if(fParentReader)
00219         return fParentReader->getProperty(name);
00220     return NULL;
00221 }
00222 
00223 // ---------------------------------------------------------------------------
00224 //  SAX2XMLFilterImpl: Grammar preparsing
00225 // ---------------------------------------------------------------------------
00226 Grammar* SAX2XMLFilterImpl::loadGrammar(const char* const systemId,
00227                                         const Grammar::GrammarType grammarType,
00228                                         const bool toCache)
00229 {
00230     if(fParentReader)
00231         return fParentReader->loadGrammar(systemId, grammarType, toCache);
00232     return NULL;
00233 }
00234 
00235 Grammar* SAX2XMLFilterImpl::loadGrammar(const XMLCh* const systemId,
00236                                         const Grammar::GrammarType grammarType,
00237                                         const bool toCache)
00238 {
00239     if(fParentReader)
00240         return fParentReader->loadGrammar(systemId, grammarType, toCache);
00241     return NULL;
00242 }
00243 
00244 Grammar* SAX2XMLFilterImpl::loadGrammar(const InputSource& source,
00245                                         const Grammar::GrammarType grammarType,
00246                                         const bool toCache)
00247 {
00248     if(fParentReader)
00249         return fParentReader->loadGrammar(source, grammarType, toCache);
00250     return NULL;
00251 }
00252 
00253 void SAX2XMLFilterImpl::resetCachedGrammarPool()
00254 {
00255     if(fParentReader)
00256         fParentReader->resetCachedGrammarPool();
00257 }
00258 
00259 void SAX2XMLFilterImpl::setInputBufferSize(const XMLSize_t bufferSize)
00260 {
00261     if(fParentReader)
00262         fParentReader->setInputBufferSize(bufferSize);
00263 }
00264 
00265 Grammar* SAX2XMLFilterImpl::getGrammar(const XMLCh* const nameSpaceKey)
00266 {
00267     if(fParentReader)
00268         return fParentReader->getGrammar(nameSpaceKey);
00269     return NULL;
00270 }
00271 
00272 // -----------------------------------------------------------------------
00273 //  Implementation of the EntityResolver interface
00274 // -----------------------------------------------------------------------
00275 InputSource* SAX2XMLFilterImpl::resolveEntity(const XMLCh* const    publicId
00276                                             , const XMLCh* const    systemId)
00277 {
00278     if(fEntityResolver)
00279         return fEntityResolver->resolveEntity(publicId, systemId);
00280     return 0;
00281 }
00282 
00283 // -----------------------------------------------------------------------
00284 //  Implementation of the DTDHandler interface
00285 // -----------------------------------------------------------------------
00286 void SAX2XMLFilterImpl::notationDecl( const XMLCh* const    name
00287                                     , const XMLCh* const    publicId
00288                                     , const XMLCh* const    systemId)
00289 {
00290     if(fDTDHandler)
00291         fDTDHandler->notationDecl(name, publicId, systemId);
00292 }
00293 
00294 void SAX2XMLFilterImpl::unparsedEntityDecl(const XMLCh* const    name
00295                                          , const XMLCh* const    publicId
00296                                          , const XMLCh* const    systemId
00297                                          , const XMLCh* const    notationName)
00298 {
00299     if(fDTDHandler)
00300         fDTDHandler->unparsedEntityDecl(name, publicId, systemId, notationName);
00301 }
00302 
00303 void SAX2XMLFilterImpl::resetDocType()
00304 {
00305     if(fDTDHandler)
00306         fDTDHandler->resetDocType();
00307 }
00308 
00309 // -----------------------------------------------------------------------
00310 //  Implementation of the ContentHandler interface
00311 // -----------------------------------------------------------------------
00312 
00313 void SAX2XMLFilterImpl::characters(const XMLCh* const    chars
00314                                  , const XMLSize_t       length)
00315 {
00316     if(fDocHandler)
00317         fDocHandler->characters(chars, length);
00318 }
00319 
00320 void SAX2XMLFilterImpl::endDocument()
00321 {
00322     if(fDocHandler)
00323         fDocHandler->endDocument();
00324 }
00325 
00326 void SAX2XMLFilterImpl::endElement(const XMLCh* const uri
00327                                          , const XMLCh* const localname
00328                                          , const XMLCh* const qname)
00329 {
00330     if(fDocHandler)
00331         fDocHandler->endElement(uri, localname, qname);
00332 }
00333 
00334 void SAX2XMLFilterImpl::ignorableWhitespace(const XMLCh* const    chars
00335                                           , const XMLSize_t       length)
00336 {
00337     if(fDocHandler)
00338         fDocHandler->ignorableWhitespace(chars, length);
00339 }
00340 
00341 void SAX2XMLFilterImpl::processingInstruction(const XMLCh* const    target
00342                                             , const XMLCh* const    data)
00343 {
00344     if(fDocHandler)
00345         fDocHandler->processingInstruction(target, data);
00346 }
00347 
00348 void SAX2XMLFilterImpl::setDocumentLocator(const Locator* const locator)
00349 {
00350     if(fDocHandler)
00351         fDocHandler->setDocumentLocator(locator);
00352 }
00353 
00354 void SAX2XMLFilterImpl::startDocument()
00355 {
00356     if(fDocHandler)
00357         fDocHandler->startDocument();
00358 }
00359 
00360 void SAX2XMLFilterImpl::startElement(const   XMLCh* const    uri
00361                                    , const   XMLCh* const    localname
00362                                    , const   XMLCh* const    qname
00363                                    , const   Attributes&     attrs)
00364 {
00365     if(fDocHandler)
00366         fDocHandler->startElement(uri, localname, qname, attrs);
00367 }
00368 
00369 void SAX2XMLFilterImpl::startPrefixMapping(const        XMLCh* const    prefix
00370                                         ,  const        XMLCh* const    uri)
00371 {
00372     if(fDocHandler)
00373         fDocHandler->startPrefixMapping(prefix, uri);
00374 }
00375 
00376 void SAX2XMLFilterImpl::endPrefixMapping(const XMLCh* const     prefix)
00377 {
00378     if(fDocHandler)
00379         fDocHandler->endPrefixMapping(prefix);
00380 }
00381 
00382 void SAX2XMLFilterImpl::skippedEntity(const     XMLCh* const    name)
00383 {
00384     if(fDocHandler)
00385         fDocHandler->skippedEntity(name);
00386 }
00387 
00388 // -----------------------------------------------------------------------
00389 //  Implementation of the ErrorHandler interface
00390 // -----------------------------------------------------------------------
00391 
00392 void SAX2XMLFilterImpl::warning(const SAXParseException& exc)
00393 {
00394     if(fErrorHandler)
00395         fErrorHandler->warning(exc);
00396 }
00397 
00398 void SAX2XMLFilterImpl::error(const SAXParseException& exc)
00399 {
00400     if(fErrorHandler)
00401         fErrorHandler->error(exc);
00402 }
00403 
00404 void SAX2XMLFilterImpl::fatalError(const SAXParseException& exc)
00405 {
00406     if(fErrorHandler)
00407         fErrorHandler->fatalError(exc);
00408 }
00409 
00410 void SAX2XMLFilterImpl::resetErrors()
00411 {
00412     if(fErrorHandler)
00413         fErrorHandler->resetErrors();
00414 }
00415 
00416 XERCES_CPP_NAMESPACE_END