http://xml.apache.org/http://www.apache.org/http://www.w3.org/

Home

Readme
Download
Installation
Build

API Docs
Samples
Schema

FAQs
Programming
Migration

Releases
Bug-Reporting
Feedback

Y2K Compliance
PDF Document

CVS Repository
Mail Archive

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 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.3 2001/08/29 19:03:03 peiyongz Exp $
00059  * $Log: XMLUri.hpp,v $
00060  * Revision 1.3  2001/08/29 19:03:03  peiyongz
00061  * Bugzilla# 2816:on AIX 4.2, xlC 3 r ev.1, Compilation error on inline method
00062  *
00063  * Revision 1.2  2001/08/16 14:09:44  peiyongz
00064  * Removed unused ctors and methods
00065  *
00066  * Revision 1.1  2001/08/10 16:23:41  peiyongz
00067  * XMLUri: creation
00068  *
00069  *
00070  */
00071 
00072 #if !defined(XMLURI_HPP)
00073 #define XMLURI_HPP
00074 
00075 #include <util/XercesDefs.hpp>
00076 #include <util/XMLException.hpp>
00077 #include <util/XMLUniDefs.hpp>
00078 #include <util/XMLString.hpp>
00079 
00080 /*
00081  * This class is a direct port of Java's URI class, to distinguish 
00082  * itself from the XMLURL, we use the name XMLUri instead of 
00083  * XMLURI.
00084  * 
00085  * TODO: how to relate XMLUri and XMLURL since URL is part of URI.
00086  *
00087  */
00088 
00089 class  XMLUri
00090 {
00091 public:
00092 
00093     // -----------------------------------------------------------------------
00094     //  Constructors and Destructor
00095     // -----------------------------------------------------------------------
00096 
00122     XMLUri(const XMLCh* const    uriSpec);
00123 
00136     XMLUri(const XMLUri* const     baseURI
00137          , const XMLCh* const      uriSpec);
00138 
00139     virtual ~XMLUri();
00140 
00141     // -----------------------------------------------------------------------
00142     //  Operators
00143     // -----------------------------------------------------------------------
00144 
00145 
00146     // -----------------------------------------------------------------------
00147     //  Getter methods
00148     // -----------------------------------------------------------------------
00149 
00155      const XMLCh* getScheme() const;
00156  
00162      const XMLCh* getUserInfo() const;
00163 
00164 
00170      const XMLCh* getHost() const;
00171 
00177      int getPort() const;
00178 
00185      const XMLCh* getPath() const;
00186 
00194      const XMLCh* getQueryString() const;
00195 
00203      const XMLCh* getFragment() const;
00204 
00205     // -----------------------------------------------------------------------
00206     //  Setter methods
00207     // -----------------------------------------------------------------------
00208  
00216      void setScheme(const XMLCh* const newScheme);
00217 
00225      void setUserInfo(const XMLCh* const newUserInfo);
00226 
00234      void setHost(const XMLCh* const newHost);
00235 
00245      void setPort(int newPort);
00246   
00267      void setPath(const XMLCh* const newPath);
00268 
00277      void setQueryString(const XMLCh* const newQueryString);
00278 
00287      void setFragment(const XMLCh* const newFragment);
00288 
00289      // -----------------------------------------------------------------------
00290     //  Miscellaneous methods
00291     // -----------------------------------------------------------------------
00292 
00293 private:
00294 
00295     static const XMLCh RESERVED_CHARACTERS[];
00296     static const XMLCh MARK_CHARACTERS[];
00297     static const XMLCh SCHEME_CHARACTERS[];
00298     static const XMLCh USERINFO_CHARACTERS[];
00299 
00303     XMLUri(const XMLUri& toCopy);    
00304     XMLUri& operator=(const XMLUri& toAssign);
00305 
00306     // -----------------------------------------------------------------------
00307     //  Private helper methods
00308     // -----------------------------------------------------------------------
00309 
00315     static bool isReservedCharacter(const XMLCh theChar);
00316 
00322     static bool isUnreservedCharacter(const XMLCh theChar);
00323 
00331     static bool isConformantSchemeName(const XMLCh* const scheme);
00332 
00338     static void isConformantUserInfo(const XMLCh* const userInfo);
00339 
00347     static bool isURIString(const XMLCh* const uric);
00348 
00363      static bool isWellFormedAddress(const XMLCh* const addr);
00364 
00372      bool isGenericURI();
00373 
00374     // -----------------------------------------------------------------------
00375     //  Miscellaneous methods
00376     // -----------------------------------------------------------------------
00377 
00383      void initialize(const XMLUri& toCopy);
00384 
00399      void initialize(const XMLUri* const baseURI
00400                    , const XMLCh*  const uriSpec);
00401 
00408      void initializeScheme(const XMLCh* const uriSpec);
00409                  
00417      void initializeAuthority(const XMLCh* const uriSpec);
00418 
00425      void initializePath(const XMLCh* const uriSpec);
00426 
00427     // -----------------------------------------------------------------------
00428     //  Data members
00429     //
00430     //  for all the data member, we own it, 
00431     //  responsible for the creation and/or deletion for
00432     //  the memory allocated.
00433     //
00434     // -----------------------------------------------------------------------
00435 
00436     XMLCh*          fScheme;
00437     XMLCh*          fUserInfo;
00438     XMLCh*          fHost;
00439     int             fPort;
00440     XMLCh*          fPath;
00441     XMLCh*          fQueryString;
00442     XMLCh*          fFragment;
00443     
00444 };
00445 
00446 // ---------------------------------------------------------------------------
00447 //  XMLUri: Public operators
00448 // ---------------------------------------------------------------------------
00449 
00450 // ctor# 2
00451 inline XMLUri::XMLUri(const XMLCh* const uriSpec)
00452 :fScheme(0)
00453 ,fUserInfo(0)
00454 ,fHost(0)
00455 ,fPort(-1)
00456 ,fPath(0)
00457 ,fQueryString(0)
00458 ,fFragment(0)
00459 {
00460     initialize((XMLUri *)0, uriSpec);
00461 }
00462 
00463 // ctor# 7 relative ctor
00464 inline XMLUri::XMLUri(const XMLUri* const      baseURI
00465                     , const XMLCh* const       uriSpec)
00466 :fScheme(0)
00467 ,fUserInfo(0)
00468 ,fHost(0)
00469 ,fPort(-1)
00470 ,fPath(0)
00471 ,fQueryString(0)
00472 ,fFragment(0)
00473 {
00474     initialize(baseURI, uriSpec);
00475 }  
00476 
00477 // ---------------------------------------------------------------------------
00478 //  XMLUri: Getter methods
00479 // ---------------------------------------------------------------------------
00480 inline const XMLCh* XMLUri::getScheme() const
00481 {
00482     return fScheme;
00483 }
00484 
00485 inline const XMLCh* XMLUri::getUserInfo() const
00486 {
00487     return fUserInfo;
00488 }
00489 
00490 inline const XMLCh* XMLUri::getHost() const
00491 {
00492     return fHost;
00493 }
00494 
00495 inline int XMLUri::getPort() const
00496 {
00497     return fPort;
00498 }
00499 
00500 inline const XMLCh* XMLUri::getPath() const
00501 {
00502     return fPath;
00503 }
00504 
00505 inline const XMLCh* XMLUri::getQueryString() const
00506 {
00507     return fQueryString;
00508 }
00509 
00510 inline const XMLCh* XMLUri::getFragment() const
00511 {
00512     return fFragment;
00513 }
00514 
00515 // ---------------------------------------------------------------------------
00516 //  XMLUri: Helper methods
00517 // ---------------------------------------------------------------------------
00518 inline bool XMLUri::isReservedCharacter(const XMLCh theChar)
00519 {
00520     return (XMLString::indexOf(RESERVED_CHARACTERS, theChar) != -1);
00521 }  
00522 
00523 inline bool XMLUri::isUnreservedCharacter(const XMLCh theChar)
00524 {
00525     return (XMLString::isAlphaNum(theChar) ||
00526             XMLString::indexOf(MARK_CHARACTERS, theChar) != -1);
00527 }  
00528 
00529 #endif


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