www.alphaworks.ibm.comwww.ibm.com/developerwww.ibm.com

Home

Readme
Download

Build







Migration

Releases

Feedback

Y2K Compliance


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.10  2001/05/11 13:25:31  tng
00060  * Copyright update.
00061  *
00062  * Revision 1.9  2001/02/27 18:48:20  tng
00063  * Schema: Add SchemaAttDef, SchemaElementDecl, SchemaAttDefList.
00064  *
00065  * Revision 1.8  2000/12/14 18:49:56  tng
00066  * Fix API document generation warning: "Warning: end of member group without matching begin"
00067  *
00068  * Revision 1.7  2000/11/30 18:22:38  andyh
00069  * reuseValidator - fix bugs (spurious errors) that occured on reuse due to
00070  * pools already containing some items.  Fixed by Tinny Ng.
00071  *
00072  * Revision 1.6  2000/07/07 22:23:38  jpolast
00073  * remove useless getKey() functions.
00074  *
00075  * Revision 1.5  2000/02/24 20:00:22  abagchi
00076  * Swat for removing Log from API docs
00077  *
00078  * Revision 1.4  2000/02/16 23:03:48  roddey
00079  * More documentation updates
00080  *
00081  * Revision 1.3  2000/02/15 01:21:30  roddey
00082  * Some initial documentation improvements. More to come...
00083  *
00084  * Revision 1.2  2000/02/06 07:47:46  rahulj
00085  * Year 2K copyright swat.
00086  *
00087  * Revision 1.1.1.1  1999/11/09 01:08:27  twl
00088  * Initial checkin
00089  *
00090  * Revision 1.2  1999/11/08 20:44:34  rahul
00091  * Swat for adding in Product name and CVS comment log variable.
00092  *
00093  */
00094 
00095 #if !defined(ATTDEF_HPP)
00096 #define ATTDEF_HPP
00097 
00098 #include <util/XMLString.hpp>
00099 
00100 class XMLAttr;
00101 
00120 class  XMLAttDef
00121 {
00122 public:
00123     // -----------------------------------------------------------------------
00124     //  Class specific types
00125     //
00126     //  AttTypes
00127     //      The list of possible types that an attribute can have, according
00128     //      to the XML 1.0 spec and schema.
00129     //
00130     //  DefAttTypes
00131     //      The modifiers that an attribute decl can have, which indicates
00132     //      whether instances of that attributes are required, implied, etc..
00133     //
00134     //  CreateReasons
00135     //      This type is used to store how an attribute declaration got into
00136     //      the elementdecl's attribute pool.
00137     //
00138     // -----------------------------------------------------------------------
00139     enum AttTypes
00140     {
00141         CData               = 0
00142         , ID                = 1
00143         , IDRef             = 2
00144         , IDRefs            = 3
00145         , Entity            = 4
00146         , Entities          = 5
00147         , NmToken           = 6
00148         , NmTokens          = 7
00149         , Notation          = 8
00150         , Enumeration       = 9
00151         , Simple            = 10
00152         , Any_Any           = 11
00153         , Any_Other         = 12
00154         , Any_Local         = 13
00155         , Any_List          = 14
00156 
00157         , AttTypes_Count
00158         , AttTypes_Min      = 0
00159         , AttTypes_Max      = 14
00160         , AttTypes_Unknown  = -1
00161     };
00162 
00163     enum DefAttTypes
00164     {
00165         Default                  = 0
00166         , Required               = 1
00167         , Implied                = 2
00168         , Fixed                  = 3
00169         , Prohibited             = 4
00170         , Required_And_Fixed     = 5
00171         , ProcessContents_Strict = 6
00172         , ProcessContents_Lax    = 7
00173         , ProcessContents_Skip   = 8
00174 
00175         , DefAttTypes_Count
00176         , DefAttTypes_Min   = 0
00177         , DefAttTypes_Max   = 8
00178         , DefAttTypes_Unknown = -1
00179     };
00180 
00181     enum CreateReasons
00182     {
00183         NoReason
00184         , JustFaultIn
00185     };
00186 
00187     // -----------------------------------------------------------------------
00188     //  Public static data members
00189     // -----------------------------------------------------------------------
00190     static const unsigned int fgInvalidAttrId;
00191 
00192 
00193     // -----------------------------------------------------------------------
00194     //  Public, static methods
00195     // -----------------------------------------------------------------------
00196 
00199 
00210     static const XMLCh* getAttTypeString(const AttTypes attrType);
00211 
00222     static const XMLCh* getDefAttTypeString(const DefAttTypes attrType);
00223 
00225 
00226 
00227     // -----------------------------------------------------------------------
00228     //  Destructor
00229     // -----------------------------------------------------------------------
00230 
00233 
00237     virtual ~XMLAttDef();
00239 
00240 
00241     // -----------------------------------------------------------------------
00242     //  The virtual attribute def interface
00243     // -----------------------------------------------------------------------
00244 
00247 
00256     virtual const XMLCh* getFullName() const = 0;
00257 
00259 
00260 
00261     // -----------------------------------------------------------------------
00262     //  Getter methods
00263     // -----------------------------------------------------------------------
00264 
00267 
00276     DefAttTypes getDefaultType() const;
00277 
00287     const XMLCh* getEnumeration() const;
00288 
00297     unsigned int getId() const;
00298 
00312     bool getProvided() const;
00313 
00323     AttTypes getType() const;
00324 
00334     const XMLCh* getValue() const;
00335 
00344     CreateReasons getCreateReason() const;
00345 
00347 
00348 
00349     // -----------------------------------------------------------------------
00350     //  Setter methods
00351     // -----------------------------------------------------------------------
00352 
00355 
00364     void setDefaultType(const XMLAttDef::DefAttTypes newValue);
00365 
00374     void setId(const unsigned int newId);
00375 
00384     void setProvided(const bool newValue);
00385 
00393     void setType(const XMLAttDef::AttTypes newValue);
00394 
00405     void setValue(const XMLCh* const newValue);
00406 
00417     void setEnumeration(const XMLCh* const newValue);
00418 
00424     void setCreateReason(const CreateReasons newReason);
00425 
00427 
00428 protected :
00429     // -----------------------------------------------------------------------
00430     //  Hidden constructors
00431     // -----------------------------------------------------------------------
00432     XMLAttDef
00433     (
00434         const   AttTypes            type = CData
00435         , const DefAttTypes         defType = Implied
00436     );
00437     XMLAttDef
00438     (
00439         const   XMLCh* const        attValue
00440         , const AttTypes            type
00441         , const DefAttTypes         defType
00442         , const XMLCh* const        enumValues = 0
00443     );
00444 
00445 
00446 private :
00447     // -----------------------------------------------------------------------
00448     //  Unimplemented constructors and operators
00449     // -----------------------------------------------------------------------
00450     XMLAttDef(const XMLAttDef&);
00451     void operator=(const XMLAttDef&);
00452 
00453 
00454     // -----------------------------------------------------------------------
00455     //  Private helper methods
00456     // -----------------------------------------------------------------------
00457     void cleanUp();
00458 
00459 
00460     // -----------------------------------------------------------------------
00461     //  Private data members
00462     //
00463     //  fDefaultType
00464     //      Indicates what, if any, default stuff this attribute has.
00465     //
00466     //  fEnumeration
00467     //      If its an enumeration, this is the list of values as space
00468     //      separated values.
00469     //
00470     //  fId
00471     //      This is the unique id of this attribute, given to it when its put
00472     //      into the validator's attribute decl pool. It defaults to the
00473     //      special value XMLAttrDef::fgInvalidAttrId.
00474     //
00475     //  fProvided
00476     //      This field is really for use by the scanner. It is used to track
00477     //      which of the attributes of an element were provided. Any marked
00478     //      as not provided (after scanning the start tag) and having a
00479     //      default type of Required, is in error.
00480     //
00481     //  fType
00482     //      The type of attribute, which is one of the AttTypes values.
00483     //
00484     //  fValue
00485     //      This is the value of the attribute, which is the default value
00486     //      given in the attribute declaration.
00487     //
00488     //  fCreateReason
00489     //      This flag tells us how this attribute got created.  Sometimes even
00490     //      the attribute was not declared for the element, we want to fault
00491     //      fault it into the pool to avoid lots of redundant errors.
00492     // -----------------------------------------------------------------------
00493     DefAttTypes     fDefaultType;
00494     XMLCh*          fEnumeration;
00495     unsigned int    fId;
00496     bool            fProvided;
00497     AttTypes        fType;
00498     XMLCh*          fValue;
00499     CreateReasons       fCreateReason;
00500 };
00501 
00502 
00503 
00504 // ---------------------------------------------------------------------------
00505 //  Getter methods
00506 // ---------------------------------------------------------------------------
00507 inline XMLAttDef::DefAttTypes XMLAttDef::getDefaultType() const
00508 {
00509     return fDefaultType;
00510 }
00511 
00512 inline const XMLCh* XMLAttDef::getEnumeration() const
00513 {
00514     return fEnumeration;
00515 }
00516 
00517 inline unsigned int XMLAttDef::getId() const
00518 {
00519     return fId;
00520 }
00521 
00522 inline bool XMLAttDef::getProvided() const
00523 {
00524     return fProvided;
00525 }
00526 
00527 inline XMLAttDef::AttTypes XMLAttDef::getType() const
00528 {
00529     return fType;
00530 }
00531 
00532 inline const XMLCh* XMLAttDef::getValue() const
00533 {
00534     return fValue;
00535 }
00536 
00537 inline XMLAttDef::CreateReasons XMLAttDef::getCreateReason() const
00538 {
00539     return fCreateReason;
00540 }
00541 
00542 
00543 // ---------------------------------------------------------------------------
00544 //  XMLAttDef: Setter methods
00545 // ---------------------------------------------------------------------------
00546 inline void XMLAttDef::setDefaultType(const XMLAttDef::DefAttTypes newValue)
00547 {
00548     fDefaultType = newValue;
00549 }
00550 
00551 inline void XMLAttDef::setEnumeration(const XMLCh* const newValue)
00552 {
00553     delete [] fEnumeration;
00554     fEnumeration = XMLString::replicate(newValue);
00555 }
00556 
00557 inline void XMLAttDef::setId(const unsigned int newId)
00558 {
00559     fId = newId;
00560 }
00561 
00562 inline void XMLAttDef::setProvided(const bool newValue)
00563 {
00564     fProvided = newValue;
00565 }
00566 
00567 inline void XMLAttDef::setType(const XMLAttDef::AttTypes newValue)
00568 {
00569     fType = newValue;
00570 }
00571 
00572 inline void XMLAttDef::setValue(const XMLCh* const newValue)
00573 {
00574     delete [] fValue;
00575     fValue = XMLString::replicate(newValue);
00576 }
00577 
00578 inline void
00579 XMLAttDef::setCreateReason(const XMLAttDef::CreateReasons newReason)
00580 {
00581     fCreateReason = newReason;
00582 }
00583 
00584 #endif


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