| 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  * Copyright 1999-2004 The Apache Software Foundation.
    00003  *
    00004  * Licensed under the Apache License, Version 2.0 (the "License");
    00005  * you may not use this file except in compliance with the License.
    00006  * You may obtain a copy of the License at
    00007  *
    00008  *      http://www.apache.org/licenses/LICENSE-2.0
    00009  *
    00010  * Unless required by applicable law or agreed to in writing, software
    00011  * distributed under the License is distributed on an "AS IS" BASIS,
    00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    00013  * See the License for the specific language governing permissions and
    00014  * limitations under the License.
    00015  */
    00016
    00017 /*
    00018  * $Log: XMLAttr.hpp,v $
    00019  * Revision 1.11  2004/09/20 14:47:13  amassari
    00020  * Mark some methods as deprecated
    00021  *
    00022  * Revision 1.10  2004/09/08 13:55:58  peiyongz
    00023  * Apache License Version 2.0
    00024  *
    00025  * Revision 1.9  2003/12/17 00:18:33  cargilld
    00026  * Update to memory management so that the static memory manager (one used to call Initialize) is only for static data.
    00027  *
    00028  * Revision 1.8  2003/11/24 05:19:37  neilg
    00029  * update XMLAttr class to carry information needed by DOMTypeInfo
    00030  *
    00031  * Revision 1.7  2003/05/22 02:10:51  knoaman
    00032  * Default the memory manager.
    00033  *
    00034  * Revision 1.6  2003/05/16 21:36:55  knoaman
    00035  * Memory manager implementation: Modify constructors to pass in the memory manager.
    00036  *
    00037  * Revision 1.5  2003/05/15 18:26:07  knoaman
    00038  * Partial implementation of the configurable memory manager.
    00039  *
    00040  * Revision 1.4  2002/11/28 20:12:45  knoaman
    00041  * Allow creating/setting of XMLAttr using a rawname (i.e. 'prefix:localpart').
    00042  *
    00043  * Revision 1.3  2002/11/04 15:00:21  tng
    00044  * C++ Namespace Support.
    00045  *
    00046  * Revision 1.2  2002/02/20 18:17:01  tng
    00047  * [Bug 5977] Warnings on generating apiDocs.
    00048  *
    00049  * Revision 1.1.1.1  2002/02/01 22:21:50  peiyongz
    00050  * sane_include
    00051  *
    00052  * Revision 1.9  2001/11/02 14:21:18  knoaman
    00053  * Add support for identity constraints.
    00054  *
    00055  * Revision 1.8  2001/05/11 13:25:31  tng
    00056  * Copyright update.
    00057  *
    00058  * Revision 1.7  2001/02/27 18:33:55  tng
    00059  * Schema: Use QName in XMLAttr.
    00060  *
    00061  * Revision 1.6  2000/04/10 22:42:53  roddey
    00062  * Extended the buffer reuse to the QName field, to further increase
    00063  * performance of attribute heavy applications.
    00064  *
    00065  * Revision 1.5  2000/03/02 19:54:24  roddey
    00066  * This checkin includes many changes done while waiting for the
    00067  * 1.1.0 code to be finished. I can't list them all here, but a list is
    00068  * available elsewhere.
    00069  *
    00070  * Revision 1.4  2000/02/24 20:00:22  abagchi
    00071  * Swat for removing Log from API docs
    00072  *
    00073  * Revision 1.3  2000/02/15 01:21:30  roddey
    00074  * Some initial documentation improvements. More to come...
    00075  *
    00076  * Revision 1.2  2000/02/06 07:47:47  rahulj
    00077  * Year 2K copyright swat.
    00078  *
    00079  * Revision 1.1.1.1  1999/11/09 01:08:28  twl
    00080  * Initial checkin
    00081  *
    00082  * Revision 1.2  1999/11/08 20:44:35  rahul
    00083  * Swat for adding in Product name and CVS comment log variable.
    00084  *
    00085  */
    00086
    00087 #if !defined(XMLATTR_HPP)
    00088 #define XMLATTR_HPP
    00089
    00090 #include <xercesc/util/PlatformUtils.hpp>
    00091 #include <xercesc/util/QName.hpp>
    00092 #include <xercesc/framework/XMLAttDef.hpp>
    00093 #include <xercesc/validators/datatype/DatatypeValidator.hpp>
    00094
    00095 XERCES_CPP_NAMESPACE_BEGIN
    00096
    00118 class  XMLAttr : public XMemory
    00119 {
    00120 public:
    00121     // -----------------------------------------------------------------------
    00122     //  Constructors and Destructor
    00123     // -----------------------------------------------------------------------
    00126
    00134     XMLAttr(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
    00135
    00168     XMLAttr
    00169     (
    00170           const unsigned int        uriId
    00171         , const XMLCh* const        attrName
    00172         , const XMLCh* const        attrPrefix
    00173         , const XMLCh* const        attrValue
    00174         , const XMLAttDef::AttTypes type = XMLAttDef::CData
    00175         , const bool                specified = true
    00176         , MemoryManager* const      manager = XMLPlatformUtils::fgMemoryManager
    00177         , DatatypeValidator * datatypeValidator = 0
    00178         , const bool isSchema = false
    00179     );
    00180
    00209     XMLAttr
    00210     (
    00211         const unsigned int uriId
    00212         , const XMLCh* const rawName
    00213         , const XMLCh* const attrValue
    00214         , const XMLAttDef::AttTypes type = XMLAttDef::CData
    00215         , const bool specified = true
    00216         , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
    00217         , DatatypeValidator * datatypeValidator = 0
    00218         , const bool isSchema = false
    00219     );
    00220
    00222
    00225     ~XMLAttr();
    00227
    00228
    00229     // -----------------------------------------------------------------------
    00230     //  Getter methods
    00231     // -----------------------------------------------------------------------
    00232
    00235
    00239     QName* getAttName() const;
    00240
    00245     const XMLCh* getName() const;
    00246
    00251     const XMLCh* getPrefix() const;
    00252
    00258     const XMLCh* getQName() const;
    00259
    00264     bool getSpecified() const;
    00265
    00270     XMLAttDef::AttTypes getType() const;
    00271
    00277     const XMLCh* getValue() const;
    00278
    00283     unsigned int getURIId() const;
    00284
    00289     const XMLCh* getValidatingTypeURI() const;
    00290
    00295     const XMLCh* getValidatingTypeName() const;
    00296
    00298
    00299
    00300     // -----------------------------------------------------------------------
    00301     //  Setter methods
    00302     // -----------------------------------------------------------------------
    00303
    00306
    00335     void set
    00336     (
    00337         const   unsigned int        uriId
    00338         , const XMLCh* const        attrName
    00339         , const XMLCh* const        attrPrefix
    00340         , const XMLCh* const        attrValue
    00341         , const XMLAttDef::AttTypes type = XMLAttDef::CData
    00342         , DatatypeValidator * datatypeValidator = 0
    00343         , const bool isSchema = false
    00344     );
    00345
    00369     void set
    00370     (
    00371         const   unsigned int        uriId
    00372         , const XMLCh* const        attrRawName
    00373         , const XMLCh* const        attrValue
    00374         , const XMLAttDef::AttTypes type = XMLAttDef::CData
    00375         , DatatypeValidator * datatypeValidator = 0
    00376         , const bool isSchema = false
    00377     );
    00378
    00393     void setName
    00394     (
    00395         const   unsigned int        uriId
    00396         , const XMLCh* const        attrName
    00397         , const XMLCh* const        attrPrefix
    00398     );
    00399
    00407     void setSpecified(const bool newValue);
    00408
    00417     void setType(const XMLAttDef::AttTypes newType);
    00418
    00426     void setValue(const XMLCh* const newValue);
    00427
    00435     void setURIId(const unsigned int uriId);
    00436
    00444     void setDatatypeValidator(DatatypeValidator * datatypeValidator);
    00445
    00453     void setSchemaValidated(const bool isSchema);
    00454
    00456
    00457
    00458
    00459 private :
    00460     // -----------------------------------------------------------------------
    00461     //  Unimplemented constructors and operators
    00462     // -----------------------------------------------------------------------
    00463     XMLAttr(const XMLAttr&);
    00464     XMLAttr& operator=(const XMLAttr&);
    00465
    00466
    00467     // -----------------------------------------------------------------------
    00468     //  Private, helper methods
    00469     // -----------------------------------------------------------------------
    00470     void cleanUp();
    00471
    00472
    00473     // -----------------------------------------------------------------------
    00474     //  Private instance variables
    00475     //
    00476     //  fAttName
    00477     //      The Attribute Name;
    00478     //
    00479     //  fSpecified
    00480     //      True if this attribute appeared in the element; else, false if
    00481     //      it was defaulted from an AttDef.
    00482     //
    00483     //  fType
    00484     //      The attribute type enum value for this attribute. Indicates what
    00485     //      type of attribute it was.
    00486     //
    00487     //  fValue
    00488     //  fValueBufSz
    00489     //      The attribute value that was given in the attribute instance, and
    00490     //      its current buffer size (minus one, where the null is.)
    00491     //
    00492     //  fMemoryManager
    00493     //      The memory manager used for dynamic memory allocation/deallocation
    00494     //  fDatatypeValidator
    00495     //      The validator used to validate the value of this attribute.
    00496     //      The attribute does not own this object, and it is only
    00497     //      used in the calculation of DOMTypeInfo information.
    00498     //  fIsSchemaValidated
    00499     //      whether this attribute was validated by an XML Schema
    00500     //
    00501     // -----------------------------------------------------------------------
    00502     bool                fSpecified;
    00503     XMLAttDef::AttTypes fType;
    00504     unsigned int        fValueBufSz;
    00505     XMLCh*              fValue;
    00506     QName*              fAttName;
    00507     MemoryManager*      fMemoryManager;
    00508     DatatypeValidator * fDatatypeValidator;
    00509     bool                fIsSchemaValidated;
    00510 };
    00511
    00512 // ---------------------------------------------------------------------------
    00513 //  XMLAttr: Constructors and Destructor
    00514 // ---------------------------------------------------------------------------
    00515 inline XMLAttr::~XMLAttr()
    00516 {
    00517     cleanUp();
    00518 }
    00519
    00520
    00521 // ---------------------------------------------------------------------------
    00522 //  XMLAttr: Getter methods
    00523 // ---------------------------------------------------------------------------
    00524 inline QName* XMLAttr::getAttName() const
    00525 {
    00526     return fAttName;
    00527 }
    00528
    00529 inline const XMLCh* XMLAttr::getName() const
    00530 {
    00531     return fAttName->getLocalPart();
    00532 }
    00533
    00534 inline const XMLCh* XMLAttr::getPrefix() const
    00535 {
    00536     return fAttName->getPrefix();
    00537 }
    00538
    00539 inline bool XMLAttr::getSpecified() const
    00540 {
    00541     return fSpecified;
    00542 }
    00543
    00544 inline XMLAttDef::AttTypes XMLAttr::getType() const
    00545 {
    00546     return fType;
    00547 }
    00548
    00549 inline const XMLCh* XMLAttr::getValue() const
    00550 {
    00551     return fValue;
    00552 }
    00553
    00554 inline unsigned int XMLAttr::getURIId() const
    00555 {
    00556     return fAttName->getURI();
    00557 }
    00558
    00559 inline const XMLCh* XMLAttr::getValidatingTypeName() const
    00560 {
    00561     if(fIsSchemaValidated)
    00562     {
    00563         if(!fDatatypeValidator || fDatatypeValidator->getAnonymous())
    00564             return 0;
    00565         return fDatatypeValidator->getTypeLocalName();
    00566     }
    00567     else
    00568     {
    00569         return XMLAttDef::getAttTypeString(fType, fMemoryManager);
    00570     }
    00571 }
    00572
    00573 inline const XMLCh* XMLAttr::getValidatingTypeURI() const
    00574 {
    00575     if(fIsSchemaValidated)
    00576     {
    00577         if(!fDatatypeValidator || fDatatypeValidator->getAnonymous())
    00578             return 0;
    00579         return fDatatypeValidator->getTypeUri();
    00580     }
    00581     else
    00582     {
    00583         return 0;
    00584     }
    00585 }
    00586
    00587 // ---------------------------------------------------------------------------
    00588 //  XMLAttr: Setter methods
    00589 // ---------------------------------------------------------------------------
    00590 inline void XMLAttr::set(const  unsigned int        uriId
    00591                         , const XMLCh* const        attrName
    00592                         , const XMLCh* const        attrPrefix
    00593                         , const XMLCh* const        attrValue
    00594                         , const XMLAttDef::AttTypes type
    00595                         , DatatypeValidator * datatypeValidator
    00596                         , const bool isSchema )
    00597 {
    00598     // Set the name info and the value via their respective calls
    00599     fAttName->setName(attrPrefix, attrName, uriId);
    00600     setValue(attrValue);
    00601
    00602     // And store the type
    00603     fType = type;
    00604
    00605     // and set up info for DOM type info
    00606     fIsSchemaValidated = isSchema;
    00607     fDatatypeValidator = datatypeValidator;
    00608 }
    00609
    00610 inline void XMLAttr::set(const  unsigned int        uriId
    00611                         , const XMLCh* const        attrRawName
    00612                         , const XMLCh* const        attrValue
    00613                         , const XMLAttDef::AttTypes type
    00614                         , DatatypeValidator * datatypeValidator
    00615                         , const bool isSchema )
    00616 {
    00617     // Set the name info and the value via their respective calls
    00618     fAttName->setName(attrRawName, uriId);
    00619     setValue(attrValue);
    00620
    00621     // And store the type
    00622     fType = type;
    00623
    00624     // and set up info for DOM type info
    00625     fIsSchemaValidated = isSchema;
    00626     fDatatypeValidator = datatypeValidator;
    00627 }
    00628
    00629 inline void XMLAttr::setType(const XMLAttDef::AttTypes newValue)
    00630 {
    00631     fType = newValue;
    00632 }
    00633
    00634 inline void XMLAttr::setSpecified(const bool newValue)
    00635 {
    00636     fSpecified = newValue;
    00637 }
    00638
    00639 inline void XMLAttr::setDatatypeValidator(DatatypeValidator *datatypeValidator)
    00640 {
    00641     fDatatypeValidator = datatypeValidator;
    00642 }
    00643
    00644 inline void XMLAttr::setSchemaValidated(const bool isSchema)
    00645 {
    00646     fIsSchemaValidated = isSchema;
    00647 }
    00648
    00649 XERCES_CPP_NAMESPACE_END
    00650
    00651 #endif

Copyright © 1994-2004 The Apache Software Foundation. All Rights Reserved.