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  

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.9  2001/11/02 14:21:18  knoaman
00060  * Add support for identity constraints.
00061  *
00062  * Revision 1.8  2001/05/11 13:25:31  tng
00063  * Copyright update.
00064  *
00065  * Revision 1.7  2001/02/27 18:33:55  tng
00066  * Schema: Use QName in XMLAttr.
00067  *
00068  * Revision 1.6  2000/04/10 22:42:53  roddey
00069  * Extended the buffer reuse to the QName field, to further increase
00070  * performance of attribute heavy applications.
00071  *
00072  * Revision 1.5  2000/03/02 19:54:24  roddey
00073  * This checkin includes many changes done while waiting for the
00074  * 1.1.0 code to be finished. I can't list them all here, but a list is
00075  * available elsewhere.
00076  *
00077  * Revision 1.4  2000/02/24 20:00:22  abagchi
00078  * Swat for removing Log from API docs
00079  *
00080  * Revision 1.3  2000/02/15 01:21:30  roddey
00081  * Some initial documentation improvements. More to come...
00082  *
00083  * Revision 1.2  2000/02/06 07:47:47  rahulj
00084  * Year 2K copyright swat.
00085  *
00086  * Revision 1.1.1.1  1999/11/09 01:08:28  twl
00087  * Initial checkin
00088  *
00089  * Revision 1.2  1999/11/08 20:44:35  rahul
00090  * Swat for adding in Product name and CVS comment log variable.
00091  *
00092  */
00093 
00094 #if !defined(XMLATTR_HPP)
00095 #define XMLATTR_HPP
00096 
00097 #include <util/XMLString.hpp>
00098 #include <util/QName.hpp>
00099 #include <framework/XMLAttDef.hpp>
00100 
00101 
00123 class  XMLAttr
00124 {
00125 public:
00126     // -----------------------------------------------------------------------
00127     //  Constructors and Destructor
00128     // -----------------------------------------------------------------------
00131 
00137     XMLAttr();
00138 
00165     XMLAttr
00166     (
00167         const   unsigned int        uriId
00168         , const XMLCh* const        attrName
00169         , const XMLCh* const        attrPrefix
00170         , const XMLCh* const        attrValue
00171         , const XMLAttDef::AttTypes type = XMLAttDef::CData
00172         , const bool                specified = true
00173     );
00175 
00178     ~XMLAttr();
00180 
00181 
00182     // -----------------------------------------------------------------------
00183     //  Getter methods
00184     // -----------------------------------------------------------------------
00185 
00188 
00192     QName* getAttName() const;
00193 
00198     const XMLCh* getName() const;
00199 
00204     const XMLCh* getPrefix() const;
00205 
00211     const XMLCh* getQName() const;
00212 
00217     bool getSpecified() const;
00218 
00223     XMLAttDef::AttTypes getType() const;
00224 
00230     const XMLCh* getValue() const;
00231 
00236     unsigned int getURIId() const;
00237 
00239 
00240 
00241     // -----------------------------------------------------------------------
00242     //  Setter methods
00243     // -----------------------------------------------------------------------
00244 
00247 
00275     void set
00276     (
00277         const   unsigned int        uriId
00278         , const XMLCh* const        attrName
00279         , const XMLCh* const        attrPrefix
00280         , const XMLCh* const        attrValue
00281         , const XMLAttDef::AttTypes type = XMLAttDef::CData
00282     );
00283 
00298     void setName
00299     (
00300         const   unsigned int        uriId
00301         , const XMLCh* const        attrName
00302         , const XMLCh* const        attrPrefix
00303     );
00304 
00312     void setSpecified(const bool newValue);
00313 
00322     void setType(const XMLAttDef::AttTypes newType);
00323 
00331     void setValue(const XMLCh* const newValue);
00332 
00338     void setURIId(const unsigned int uriId);
00339 
00341 
00342 
00343 
00344 private :
00345     // -----------------------------------------------------------------------
00346     //  Unimplemented constructors and operators
00347     // -----------------------------------------------------------------------
00348     XMLAttr(const XMLAttr&);
00349     XMLAttr& operator=(const XMLAttr&);
00350 
00351 
00352     // -----------------------------------------------------------------------
00353     //  Private, helper methods
00354     // -----------------------------------------------------------------------
00355     void cleanUp();
00356 
00357 
00358     // -----------------------------------------------------------------------
00359     //  Private instance variables
00360     //
00361     //  fAttName
00362     //      The Attribute Name;
00363     //
00364     //  fSpecified
00365     //      True if this attribute appeared in the element; else, false if
00366     //      it was defaulted from an AttDef.
00367     //
00368     //  fType
00369     //      The attribute type enum value for this attribute. Indicates what
00370     //      type of attribute it was.
00371     //
00372     //  fValue
00373     //  fValueBufSz
00374     //      The attribute value that was given in the attribute instance, and
00375     //      its current buffer size (minus one, where the null is.)
00376     //
00377     // -----------------------------------------------------------------------
00378     bool                fSpecified;
00379     XMLAttDef::AttTypes fType;
00380     XMLCh*              fValue;
00381     unsigned int        fValueBufSz;
00382     QName*              fAttName;
00383 };
00384 
00385 // ---------------------------------------------------------------------------
00386 //  XMLAttr: Constructors and Destructor
00387 // ---------------------------------------------------------------------------
00388 inline XMLAttr::~XMLAttr()
00389 {
00390     cleanUp();
00391 }
00392 
00393 
00394 // ---------------------------------------------------------------------------
00395 //  XMLAttr: Getter methods
00396 // ---------------------------------------------------------------------------
00397 inline QName* XMLAttr::getAttName() const
00398 {
00399     return fAttName;
00400 }
00401 
00402 inline const XMLCh* XMLAttr::getName() const
00403 {
00404     return fAttName->getLocalPart();
00405 }
00406 
00407 inline const XMLCh* XMLAttr::getPrefix() const
00408 {
00409     return fAttName->getPrefix();
00410 }
00411 
00412 inline bool XMLAttr::getSpecified() const
00413 {
00414     return fSpecified;
00415 }
00416 
00417 inline XMLAttDef::AttTypes XMLAttr::getType() const
00418 {
00419     return fType;
00420 }
00421 
00422 inline const XMLCh* XMLAttr::getValue() const
00423 {
00424     return fValue;
00425 }
00426 
00427 inline unsigned int XMLAttr::getURIId() const
00428 {
00429     return fAttName->getURI();
00430 }
00431 
00432 
00433 // ---------------------------------------------------------------------------
00434 //  XMLAttr: Setter methods
00435 // ---------------------------------------------------------------------------
00436 inline void XMLAttr::set(const  unsigned int        uriId
00437                         , const XMLCh* const        attrName
00438                         , const XMLCh* const        attrPrefix
00439                         , const XMLCh* const        attrValue
00440                         , const XMLAttDef::AttTypes type)
00441 {
00442     // Set the name info and the value via their respective calls
00443     fAttName->setName(attrPrefix, attrName, uriId);
00444     setValue(attrValue);
00445 
00446     // And store the type
00447     fType = type;
00448 }
00449 
00450 inline void XMLAttr::setType(const XMLAttDef::AttTypes newValue)
00451 {
00452     fType = newValue;
00453 }
00454 
00455 inline void XMLAttr::setSpecified(const bool newValue)
00456 {
00457     fSpecified = newValue;
00458 }
00459 
00460 #endif


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