http://xml.apache.org/http://www.apache.org/http://www.w3.org/

Home

Readme
Installation
Build

API Docs
Samples
Programming
Migration
FAQs

Releases
Feedback
Bug-Todo

Download
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-2000 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.8  2000/12/14 18:49:56  tng

00060  * Fix API document generation warning: "Warning: end of member group without matching begin"

00061  *
00062  * Revision 1.7  2000/11/30 18:22:38  andyh

00063  * reuseValidator - fix bugs (spurious errors) that occured on reuse due to

00064  * pools already containing some items.  Fixed by Tinny Ng.

00065  *
00066  * Revision 1.6  2000/07/07 22:23:38  jpolast

00067  * remove useless getKey() functions.

00068  *
00069  * Revision 1.5  2000/02/24 20:00:22  abagchi

00070  * Swat for removing Log from API docs

00071  *
00072  * Revision 1.4  2000/02/16 23:03:48  roddey

00073  * More documentation updates

00074  *
00075  * Revision 1.3  2000/02/15 01:21:30  roddey

00076  * Some initial documentation improvements. More to come...

00077  *
00078  * Revision 1.2  2000/02/06 07:47:46  rahulj

00079  * Year 2K copyright swat.

00080  *
00081  * Revision 1.1.1.1  1999/11/09 01:08:27  twl

00082  * Initial checkin

00083  *
00084  * Revision 1.2  1999/11/08 20:44:34  rahul

00085  * Swat for adding in Product name and CVS comment log variable.

00086  *
00087  */
00088 
00089 #if !defined(ATTDEF_HPP)
00090 #define ATTDEF_HPP
00091 
00092 #include <util/XMLString.hpp>
00093 
00094 class XMLAttr;
00095 
00114 class  XMLAttDef
00115 {
00116 public:
00117     // -----------------------------------------------------------------------
00118     //  Class specific types
00119     //
00120     //  AttTypes
00121     //      The list of possible types that an attribute can have, according
00122     //      to the XML 1.0 spec.
00123     //
00124     //  DefAttTypes
00125     //      The modifiers that an attribute decl can have, which indicates
00126     //      whether instances of that attributes are required, implied, etc..
00127     //
00128     //  CreateReasons
00129     //      This type is used to store how an attribute declaration got into
00130     //      the elementdecl's attribute pool.
00131     //
00132     // -----------------------------------------------------------------------
00133     enum AttTypes
00134     {
00135         CData               = 0
00136         , ID                = 1
00137         , IDRef             = 2
00138         , IDRefs            = 3
00139         , Entity            = 4
00140         , Entities          = 5
00141         , NmToken           = 6
00142         , NmTokens          = 7
00143         , Notation          = 8
00144         , Enumeration       = 9
00145 
00146         , AttTypes_Count
00147         , AttTypes_Min      = 0
00148         , AttTypes_Max      = 9
00149         , AttTypes_Unknown  = -1
00150     };
00151 
00152     enum DefAttTypes
00153     {
00154         Default             = 0
00155         , Required          = 1
00156         , Implied           = 2
00157         , Fixed             = 3
00158 
00159         , DefAttTypes_Count
00160         , DefAttTypes_Min   = 0
00161         , DefAttTypes_Max   = 3
00162         , DefAttTypes_Unknown = -1
00163     };
00164 
00165     enum CreateReasons
00166     {
00167         NoReason
00168         , JustFaultIn
00169     };
00170 
00171     // -----------------------------------------------------------------------
00172     //  Public static data members
00173     // -----------------------------------------------------------------------
00174     static const unsigned int fgInvalidAttrId;
00175 
00176 
00177     // -----------------------------------------------------------------------
00178     //  Public, static methods
00179     // -----------------------------------------------------------------------
00180 
00183 
00194     static const XMLCh* getAttTypeString(const AttTypes attrType);
00195 
00206     static const XMLCh* getDefAttTypeString(const DefAttTypes attrType);
00207 
00209 
00210 
00211     // -----------------------------------------------------------------------
00212     //  Destructor
00213     // -----------------------------------------------------------------------
00214 
00217 
00221     virtual ~XMLAttDef();
00223 
00224 
00225     // -----------------------------------------------------------------------
00226     //  The virtual attribute def interface
00227     // -----------------------------------------------------------------------
00228 
00231 
00240     virtual const XMLCh* getFullName() const = 0;
00241 
00243 
00244 
00245     // -----------------------------------------------------------------------
00246     //  Getter methods
00247     // -----------------------------------------------------------------------
00248 
00251 
00260     DefAttTypes getDefaultType() const;
00261 
00271     const XMLCh* getEnumeration() const;
00272 
00281     unsigned int getId() const;
00282 
00296     bool getProvided() const;
00297 
00307     AttTypes getType() const;
00308 
00318     const XMLCh* getValue() const;
00319 
00328     CreateReasons getCreateReason() const;
00329 
00331 
00332 
00333     // -----------------------------------------------------------------------
00334     //  Setter methods
00335     // -----------------------------------------------------------------------
00336 
00339 
00348     void setDefaultType(const XMLAttDef::DefAttTypes newValue);
00349 
00358     void setId(const unsigned int newId);
00359 
00368     void setProvided(const bool newValue);
00369 
00377     void setType(const XMLAttDef::AttTypes newValue);
00378 
00389     void setValue(const XMLCh* const newValue);
00390 
00401     void setEnumeration(const XMLCh* const newValue);
00402 
00408     void setCreateReason(const CreateReasons newReason);
00409 
00411 
00412 protected :
00413     // -----------------------------------------------------------------------
00414     //  Hidden constructors
00415     // -----------------------------------------------------------------------
00416     XMLAttDef
00417     (
00418         const   AttTypes            type = CData
00419         , const DefAttTypes         defType = Implied
00420     );
00421     XMLAttDef
00422     (
00423         const   XMLCh* const        attValue
00424         , const AttTypes            type
00425         , const DefAttTypes         defType
00426         , const XMLCh* const        enumValues = 0
00427     );
00428 
00429 
00430 private :
00431     // -----------------------------------------------------------------------
00432     //  Unimplemented constructors and operators
00433     // -----------------------------------------------------------------------
00434     XMLAttDef(const XMLAttDef&);
00435     void operator=(const XMLAttDef&);
00436 
00437 
00438     // -----------------------------------------------------------------------
00439     //  Private helper methods
00440     // -----------------------------------------------------------------------
00441     void cleanUp();
00442 
00443 
00444     // -----------------------------------------------------------------------
00445     //  Private data members
00446     //
00447     //  fDefaultType
00448     //      Indicates what, if any, default stuff this attribute has.
00449     //
00450     //  fEnumeration
00451     //      If its an enumeration, this is the list of values as space
00452     //      separated values.
00453     //
00454     //  fId
00455     //      This is the unique id of this attribute, given to it when its put
00456     //      into the validator's attribute decl pool. It defaults to the
00457     //      special value XMLAttrDef::fgInvalidAttrId.
00458     //
00459     //  fProvided
00460     //      This field is really for use by the scanner. It is used to track
00461     //      which of the attributes of an element were provided. Any marked
00462     //      as not provided (after scanning the start tag) and having a 
00463     //      default type of Required, is in error.
00464     //
00465     //  fType
00466     //      The type of attribute, which is one of the AttTypes values.
00467     //
00468     //  fValue
00469     //      This is the value of the attribute, which is the default value
00470     //      given in the attribute declaration.
00471     //
00472     //  fCreateReason
00473     //      This flag tells us how this attribute got created.  Sometimes even
00474     //      the attribute was not declared for the element, we want to fault
00475     //      fault it into the pool to avoid lots of redundant errors.
00476     // -----------------------------------------------------------------------
00477     DefAttTypes     fDefaultType;
00478     XMLCh*          fEnumeration;
00479     unsigned int    fId;
00480     bool            fProvided;
00481     AttTypes        fType;
00482     XMLCh*          fValue;
00483     CreateReasons       fCreateReason;
00484 };
00485 
00486 
00487 
00488 // ---------------------------------------------------------------------------
00489 //  Getter methods
00490 // ---------------------------------------------------------------------------
00491 inline XMLAttDef::DefAttTypes XMLAttDef::getDefaultType() const

