Main Page   Class Hierarchy   Compound List   File List   Compound Members  

XMLUri.hpp

00001 /*
00002  * The Apache Software License, Version 1.1
00003  *
00004  * Copyright (c) 2001 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.1 2002/05/11 21:21:10 bhavani Exp $
00059  * $Log: XMLUri.hpp,v $
00060  * Revision 1.1  2002/05/11 21:21:10  bhavani
00061  * CR#CR062582# adding xercesc 1.7 file
00062  *
00063  * Revision 1.2  2002/02/20 18:17:02  tng
00064  * [Bug 5977] Warnings on generating apiDocs.
00065  *
00066  * Revision 1.1.1.1  2002/02/01 22:22:17  peiyongz
00067  * sane_include
00068  *
00069  * Revision 1.3  2001/08/29 19:03:03  peiyongz
00070  * Bugzilla# 2816:on AIX 4.2, xlC 3 r ev.1, Compilation error on inline method
00071  *
00072  * Revision 1.2  2001/08/16 14:09:44  peiyongz
00073  * Removed unused ctors and methods
00074  *
00075  * Revision 1.1  2001/08/10 16:23:41  peiyongz
00076  * XMLUri: creation
00077  *
00078  *
00079  */
00080 
00081 #if !defined(XMLURI_HPP)
00082 #define XMLURI_HPP
00083 
00084 #include <xercesc/util/XercesDefs.hpp>
00085 #include <xercesc/util/XMLException.hpp>
00086 #include <xercesc/util/XMLUniDefs.hpp>
00087 #include <xercesc/util/XMLString.hpp>
00088 
00089 /*
00090  * This class is a direct port of Java's URI class, to distinguish
00091  * itself from the XMLURL, we use the name XMLUri instead of
00092  * XMLURI.
00093  *
00094  * TODO: how to relate XMLUri and XMLURL since URL is part of URI.
00095  *
00096  */
00097 
00098 class XMLUTIL_EXPORT XMLUri
00099 {
00100 public:
00101 
00102     // -----------------------------------------------------------------------
00103     //  Constructors and Destructor
00104     // -----------------------------------------------------------------------
00105 
00131     XMLUri(const XMLCh* const    uriSpec);
00132 
00145     XMLUri(const XMLUri* const     baseURI
00146          , const XMLCh* const      uriSpec);
00147 
00148     virtual ~XMLUri();
00149 
00150     // -----------------------------------------------------------------------
00151     //  Operators
00152     // -----------------------------------------------------------------------
00153 
00154 
00155     // -----------------------------------------------------------------------
00156     //  Getter methods
00157     // -----------------------------------------------------------------------
00158 
00164      const XMLCh* getScheme() const;
00165 
00171      const XMLCh* getUserInfo() const;
00172 
00173 
00179      const XMLCh* getHost() const;
00180 
00186      int getPort() const;
00187 
00194      const XMLCh* getPath() const;
00195 
00203      const XMLCh* getQueryString() const;
00204 
00212      const XMLCh* getFragment() const;
00213 
00214     // -----------------------------------------------------------------------
00215     //  Setter methods
00216     // -----------------------------------------------------------------------
00217 
00225      void setScheme(const XMLCh* const newScheme);
00226 
00234      void setUserInfo(const XMLCh* const newUserInfo);
00235 
00243      void setHost(const XMLCh* const newHost);
00244 
00254      void setPort(int newPort);
00255 
00276      void setPath(const XMLCh* const newPath);
00277 
00286      void setQueryString(const XMLCh* const newQueryString);
00287 
00296      void setFragment(const XMLCh* const newFragment);
00297 
00298      // -----------------------------------------------------------------------
00299     //  Miscellaneous methods
00300     // -----------------------------------------------------------------------
00301 
00302 private:
00303 
00304     static const XMLCh RESERVED_CHARACTERS[];
00305     static const XMLCh MARK_CHARACTERS[];
00306     static const XMLCh SCHEME_CHARACTERS[];
00307     static const XMLCh USERINFO_CHARACTERS[];
00308 
00312     XMLUri(const XMLUri& toCopy);
00313     XMLUri& operator=(const XMLUri& toAssign);
00314 
00315     // -----------------------------------------------------------------------
00316     //  Private helper methods
00317     // -----------------------------------------------------------------------
00318 
00324     static bool isReservedCharacter(const XMLCh theChar);
00325 
00331     static bool isUnreservedCharacter(const XMLCh theChar);
00332 
00340     static bool isConformantSchemeName(const XMLCh* const scheme);
00341 
00347     static void isConformantUserInfo(const XMLCh* const userInfo);
00348 
00356     static bool isURIString(const XMLCh* const uric);
00357 
00372      static bool isWellFormedAddress(const XMLCh* const addr);
00373 
00381      bool isGenericURI();
00382 
00383     // -----------------------------------------------------------------------
00384     //  Miscellaneous methods
00385     // -----------------------------------------------------------------------
00386 
00392      void initialize(const XMLUri& toCopy);
00393 
00408      void initialize(const XMLUri* const baseURI
00409                    , const XMLCh*  const uriSpec);
00410 
00417      void initializeScheme(const XMLCh* const uriSpec);
00418 
00426      void initializeAuthority(const XMLCh* const uriSpec);
00427 
00434      void initializePath(const XMLCh* const uriSpec);
00435 
00436     // -----------------------------------------------------------------------
00437     //  Data members
00438     //
00439     //  for all the data member, we own it,
00440     //  responsible for the creation and/or deletion for
00441     //  the memory allocated.
00442     //
00443     // -----------------------------------------------------------------------
00444 
00445     XMLCh*          fScheme;
00446     XMLCh*          fUserInfo;
00447     XMLCh*          fHost;
00448     int             fPort;
00449     XMLCh*          fPath;
00450     XMLCh*          fQueryString;
00451     XMLCh*          fFragment;
00452 
00453 };
00454 
00455 // ---------------------------------------------------------------------------
00456 //  XMLUri: Public operators
00457 // ---------------------------------------------------------------------------
00458 
00459 // ctor# 2
00460 inline XMLUri::XMLUri(const XMLCh* const uriSpec)
00461 :fScheme(0)
00462 ,fUserInfo(0)
00463 ,fHost(0)
00464 ,fPort(-1)
00465 ,fPath(0)
00466 ,fQueryString(0)
00467 ,fFragment(0)
00468 {
00469     initialize((XMLUri *)0, uriSpec);
00470 }
00471 
00472 // ctor# 7 relative ctor
00473 inline XMLUri::XMLUri(const XMLUri* const      baseURI
00474                     , const XMLCh* const       uriSpec)
00475 :fScheme(0)
00476 ,fUserInfo(0)
00477 ,fHost(0)
00478 ,fPort(-1)
00479 ,fPath(0)
00480 ,fQueryString(0)
00481 ,fFragment(0)
00482 {
00483     initialize(baseURI, uriSpec);
00484 }
00485 
00486 // ---------------------------------------------------------------------------
00487 //  XMLUri: Getter methods
00488 // ---------------------------------------------------------------------------
00489 inline const XMLCh* XMLUri::getScheme() const
00490 {
00491     return fScheme;
00492 }
00493 
00494 inline const XMLCh* XMLUri::getUserInfo() const
00495 {
00496         return fUserInfo;
00497 }
00498 
00499 inline const XMLCh* XMLUri::getHost() const
00500 {
00501         return fHost;
00502 }
00503 
00504 inline int XMLUri::getPort() const
00505 {
00506         return fPort;
00507 }
00508 
00509 inline const XMLCh* XMLUri::getPath() const
00510 {
00511         return fPath;
00512 }
00513 
00514 inline const XMLCh* XMLUri::getQueryString() const
00515 {
00516         return fQueryString;
00517 }
00518 
00519 inline const XMLCh* XMLUri::getFragment() const
00520 {
00521         return fFragment;
00522 }
00523 
00524 // ---------------------------------------------------------------------------
00525 //  XMLUri: Helper methods
00526 // ---------------------------------------------------------------------------
00527 inline bool XMLUri::isReservedCharacter(const XMLCh theChar)
00528 {
00529     return (XMLString::indexOf(RESERVED_CHARACTERS, theChar) != -1);
00530 }
00531 
00532 inline bool XMLUri::isUnreservedCharacter(const XMLCh theChar)
00533 {
00534     return (XMLString::isAlphaNum(theChar) ||
00535             XMLString::indexOf(MARK_CHARACTERS, theChar) != -1);
00536 }
00537 
00538 #endif

Generated on Tue Nov 19 09:36:36 2002 by doxygen1.3-rc1