| API Docs for SAX and DOM |

Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members File Members

# XMLUri.hpp

Go to the documentation of this file.

    00001 /*
    00002  * The Apache Software License, Version 1.1
    00003  *
    00004  * Copyright (c) 2001-2003 The Apache Software Foundation.  All rights
    00005  * reserved.
    00006  *
    00007  * Redistribution and use in source and binary forms, with or without
    00008  * modification, are permitted provided that the following conditions
    00009  * are met:
    00010  *
    00011  * 1. Redistributions of source code must retain the above copyright
    00012  *    notice, this list of conditions and the following disclaimer.
    00013  *
    00014  * 2. Redistributions in binary form must reproduce the above copyright
    00015  *    notice, this list of conditions and the following disclaimer in
    00016  *    the documentation and/or other materials provided with the
    00017  *    distribution.
    00018  *
    00019  * 3. The end-user documentation included with the redistribution,
    00020  *    if any, must include the following acknowledgment:
    00021  *       "This product includes software developed by the
    00022  *        Apache Software Foundation (http://www.apache.org/)."
    00023  *    Alternately, this acknowledgment may appear in the software itself,
    00024  *    if and wherever such third-party acknowledgments normally appear.
    00025  *
    00026  * 4. The names "Xerces" and "Apache Software Foundation" must
    00027  *    not be used to endorse or promote products derived from this
    00028  *    software without prior written permission. For written
    00029  *    permission, please contact apache\@apache.org.
    00030  *
    00031  * 5. Products derived from this software may not be called "Apache",
    00032  *    nor may "Apache" appear in their name, without prior written
    00033  *    permission of the Apache Software Foundation.
    00034  *
    00035  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
    00036  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
    00037  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
    00038  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
    00039  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    00040  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    00041  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
    00042  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
    00043  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
    00044  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
    00045  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
    00046  * SUCH DAMAGE.
    00047  * ====================================================================
    00048  *
    00049  * This software consists of voluntary contributions made by many
    00050  * individuals on behalf of the Apache Software Foundation, and was
    00051  * originally based on software copyright (c) 1999, International
    00052  * Business Machines, Inc., http://www.ibm.com .  For more information
    00053  * on the Apache Software Foundation, please see
    00054  * <http://www.apache.org/>.
    00055  */
    00056
    00057 /*
    00058  * $Id: XMLUri.hpp,v 1.9 2003/05/16 06:01:53 knoaman Exp $
    00059  * $Log: XMLUri.hpp,v $
    00060  * Revision 1.9  2003/05/16 06:01:53  knoaman
    00061  * Partial implementation of the configurable memory manager.
    00062  *
    00063  * Revision 1.8  2003/05/15 19:07:46  knoaman
    00064  * Partial implementation of the configurable memory manager.
    00065  *
    00066  * Revision 1.7  2003/01/06 19:43:18  tng
    00067  * New feature StandardUriConformant to force strict standard uri conformance.
    00068  *
    00069  * Revision 1.6  2002/11/21 15:42:39  gareth
    00070  * Implemented copy constructor and operator =. Patch by Jennifer Schachter.
    00071  *
    00072  * Revision 1.5  2002/11/04 15:22:05  tng
    00073  * C++ Namespace Support.
    00074  *
    00075  * Revision 1.4  2002/09/23 18:41:00  tng
    00076  * DOM L3: Support baseURI.   Add fURIText to XMLUri.   Added by Gareth Reakes and Thomas Ford.
    00077  *
    00078  * Revision 1.3  2002/08/23 20:45:24  tng
    00079  * .Memory leak fix: XMLUri data not deleted if constructor failed.
    00080  *
    00081  * Revision 1.2  2002/02/20 18:17:02  tng
    00082  * [Bug 5977] Warnings on generating apiDocs.
    00083  *
    00084  * Revision 1.1.1.1  2002/02/01 22:22:17  peiyongz
    00085  * sane_include
    00086  *
    00087  * Revision 1.3  2001/08/29 19:03:03  peiyongz
    00088  * Bugzilla# 2816:on AIX 4.2, xlC 3 r ev.1, Compilation error on inline method
    00089  *
    00090  * Revision 1.2  2001/08/16 14:09:44  peiyongz
    00091  * Removed unused ctors and methods
    00092  *
    00093  * Revision 1.1  2001/08/10 16:23:41  peiyongz
    00094  * XMLUri: creation
    00095  *
    00096  *
    00097  */
    00098
    00099 #if !defined(XMLURI_HPP)
    00100 #define XMLURI_HPP
    00101
    00102 #include <xercesc/util/XMemory.hpp>
    00103 #include <xercesc/util/XMLString.hpp>
    00104
    00105 XERCES_CPP_NAMESPACE_BEGIN
    00106
    00107 /*
    00108  * This class is a direct port of Java's URI class, to distinguish
    00109  * itself from the XMLURL, we use the name XMLUri instead of
    00110  * XMLURI.
    00111  *
    00112  * TODO: how to relate XMLUri and XMLURL since URL is part of URI.
    00113  *
    00114  */
    00115
    00116  class  XMLUri : public XMemory
    00117 {
    00118 public:
    00119
    00120     // -----------------------------------------------------------------------
    00121     //  Constructors and Destructor
    00122     // -----------------------------------------------------------------------
    00123
    00149     XMLUri(const XMLCh* const    uriSpec,
    00150            MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
    00151
    00164     XMLUri(const XMLUri* const  baseURI
    00165          , const XMLCh* const   uriSpec
    00166          , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
    00167
    00171     XMLUri(const XMLUri& toCopy);
    00172     XMLUri& operator=(const XMLUri& toAssign);
    00173
    00174     virtual ~XMLUri();
    00175
    00176     // -----------------------------------------------------------------------
    00177     //  Getter methods
    00178     // -----------------------------------------------------------------------
    00184     const XMLCh* getUriText() const;
    00185
    00191      const XMLCh* getScheme() const;
    00192
    00198      const XMLCh* getUserInfo() const;
    00199
    00200
    00206      const XMLCh* getHost() const;
    00207
    00213      int getPort() const;
    00214
    00221      const XMLCh* getPath() const;
    00222
    00230      const XMLCh* getQueryString() const;
    00231
    00239      const XMLCh* getFragment() const;
    00240
    00241     // -----------------------------------------------------------------------
    00242     //  Setter methods
    00243     // -----------------------------------------------------------------------
    00244
    00252      void setScheme(const XMLCh* const newScheme);
    00253
    00261      void setUserInfo(const XMLCh* const newUserInfo);
    00262
    00270      void setHost(const XMLCh* const newHost);
    00271
    00281      void setPort(int newPort);
    00282
    00303      void setPath(const XMLCh* const newPath);
    00304
    00313      void setQueryString(const XMLCh* const newQueryString);
    00314
    00323      void setFragment(const XMLCh* const newFragment);
    00324
    00325      // -----------------------------------------------------------------------
    00326     //  Miscellaneous methods
    00327     // -----------------------------------------------------------------------
    00328
    00336     static bool isURIString(const XMLCh* const uric);
    00337
    00338
    00339 private:
    00340
    00341     static const XMLCh RESERVED_CHARACTERS[];
    00342     static const XMLCh MARK_CHARACTERS[];
    00343     static const XMLCh SCHEME_CHARACTERS[];
    00344     static const XMLCh USERINFO_CHARACTERS[];
    00345
    00346     //helper method for getUriText
    00347     void buildFullText();
    00348
    00349     // -----------------------------------------------------------------------
    00350     //  Private helper methods
    00351     // -----------------------------------------------------------------------
    00352
    00358     static bool isReservedCharacter(const XMLCh theChar);
    00359
    00365     static bool isUnreservedCharacter(const XMLCh theChar);
    00366
    00374     static bool isConformantSchemeName(const XMLCh* const scheme);
    00375
    00381     static void isConformantUserInfo(const XMLCh* const userInfo);
    00396      static bool isWellFormedAddress(const XMLCh* const addr);
    00397
    00405      bool isGenericURI();
    00406
    00407     // -----------------------------------------------------------------------
    00408     //  Miscellaneous methods
    00409     // -----------------------------------------------------------------------
    00410
    00416      void initialize(const XMLUri& toCopy);
    00417
    00432      void initialize(const XMLUri* const baseURI
    00433                    , const XMLCh*  const uriSpec);
    00434
    00441      void initializeScheme(const XMLCh* const uriSpec);
    00442
    00450      void initializeAuthority(const XMLCh* const uriSpec);
    00451
    00458      void initializePath(const XMLCh* const uriSpec);
    00459
    00464      void cleanUp();
    00465
    00466     // -----------------------------------------------------------------------
    00467     //  Data members
    00468     //
    00469     //  for all the data member, we own it,
    00470     //  responsible for the creation and/or deletion for
    00471     //  the memory allocated.
    00472     //
    00473     // -----------------------------------------------------------------------
    00474     XMLCh*          fScheme;
    00475     XMLCh*          fUserInfo;
    00476     XMLCh*          fHost;
    00477     int             fPort;
    00478     XMLCh*          fPath;
    00479     XMLCh*          fQueryString;
    00480     XMLCh*          fFragment;
    00481     XMLCh*          fURIText;
    00482     MemoryManager*  fMemoryManager;
    00483 };
    00484
    00485 // ---------------------------------------------------------------------------
    00486 //  XMLUri: Getter methods
    00487 // ---------------------------------------------------------------------------
    00488 inline const XMLCh* XMLUri::getScheme() const
    00489 {
    00490     return fScheme;
    00491 }
    00492
    00493 inline const XMLCh* XMLUri::getUserInfo() const
    00494 {
    00495     return fUserInfo;
    00496 }
    00497
    00498 inline const XMLCh* XMLUri::getHost() const
    00499 {
    00500     return fHost;
    00501 }
    00502
    00503 inline int XMLUri::getPort() const
    00504 {
    00505     return fPort;
    00506 }
    00507
    00508 inline const XMLCh* XMLUri::getPath() const
    00509 {
    00510     return fPath;
    00511 }
    00512
    00513 inline const XMLCh* XMLUri::getQueryString() const
    00514 {
    00515     return fQueryString;
    00516 }
    00517
    00518 inline const XMLCh* XMLUri::getFragment() const
    00519 {
    00520     return fFragment;
    00521 }
    00522
    00523 inline const XMLCh* XMLUri::getUriText() const
    00524 {
    00525     //
    00526     //  Fault it in if not already. Since this is a const method and we
    00527     //  can't use mutable members due the compilers we have to support,
    00528     //  we have to cast off the constness.
    00529     //
    00530     if (!fURIText)
    00531         ((XMLUri*)this)->buildFullText();
    00532
    00533     return fURIText;
    00534 }
    00535
    00536 // ---------------------------------------------------------------------------
    00537 //  XMLUri: Helper methods
    00538 // ---------------------------------------------------------------------------
    00539 inline bool XMLUri::isReservedCharacter(const XMLCh theChar)
    00540 {
    00541     return (XMLString::indexOf(RESERVED_CHARACTERS, theChar) != -1);
    00542 }
    00543
    00544 inline bool XMLUri::isUnreservedCharacter(const XMLCh theChar)
    00545 {
    00546     return (XMLString::isAlphaNum(theChar) ||
    00547             XMLString::indexOf(MARK_CHARACTERS, theChar) != -1);
    00548 }
    00549
    00550 XERCES_CPP_NAMESPACE_END
    00551
    00552 #endif

Copyright © 2000 The Apache Software Foundation. All Rights Reserved.