00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 
00029 
00030 
00031 
00032 
00033 
00034 
00035 
00036 
00037 
00038 
00039 
00040 
00041 
00042 
00043 
00044 
00045 
00046 
00047 
00048 
00049 
00050 
00051 
00052 
00053 
00054 
00055 
00056 
00057 
00058 
00059 
00060 
00061 
00062 
00063 
00064 
00065 
00066 
00067 
00068 
00069 
00070 
00071 
00072 
00073 
00074 
00075 
00076 
00077 
00078 
00079 
00080 
00081 
00082 
00083 
00084 
00085 
00086 
00087 
00088 
00089 
00090 
00091 
00092 
00093 
00094 
00095 
00096 
00097 
00098 
00099 
00100 
00101 
00102 
00103 
00104 
00105 
00106 
00107 
00108 
00109 
00110 
00111 
00112 
00113 
00114 
00115 
00116 
00117 
00118 
00119 
00120 
00121 #if !defined(XMLATTR_HPP)
00122 #define XMLATTR_HPP
00123 
00124 #include <xercesc/util/PlatformUtils.hpp>
00125 #include <xercesc/util/QName.hpp>
00126 #include <xercesc/framework/XMLAttDef.hpp>
00127 #include <xercesc/validators/datatype/DatatypeValidator.hpp>
00128 
00129 XERCES_CPP_NAMESPACE_BEGIN
00130 
00152 class  XMLAttr : public XMemory
00153 {
00154 public:
00155     
00156     
00157     
00160 
00168     XMLAttr(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
00169 
00202     XMLAttr
00203     (
00204           const unsigned int        uriId
00205         , const XMLCh* const        attrName
00206         , const XMLCh* const        attrPrefix
00207         , const XMLCh* const        attrValue
00208         , const XMLAttDef::AttTypes type = XMLAttDef::CData
00209         , const bool                specified = true
00210         , MemoryManager* const      manager = XMLPlatformUtils::fgMemoryManager
00211         , DatatypeValidator * datatypeValidator = 0
00212         , const bool isSchema = false
00213     );
00214 
00243     XMLAttr
00244     (
00245         const unsigned int uriId
00246         , const XMLCh* const rawName
00247         , const XMLCh* const attrValue
00248         , const XMLAttDef::AttTypes type = XMLAttDef::CData
00249         , const bool specified = true
00250         , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
00251         , DatatypeValidator * datatypeValidator = 0
00252         , const bool isSchema = false
00253     );
00254 
00256 
00259     ~XMLAttr();
00261 
00262 
00263     
00264     
00265     
00266 
00269 
00273     QName* getAttName() const;
00274 
00279     const XMLCh* getName() const;
00280 
00285     const XMLCh* getPrefix() const;
00286 
00292     const XMLCh* getQName() const;
00293 
00298     bool getSpecified() const;
00299 
00304     XMLAttDef::AttTypes getType() const;
00305 
00311     const XMLCh* getValue() const;
00312 
00317     unsigned int getURIId() const;
00318 
00322     const XMLCh* getValidatingTypeURI() const;
00323 
00327     const XMLCh* getValidatingTypeName() const;
00328 
00330 
00331 
00332     
00333     
00334     
00335 
00338 
00367     void set
00368     (
00369         const   unsigned int        uriId
00370         , const XMLCh* const        attrName
00371         , const XMLCh* const        attrPrefix
00372         , const XMLCh* const        attrValue
00373         , const XMLAttDef::AttTypes type = XMLAttDef::CData
00374         , DatatypeValidator * datatypeValidator = 0
00375         , const bool isSchema = false
00376     );
00377 
00401     void set
00402     (
00403         const   unsigned int        uriId
00404         , const XMLCh* const        attrRawName
00405         , const XMLCh* const        attrValue
00406         , const XMLAttDef::AttTypes type = XMLAttDef::CData
00407         , DatatypeValidator * datatypeValidator = 0
00408         , const bool isSchema = false
00409     );
00410 
00425     void setName
00426     (
00427         const   unsigned int        uriId
00428         , const XMLCh* const        attrName
00429         , const XMLCh* const        attrPrefix
00430     );
00431 
00439     void setSpecified(const bool newValue);
00440 
00449     void setType(const XMLAttDef::AttTypes newType);
00450 
00458     void setValue(const XMLCh* const newValue);
00459 
00467     void setURIId(const unsigned int uriId);
00468 
00475     void setDatatypeValidator(DatatypeValidator * datatypeValidator);
00476 
00483     void setSchemaValidated(const bool isSchema);
00484 
00486 
00487 
00488 
00489 private :
00490     
00491     
00492     
00493     XMLAttr(const XMLAttr&);
00494     XMLAttr& operator=(const XMLAttr&);
00495 
00496 
00497     
00498     
00499     
00500     void cleanUp();
00501 
00502 
00503     
00504     
00505     
00506     
00507     
00508     
00509     
00510     
00511     
00512     
00513     
00514     
00515     
00516     
00517     
00518     
00519     
00520     
00521     
00522     
00523     
00524     
00525     
00526     
00527     
00528     
00529     
00530     
00531     
00532     bool                fSpecified;
00533     XMLAttDef::AttTypes fType;
00534     unsigned int        fValueBufSz;
00535     XMLCh*              fValue;
00536     QName*              fAttName;
00537     MemoryManager*      fMemoryManager;
00538     DatatypeValidator * fDatatypeValidator;
00539     bool                fIsSchemaValidated;
00540 };
00541 
00542 
00543 
00544 
00545 inline XMLAttr::~XMLAttr()
00546 {
00547     cleanUp();
00548 }
00549 
00550 
00551 
00552 
00553 
00554 inline QName* XMLAttr::getAttName() const
00555 {
00556     return fAttName;
00557 }
00558 
00559 inline const XMLCh* XMLAttr::getName() const
00560 {
00561     return fAttName->getLocalPart();
00562 }
00563 
00564 inline const XMLCh* XMLAttr::getPrefix() const
00565 {
00566     return fAttName->getPrefix();
00567 }
00568 
00569 inline bool XMLAttr::getSpecified() const
00570 {
00571     return fSpecified;
00572 }
00573 
00574 inline XMLAttDef::AttTypes XMLAttr::getType() const
00575 {
00576     return fType;
00577 }
00578 
00579 inline const XMLCh* XMLAttr::getValue() const
00580 {
00581     return fValue;
00582 }
00583 
00584 inline unsigned int XMLAttr::getURIId() const
00585 {
00586     return fAttName->getURI();
00587 }
00588 
00589 inline const XMLCh* XMLAttr::getValidatingTypeName() const
00590 {
00591     if(fIsSchemaValidated)
00592     {
00593         if(!fDatatypeValidator || fDatatypeValidator->getAnonymous())
00594             return 0; 
00595         return fDatatypeValidator->getTypeLocalName();
00596     }
00597     else
00598     {
00599         return XMLAttDef::getAttTypeString(fType, fMemoryManager);
00600     }
00601 }
00602 
00603 inline const XMLCh* XMLAttr::getValidatingTypeURI() const
00604 {
00605     if(fIsSchemaValidated)
00606     {
00607         if(!fDatatypeValidator || fDatatypeValidator->getAnonymous())
00608             return 0; 
00609         return fDatatypeValidator->getTypeUri();
00610     }
00611     else
00612     {
00613         return 0;
00614     }
00615 }
00616 
00617 
00618 
00619 
00620 inline void XMLAttr::set(const  unsigned int        uriId
00621                         , const XMLCh* const        attrName
00622                         , const XMLCh* const        attrPrefix
00623                         , const XMLCh* const        attrValue
00624                         , const XMLAttDef::AttTypes type
00625                         , DatatypeValidator * datatypeValidator 
00626                         , const bool isSchema )
00627 {
00628     
00629     fAttName->setName(attrPrefix, attrName, uriId);
00630     setValue(attrValue);
00631 
00632     
00633     fType = type;
00634 
00635     
00636     fIsSchemaValidated = isSchema;
00637     fDatatypeValidator = datatypeValidator;
00638 }
00639 
00640 inline void XMLAttr::set(const  unsigned int        uriId
00641                         , const XMLCh* const        attrRawName
00642                         , const XMLCh* const        attrValue
00643                         , const XMLAttDef::AttTypes type
00644                         , DatatypeValidator * datatypeValidator 
00645                         , const bool isSchema )
00646 {
00647     
00648     fAttName->setName(attrRawName, uriId);
00649     setValue(attrValue);
00650 
00651     
00652     fType = type;
00653 
00654     
00655     fIsSchemaValidated = isSchema;
00656     fDatatypeValidator = datatypeValidator;
00657 }
00658 
00659 inline void XMLAttr::setType(const XMLAttDef::AttTypes newValue)
00660 {
00661     fType = newValue;
00662 }
00663 
00664 inline void XMLAttr::setSpecified(const bool newValue)
00665 {
00666     fSpecified = newValue;
00667 }
00668 
00669 inline void XMLAttr::setDatatypeValidator(DatatypeValidator *datatypeValidator)
00670 {
00671     fDatatypeValidator = datatypeValidator;
00672 }
00673 
00674 inline void XMLAttr::setSchemaValidated(const bool isSchema)
00675 {
00676     fIsSchemaValidated = isSchema;
00677 }
00678 
00679 XERCES_CPP_NAMESPACE_END
00680 
00681 #endif