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  

XMLAttDef.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: XMLAttDef.hpp,v $
00059  * Revision 1.13  2001/11/15 16:36:36  knoaman
00060  * Re-organize constant values.
00061  *
00062  * Revision 1.12  2001/08/09 15:23:37  knoaman
00063  * add support for <anyAttribute> declaration.
00064  *
00065  * Revision 1.11  2001/06/21 14:25:26  knoaman
00066  * Fix for bug 1946
00067  *
00068  * Revision 1.10  2001/05/11 13:25:31  tng
00069  * Copyright update.
00070  *
00071  * Revision 1.9  2001/02/27 18:48:20  tng
00072  * Schema: Add SchemaAttDef, SchemaElementDecl, SchemaAttDefList.
00073  *
00074  * Revision 1.8  2000/12/14 18:49:56  tng
00075  * Fix API document generation warning: "Warning: end of member group without matching begin"
00076  *
00077  * Revision 1.7  2000/11/30 18:22:38  andyh
00078  * reuseValidator - fix bugs (spurious errors) that occured on reuse due to
00079  * pools already containing some items.  Fixed by Tinny Ng.
00080  *
00081  * Revision 1.6  2000/07/07 22:23:38  jpolast
00082  * remove useless getKey() functions.
00083  *
00084  * Revision 1.5  2000/02/24 20:00:22  abagchi
00085  * Swat for removing Log from API docs
00086  *
00087  * Revision 1.4  2000/02/16 23:03:48  roddey
00088  * More documentation updates
00089  *
00090  * Revision 1.3  2000/02/15 01:21:30  roddey
00091  * Some initial documentation improvements. More to come...
00092  *
00093  * Revision 1.2  2000/02/06 07:47:46  rahulj
00094  * Year 2K copyright swat.
00095  *
00096  * Revision 1.1.1.1  1999/11/09 01:08:27  twl
00097  * Initial checkin
00098  *
00099  * Revision 1.2  1999/11/08 20:44:34  rahul
00100  * Swat for adding in Product name and CVS comment log variable.
00101  *
00102  */
00103 
00104 #if !defined(ATTDEF_HPP)
00105 #define ATTDEF_HPP
00106 
00107 #include <util/XMLString.hpp>
00108 
00109 class XMLAttr;
00110 
00129 class  XMLAttDef
00130 {
00131 public:
00132     // -----------------------------------------------------------------------
00133     //  Class specific types
00134     //
00135     //  AttTypes
00136     //      The list of possible types that an attribute can have, according
00137     //      to the XML 1.0 spec and schema.
00138     //
00139     //  DefAttTypes
00140     //      The modifiers that an attribute decl can have, which indicates
00141     //      whether instances of that attributes are required, implied, etc..
00142     //
00143     //  CreateReasons
00144     //      This type is used to store how an attribute declaration got into
00145     //      the elementdecl's attribute pool.
00146     //
00147     // -----------------------------------------------------------------------
00148     enum AttTypes
00149     {
00150         CData               = 0
00151         , ID                = 1
00152         , IDRef             = 2
00153         , IDRefs            = 3
00154         , Entity            = 4
00155         , Entities          = 5
00156         , NmToken           = 6
00157         , NmTokens          = 7
00158         , Notation          = 8
00159         , Enumeration       = 9
00160         , Simple            = 10
00161         , Any_Any           = 11
00162         , Any_Other         = 12
00163         , Any_List          = 13
00164 
00165         , AttTypes_Count
00166         , AttTypes_Min      = 0
00167         , AttTypes_Max      = 13
00168         , AttTypes_Unknown  = -1
00169     };
00170 
00171     enum DefAttTypes
00172     {
00173         Default                  = 0
00174         , Fixed                  = 1
00175         , Required               = 2
00176         , Required_And_Fixed     = 3
00177         , Implied                = 4
00178         , ProcessContents_Strict = 5
00179         , ProcessContents_Lax    = 6
00180         , ProcessContents_Skip   = 7
00181         , Prohibited             = 8
00182 
00183         , DefAttTypes_Count
00184         , DefAttTypes_Min   = 0
00185         , DefAttTypes_Max   = 8
00186         , DefAttTypes_Unknown = -1
00187     };
00188 
00189     enum CreateReasons
00190     {
00191         NoReason
00192         , JustFaultIn
00193     };
00194 
00195     // -----------------------------------------------------------------------
00196     //  Public static data members
00197     // -----------------------------------------------------------------------
00198     static const unsigned int fgInvalidAttrId;
00199 
00200 
00201     // -----------------------------------------------------------------------
00202     //  Public, static methods
00203     // -----------------------------------------------------------------------
00204 
00207 
00218     static const XMLCh* getAttTypeString(const AttTypes attrType);
00219 
00230     static const XMLCh* getDefAttTypeString(const DefAttTypes attrType);
00231 
00233 
00234 
00235     // -----------------------------------------------------------------------
00236     //  Destructor
00237     // -----------------------------------------------------------------------
00238 
00241 
00245     virtual ~XMLAttDef();
00247 
00248 
00249     // -----------------------------------------------------------------------
00250     //  The virtual attribute def interface
00251     // -----------------------------------------------------------------------
00252 
00255 
00264     virtual const XMLCh* getFullName() const = 0;
00265 
00267 
00268 
00269     // -----------------------------------------------------------------------
00270     //  Getter methods
00271     // -----------------------------------------------------------------------
00272 
00275 
00284     DefAttTypes getDefaultType() const;
00285 
00295     const XMLCh* getEnumeration() const;
00296 
00305     unsigned int getId() const;
00306 
00320     bool getProvided() const;
00321 
00331     AttTypes getType() const;
00332 
00342     const XMLCh* getValue() const;
00343 
00352     CreateReasons getCreateReason() const;
00353 
00361     bool isExternal() const;
00362 
00364 
00365 
00366     // -----------------------------------------------------------------------
00367     //  Setter methods
00368     // -----------------------------------------------------------------------
00369 
00372 
00381     void setDefaultType(const XMLAttDef::DefAttTypes newValue);
00382 
00391     void setId(const unsigned int newId);
00392 
00401     void setProvided(const bool newValue);
00402 
00410     void setType(const XMLAttDef::AttTypes newValue);
00411 
00422     void setValue(const XMLCh* const newValue);
00423 
00434     void setEnumeration(const XMLCh* const newValue);
00435 
00441     void setCreateReason(const CreateReasons newReason);
00442 
00446     void setExternalAttDeclaration(const bool aValue);
00447 
00449 
00450 protected :
00451     // -----------------------------------------------------------------------
00452     //  Hidden constructors
00453     // -----------------------------------------------------------------------
00454     XMLAttDef
00455     (
00456         const   AttTypes            type = CData
00457         , const DefAttTypes         defType = Implied
00458     );
00459     XMLAttDef
00460     (
00461         const   XMLCh* const        attValue
00462         , const AttTypes            type
00463         , const DefAttTypes         defType
00464         , const XMLCh* const        enumValues = 0
00465     );
00466 
00467 
00468 private :
00469     // -----------------------------------------------------------------------
00470     //  Unimplemented constructors and operators
00471     // -----------------------------------------------------------------------
00472     XMLAttDef(const XMLAttDef&);
00473     void operator=(const XMLAttDef&);
00474 
00475 
00476     // -----------------------------------------------------------------------
00477     //  Private helper methods
00478     // -----------------------------------------------------------------------
00479     void cleanUp();
00480 
00481 
00482     // -----------------------------------------------------------------------
00483     //  Private data members
00484     //
00485     //  fDefaultType
00486     //      Indicates what, if any, default stuff this attribute has.
00487     //
00488     //  fEnumeration
00489     //      If its an enumeration, this is the list of values as space
00490     //      separated values.
00491     //
00492     //  fId
00493     //      This is the unique id of this attribute, given to it when its put
00494     //      into the validator's attribute decl pool. It defaults to the
00495     //      special value XMLAttrDef::fgInvalidAttrId.
00496     //
00497     //  fProvided
00498     //      This field is really for use by the scanner. It is used to track
00499     //      which of the attributes of an element were provided. Any marked
00500     //      as not provided (after scanning the start tag) and having a
00501     //      default type of Required, is in error.
00502     //
00503     //  fType
00504     //      The type of attribute, which is one of the AttTypes values.
00505     //
00506     //  fValue
00507     //      This is the value of the attribute, which is the default value
00508     //      given in the attribute declaration.
00509     //
00510     //  fCreateReason
00511     //      This flag tells us how this attribute got created.  Sometimes even
00512     //      the attribute was not declared for the element, we want to fault
00513     //      fault it into the pool to avoid lots of redundant errors.
00514     //
00515     //  fExternalAttribute
00516     //      This flag indicates whether or not the attribute was declared externally.
00517     // -----------------------------------------------------------------------
00518     DefAttTypes     fDefaultType;
00519     XMLCh*          fEnumeration;
00520     unsigned int    fId;
00521     bool            fProvided;
00522     AttTypes        fType;
00523     XMLCh*          fValue;
00524     CreateReasons   fCreateReason;
00525     bool            fExternalAttribute;
00526 };
00527 
00528 
00529 
00530 // ---------------------------------------------------------------------------
00531 //  Getter methods
00532 // ---------------------------------------------------------------------------
00533 inline XMLAttDef::DefAttTypes XMLAttDef::getDefaultType() const
00534 {
00535     return fDefaultType;
00536 }
00537 
00538 inline const XMLCh* XMLAttDef::getEnumeration() const
00539 {
00540     return fEnumeration;
00541 }
00542 
00543 inline unsigned int XMLAttDef::getId() const
00544 {
00545     return fId;
00546 }
00547 
00548 inline bool XMLAttDef::getProvided() const
00549 {
00550     return fProvided;
00551 }
00552 
00553 inline XMLAttDef::AttTypes XMLAttDef::getType() const
00554 {
00555     return fType;
00556 }
00557 
00558 inline const XMLCh* XMLAttDef::getValue() const
00559 {
00560     return fValue;
00561 }
00562 
00563 inline XMLAttDef::CreateReasons XMLAttDef::getCreateReason() const
00564 {
00565     return fCreateReason;
00566 }
00567 
00568 inline bool XMLAttDef::isExternal() const
00569 {
00570     return fExternalAttribute;
00571 }
00572 
00573 
00574 // ---------------------------------------------------------------------------
00575 //  XMLAttDef: Setter methods
00576 // ---------------------------------------------------------------------------
00577 inline void XMLAttDef::setDefaultType(const XMLAttDef::DefAttTypes newValue)
00578 {
00579     fDefaultType = newValue;
00580 }
00581 
00582 inline void XMLAttDef::setEnumeration(const XMLCh* const newValue)
00583 {
00584     delete [] fEnumeration;
00585 
00586     if (newValue) {
00587         fEnumeration = XMLString::replicate(newValue);
00588     }
00589     else {
00590         fEnumeration = 0;
00591     }
00592 }
00593 
00594 inline void XMLAttDef::setId(const unsigned int newId)
00595 {
00596     fId = newId;
00597 }
00598 
00599 inline void XMLAttDef::setProvided(const bool newValue)
00600 {
00601     fProvided = newValue;
00602 }
00603 
00604 inline void XMLAttDef::setType(const XMLAttDef::AttTypes newValue)
00605 {
00606     fType = newValue;
00607 }
00608 
00609 inline void XMLAttDef::setValue(const XMLCh* const newValue)
00610 {
00611     delete [] fValue;
00612     fValue = XMLString::replicate(newValue);
00613 }
00614 
00615 inline void
00616 XMLAttDef::setCreateReason(const XMLAttDef::CreateReasons newReason)
00617 {
00618     fCreateReason = newReason;
00619 }
00620 
00621 inline void XMLAttDef::setExternalAttDeclaration(const bool aValue)
00622 {
00623     fExternalAttribute = aValue;
00624 }
00625 
00626 #endif


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