00492 {
00493     return fDefaultType;
00494 }
00495 
00496 inline const XMLCh* XMLAttDef::getEnumeration() const

00497 {
00498     return fEnumeration;
00499 }
00500 
00501 inline unsigned int XMLAttDef::getId() const

00502 {
00503     return fId;
00504 }
00505 
00506 inline bool XMLAttDef::getProvided() const

00507 {
00508     return fProvided;
00509 }
00510 
00511 inline XMLAttDef::AttTypes XMLAttDef::getType() const

00512 {
00513     return fType;
00514 }
00515 
00516 inline const XMLCh* XMLAttDef::getValue() const

00517 {
00518     return fValue;
00519 }
00520 
00521 inline XMLAttDef::CreateReasons XMLAttDef::getCreateReason() const

00522 {
00523     return fCreateReason;
00524 }
00525 
00526 
00527 // ---------------------------------------------------------------------------
00528 //  XMLAttDef: Setter methods
00529 // ---------------------------------------------------------------------------
00530 inline void XMLAttDef::setDefaultType(const XMLAttDef::DefAttTypes newValue)

00531 {
00532     fDefaultType = newValue;
00533 }
00534 
00535 inline void XMLAttDef::setEnumeration(const XMLCh* const newValue)

00536 {
00537     delete [] fEnumeration;
00538     fEnumeration = XMLString::replicate(newValue);
00539 }
00540 
00541 inline void XMLAttDef::setId(const unsigned int newId)

00542 {
00543     fId = newId;
00544 }
00545 
00546 inline void XMLAttDef::setProvided(const bool newValue)

00547 {
00548     fProvided = newValue;
00549 }
00550 
00551 inline void XMLAttDef::setType(const XMLAttDef::AttTypes newValue)

00552 {
00553     fType = newValue;
00554 }
00555 
00556 inline void XMLAttDef::setValue(const XMLCh* const newValue)

00557 {
00558     delete [] fValue;
00559     fValue = XMLString::replicate(newValue);
00560 }
00561 
00562 inline void
00563 XMLAttDef::setCreateReason(const XMLAttDef::CreateReasons newReason)

00564 {
00565     fCreateReason = newReason;
00566 }
00567 
00568 #endif


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