| API Docs for SAX and DOM |
| Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages # 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  * $Id: XMLAttr.hpp 191054 2005-06-17 02:56:35Z jberry $
    00019  */
    00020
    00021 #if !defined(XMLATTR_HPP)
    00022 #define XMLATTR_HPP
    00023
    00024 #include <xercesc/util/PlatformUtils.hpp>
    00025 #include <xercesc/util/QName.hpp>
    00026 #include <xercesc/framework/XMLAttDef.hpp>
    00027 #include <xercesc/validators/datatype/DatatypeValidator.hpp>
    00028
    00029 XERCES_CPP_NAMESPACE_BEGIN
    00030
    00052 class  XMLAttr : public XMemory
    00053 {
    00054 public:
    00055     // -----------------------------------------------------------------------
    00056     //  Constructors and Destructor
    00057     // -----------------------------------------------------------------------
    00060
    00068     XMLAttr(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
    00069
    00102     XMLAttr
    00103     (
    00104           const unsigned int        uriId
    00105         , const XMLCh* const        attrName
    00106         , const XMLCh* const        attrPrefix
    00107         , const XMLCh* const        attrValue
    00108         , const XMLAttDef::AttTypes type = XMLAttDef::CData
    00109         , const bool                specified = true
    00110         , MemoryManager* const      manager = XMLPlatformUtils::fgMemoryManager
    00111         , DatatypeValidator * datatypeValidator = 0
    00112         , const bool isSchema = false
    00113     );
    00114
    00143     XMLAttr
    00144     (
    00145         const unsigned int uriId
    00146         , const XMLCh* const rawName
    00147         , const XMLCh* const attrValue
    00148         , const XMLAttDef::AttTypes type = XMLAttDef::CData
    00149         , const bool specified = true
    00150         , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
    00151         , DatatypeValidator * datatypeValidator = 0
    00152         , const bool isSchema = false
    00153     );
    00154
    00156
    00159     ~XMLAttr();
    00161
    00162
    00163     // -----------------------------------------------------------------------
    00164     //  Getter methods
    00165     // -----------------------------------------------------------------------
    00166
    00169
    00173     QName* getAttName() const;
    00174
    00179     const XMLCh* getName() const;
    00180
    00185     const XMLCh* getPrefix() const;
    00186
    00192     const XMLCh* getQName() const;
    00193
    00198     bool getSpecified() const;
    00199
    00204     XMLAttDef::AttTypes getType() const;
    00205
    00211     const XMLCh* getValue() const;
    00212
    00217     unsigned int getURIId() const;
    00218
    00223     const XMLCh* getValidatingTypeURI() const;
    00224
    00229     const XMLCh* getValidatingTypeName() const;
    00230
    00232
    00233
    00234     // -----------------------------------------------------------------------
    00235     //  Setter methods
    00236     // -----------------------------------------------------------------------
    00237
    00240
    00269     void set
    00270     (
    00271         const   unsigned int        uriId
    00272         , const XMLCh* const        attrName
    00273         , const XMLCh* const        attrPrefix
    00274         , const XMLCh* const        attrValue
    00275         , const XMLAttDef::AttTypes type = XMLAttDef::CData
    00276         , DatatypeValidator * datatypeValidator = 0
    00277         , const bool isSchema = false
    00278     );
    00279
    00303     void set
    00304     (
    00305         const   unsigned int        uriId
    00306         , const XMLCh* const        attrRawName
    00307         , const XMLCh* const        attrValue
    00308         , const XMLAttDef::AttTypes type = XMLAttDef::CData
    00309         , DatatypeValidator * datatypeValidator = 0
    00310         , const bool isSchema = false
    00311     );
    00312
    00327     void setName
    00328     (
    00329         const   unsigned int        uriId
    00330         , const XMLCh* const        attrName
    00331         , const XMLCh* const        attrPrefix
    00332     );
    00333
    00341     void setSpecified(const bool newValue);
    00342
    00351     void setType(const XMLAttDef::AttTypes newType);
    00352
    00360     void setValue(const XMLCh* const newValue);
    00361
    00369     void setURIId(const unsigned int uriId);
    00370
    00378     void setDatatypeValidator(DatatypeValidator * datatypeValidator);
    00379
    00387     void setSchemaValidated(const bool isSchema);
    00388
    00390
    00391
    00392
    00393 private :
    00394     // -----------------------------------------------------------------------
    00395     //  Unimplemented constructors and operators
    00396     // -----------------------------------------------------------------------
    00397     XMLAttr(const XMLAttr&);
    00398     XMLAttr& operator=(const XMLAttr&);
    00399
    00400
    00401     // -----------------------------------------------------------------------
    00402     //  Private, helper methods
    00403     // -----------------------------------------------------------------------
    00404     void cleanUp();
    00405
    00406
    00407     // -----------------------------------------------------------------------
    00408     //  Private instance variables
    00409     //
    00410     //  fAttName
    00411     //      The Attribute Name;
    00412     //
    00413     //  fSpecified
    00414     //      True if this attribute appeared in the element; else, false if
    00415     //      it was defaulted from an AttDef.
    00416     //
    00417     //  fType
    00418     //      The attribute type enum value for this attribute. Indicates what
    00419     //      type of attribute it was.
    00420     //
    00421     //  fValue
    00422     //  fValueBufSz
    00423     //      The attribute value that was given in the attribute instance, and
    00424     //      its current buffer size (minus one, where the null is.)
    00425     //
    00426     //  fMemoryManager
    00427     //      The memory manager used for dynamic memory allocation/deallocation
    00428     //  fDatatypeValidator
    00429     //      The validator used to validate the value of this attribute.
    00430     //      The attribute does not own this object, and it is only
    00431     //      used in the calculation of DOMTypeInfo information.
    00432     //  fIsSchemaValidated
    00433     //      whether this attribute was validated by an XML Schema
    00434     //
    00435     // -----------------------------------------------------------------------
    00436     bool                fSpecified;
    00437     XMLAttDef::AttTypes fType;
    00438     unsigned int        fValueBufSz;
    00439     XMLCh*              fValue;
    00440     QName*              fAttName;
    00441     MemoryManager*      fMemoryManager;
    00442     DatatypeValidator * fDatatypeValidator;
    00443     bool                fIsSchemaValidated;
    00444 };
    00445
    00446 // ---------------------------------------------------------------------------
    00447 //  XMLAttr: Constructors and Destructor
    00448 // ---------------------------------------------------------------------------
    00449 inline XMLAttr::~XMLAttr()
    00450 {
    00451     cleanUp();
    00452 }
    00453
    00454
    00455 // ---------------------------------------------------------------------------
    00456 //  XMLAttr: Getter methods
    00457 // ---------------------------------------------------------------------------
    00458 inline QName* XMLAttr::getAttName() const
    00459 {
    00460     return fAttName;
    00461 }
    00462
    00463 inline const XMLCh* XMLAttr::getName() const
    00464 {
    00465     return fAttName->getLocalPart();
    00466 }
    00467
    00468 inline const XMLCh* XMLAttr::getPrefix() const
    00469 {
    00470     return fAttName->getPrefix();
    00471 }
    00472
    00473 inline bool XMLAttr::getSpecified() const
    00474 {
    00475     return fSpecified;
    00476 }
    00477
    00478 inline XMLAttDef::AttTypes XMLAttr::getType() const
    00479 {
    00480     return fType;
    00481 }
    00482
    00483 inline const XMLCh* XMLAttr::getValue() const
    00484 {
    00485     return fValue;
    00486 }
    00487
    00488 inline unsigned int XMLAttr::getURIId() const
    00489 {
    00490     return fAttName->getURI();
    00491 }
    00492
    00493 inline const XMLCh* XMLAttr::getValidatingTypeName() const
    00494 {
    00495     if(fIsSchemaValidated)
    00496     {
    00497         if(!fDatatypeValidator || fDatatypeValidator->getAnonymous())
    00498             return 0;
    00499         return fDatatypeValidator->getTypeLocalName();
    00500     }
    00501     else
    00502     {
    00503         return XMLAttDef::getAttTypeString(fType, fMemoryManager);
    00504     }
    00505 }
    00506
    00507 inline const XMLCh* XMLAttr::getValidatingTypeURI() const
    00508 {
    00509     if(fIsSchemaValidated)
    00510     {
    00511         if(!fDatatypeValidator || fDatatypeValidator->getAnonymous())
    00512             return 0;
    00513         return fDatatypeValidator->getTypeUri();
    00514     }
    00515     else
    00516     {
    00517         return 0;
    00518     }
    00519 }
    00520
    00521 // ---------------------------------------------------------------------------
    00522 //  XMLAttr: Setter methods
    00523 // ---------------------------------------------------------------------------
    00524 inline void XMLAttr::set(const  unsigned int        uriId
    00525                         , const XMLCh* const        attrName
    00526                         , const XMLCh* const        attrPrefix
    00527                         , const XMLCh* const        attrValue
    00528                         , const XMLAttDef::AttTypes type
    00529                         , DatatypeValidator * datatypeValidator
    00530                         , const bool isSchema )
    00531 {
    00532     // Set the name info and the value via their respective calls
    00533     fAttName->setName(attrPrefix, attrName, uriId);
    00534     setValue(attrValue);
    00535
    00536     // And store the type
    00537     fType = type;
    00538
    00539     // and set up info for DOM type info
    00540     fIsSchemaValidated = isSchema;
    00541     fDatatypeValidator = datatypeValidator;
    00542 }
    00543
    00544 inline void XMLAttr::set(const  unsigned int        uriId
    00545                         , const XMLCh* const        attrRawName
    00546                         , const XMLCh* const        attrValue
    00547                         , const XMLAttDef::AttTypes type
    00548                         , DatatypeValidator * datatypeValidator
    00549                         , const bool isSchema )
    00550 {
    00551     // Set the name info and the value via their respective calls
    00552     fAttName->setName(attrRawName, uriId);
    00553     setValue(attrValue);
    00554
    00555     // And store the type
    00556     fType = type;
    00557
    00558     // and set up info for DOM type info
    00559     fIsSchemaValidated = isSchema;
    00560     fDatatypeValidator = datatypeValidator;
    00561 }
    00562
    00563 inline void XMLAttr::setType(const XMLAttDef::AttTypes newValue)
    00564 {
    00565     fType = newValue;
    00566 }
    00567
    00568 inline void XMLAttr::setSpecified(const bool newValue)
    00569 {
    00570     fSpecified = newValue;
    00571 }
    00572
    00573 inline void XMLAttr::setDatatypeValidator(DatatypeValidator *datatypeValidator)
    00574 {
    00575     fDatatypeValidator = datatypeValidator;
    00576 }
    00577
    00578 inline void XMLAttr::setSchemaValidated(const bool isSchema)
    00579 {
    00580     fIsSchemaValidated = isSchema;
    00581 }
    00582
    00583 XERCES_CPP_NAMESPACE_END
    00584
    00585 #endif

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