www.alphaworks.ibm.comwww.ibm.com/developerwww.ibm.com

Home

Readme
Download

Build







Migration

Releases

Feedback

Y2K Compliance


CVS Repository
Mail Archive

API Docs for SAX and DOM
 

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

XMLAttr.hpp

Go to the documentation of this file.
00001 /*
00002  * The Apache Software License, Version 1.1
00003  *
00004  * Copyright (c) 1999-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  * $Log: XMLAttr.hpp,v $
00059  * Revision 1.8  2001/05/11 13:25:31  tng
00060  * Copyright update.
00061  *
00062  * Revision 1.7  2001/02/27 18:33:55  tng
00063  * Schema: Use QName in XMLAttr.
00064  *
00065  * Revision 1.6  2000/04/10 22:42:53  roddey
00066  * Extended the buffer reuse to the QName field, to further increase
00067  * performance of attribute heavy applications.
00068  *
00069  * Revision 1.5  2000/03/02 19:54:24  roddey
00070  * This checkin includes many changes done while waiting for the
00071  * 1.1.0 code to be finished. I can't list them all here, but a list is
00072  * available elsewhere.
00073  *
00074  * Revision 1.4  2000/02/24 20:00:22  abagchi
00075  * Swat for removing Log from API docs
00076  *
00077  * Revision 1.3  2000/02/15 01:21:30  roddey
00078  * Some initial documentation improvements. More to come...
00079  *
00080  * Revision 1.2  2000/02/06 07:47:47  rahulj
00081  * Year 2K copyright swat.
00082  *
00083  * Revision 1.1.1.1  1999/11/09 01:08:28  twl
00084  * Initial checkin
00085  *
00086  * Revision 1.2  1999/11/08 20:44:35  rahul
00087  * Swat for adding in Product name and CVS comment log variable.
00088  *
00089  */
00090 
00091 #if !defined(XMLATTR_HPP)
00092 #define XMLATTR_HPP
00093 
00094 #include <util/XMLString.hpp>
00095 #include <util/QName.hpp>
00096 #include <framework/XMLAttDef.hpp>
00097 
00098 
00120 class  XMLAttr
00121 {
00122 public:
00123     // -----------------------------------------------------------------------
00124     //  Constructors and Destructor
00125     // -----------------------------------------------------------------------
00128 
00134     XMLAttr();
00135 
00162     XMLAttr
00163     (
00164         const   unsigned int        uriId
00165         , const XMLCh* const        attrName
00166         , const XMLCh* const        attrPrefix
00167         , const XMLCh* const        attrValue
00168         , const XMLAttDef::AttTypes type = XMLAttDef::CData
00169         , const bool                specified = true
00170     );
00172 
00175     ~XMLAttr();
00177 
00178 
00179     // -----------------------------------------------------------------------
00180     //  Getter methods
00181     // -----------------------------------------------------------------------
00182 
00185 
00190     const XMLCh* getName() const;
00191 
00196     const XMLCh* getPrefix() const;
00197 
00203     const XMLCh* getQName() const;
00204 
00209     bool getSpecified() const;
00210 
00215     XMLAttDef::AttTypes getType() const;
00216 
00222     const XMLCh* getValue() const;
00223 
00228     unsigned int getURIId() const;
00229 
00231 
00232 
00233     // -----------------------------------------------------------------------
00234     //  Setter methods
00235     // -----------------------------------------------------------------------
00236 
00239 
00267     void set
00268     (
00269         const   unsigned int        uriId
00270         , const XMLCh* const        attrName
00271         , const XMLCh* const        attrPrefix
00272         , const XMLCh* const        attrValue
00273         , const XMLAttDef::AttTypes type = XMLAttDef::CData
00274     );
00275 
00290     void setName
00291     (
00292         const   unsigned int        uriId
00293         , const XMLCh* const        attrName
00294         , const XMLCh* const        attrPrefix
00295     );
00296 
00304     void setSpecified(const bool newValue);
00305 
00314     void setType(const XMLAttDef::AttTypes newType);
00315 
00323     void setValue(const XMLCh* const newValue);
00324 
00330     void setURIId(const unsigned int uriId);
00331 
00333 
00334 
00335 
00336 private :
00337     // -----------------------------------------------------------------------
00338     //  Unimplemented constructors and operators
00339     // -----------------------------------------------------------------------
00340     XMLAttr(const XMLAttr&);
00341     XMLAttr& operator=(const XMLAttr&);
00342 
00343 
00344     // -----------------------------------------------------------------------
00345     //  Private, helper methods
00346     // -----------------------------------------------------------------------
00347     void cleanUp();
00348 
00349 
00350     // -----------------------------------------------------------------------
00351     //  Private instance variables
00352     //
00353     //  fAttName
00354     //      The Attribute Name;
00355     //
00356     //  fSpecified
00357     //      True if this attribute appeared in the element; else, false if
00358     //      it was defaulted from an AttDef.
00359     //
00360     //  fType
00361     //      The attribute type enum value for this attribute. Indicates what
00362     //      type of attribute it was.
00363     //
00364     //  fValue
00365     //  fValueBufSz
00366     //      The attribute value that was given in the attribute instance, and
00367     //      its current buffer size (minus one, where the null is.)
00368     //
00369     // -----------------------------------------------------------------------
00370     bool                fSpecified;
00371     XMLAttDef::AttTypes fType;
00372     XMLCh*              fValue;
00373     unsigned int        fValueBufSz;
00374     QName*              fAttName;
00375 };
00376 
00377 // ---------------------------------------------------------------------------
00378 //  XMLAttr: Constructors and Destructor
00379 // ---------------------------------------------------------------------------
00380 inline XMLAttr::~XMLAttr()
00381 {
00382     cleanUp();
00383 }
00384 
00385 
00386 // ---------------------------------------------------------------------------
00387 //  XMLAttr: Getter methods
00388 // ---------------------------------------------------------------------------
00389 inline const XMLCh* XMLAttr::getName() const
00390 {
00391     return fAttName->getLocalPart();
00392 }
00393 
00394 inline const XMLCh* XMLAttr::getPrefix() const
00395 {
00396     return fAttName->getPrefix();
00397 }
00398 
00399 inline bool XMLAttr::getSpecified() const
00400 {
00401     return fSpecified;
00402 }
00403 
00404 inline XMLAttDef::AttTypes XMLAttr::getType() const
00405 {
00406     return fType;
00407 }
00408 
00409 inline const XMLCh* XMLAttr::getValue() const
00410 {
00411     return fValue;
00412 }
00413 
00414 inline unsigned int XMLAttr::getURIId() const
00415 {
00416     return fAttName->getURI();
00417 }
00418 
00419 
00420 // ---------------------------------------------------------------------------
00421 //  XMLAttr: Setter methods
00422 // ---------------------------------------------------------------------------
00423 inline void XMLAttr::set(const  unsigned int        uriId
00424                         , const XMLCh* const        attrName
00425                         , const XMLCh* const        attrPrefix
00426                         , const XMLCh* const        attrValue
00427                         , const XMLAttDef::AttTypes type)
00428 {
00429     // Set the name info and the value via their respective calls
00430     fAttName->setName(attrPrefix, attrName, uriId);
00431     setValue(attrValue);
00432 
00433     // And store the type
00434     fType = type;
00435 }
00436 
00437 inline void XMLAttr::setType(const XMLAttDef::AttTypes newValue)
00438 {
00439     fType = newValue;
00440 }
00441 
00442 inline void XMLAttr::setSpecified(const bool newValue)
00443 {
00444     fSpecified = newValue;
00445 }
00446 
00447 #endif


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