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

Home

Readme
Installation
Build

API Docs
Samples
Programming
Migration
FAQs

Releases
Feedback

PDF Document

Download
Dev Snapshots
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.5  2000/02/24 20:00:22  abagchi
00060  * Swat for removing Log from API docs
00061  *
00062  * Revision 1.4  2000/02/16 23:03:48  roddey
00063  * More documentation updates
00064  *
00065  * Revision 1.3  2000/02/15 01:21:30  roddey
00066  * Some initial documentation improvements. More to come...
00067  *
00068  * Revision 1.2  2000/02/06 07:47:46  rahulj
00069  * Year 2K copyright swat.
00070  *
00071  * Revision 1.1.1.1  1999/11/09 01:08:27  twl
00072  * Initial checkin
00073  *
00074  * Revision 1.2  1999/11/08 20:44:34  rahul
00075  * Swat for adding in Product name and CVS comment log variable.
00076  *
00077  */
00078 
00079 #if !defined(ATTDEF_HPP)
00080 #define ATTDEF_HPP
00081 
00082 #include <util/XMLString.hpp>
00083 
00084 class XMLAttr;
00085 
00104 class  XMLAttDef
00105 {
00106 public:
00107     // -----------------------------------------------------------------------
00108     //  Class specific types
00109     //
00110     //  AttTypes
00111     //      The list of possible types that an attribute can have, according
00112     //      to the XML 1.0 spec.
00113     //
00114     //  DefAttTypes
00115     //      The modifiers that an attribute decl can have, which indicates
00116     //      whether instances of that attributes are required, implied, etc..
00117     // -----------------------------------------------------------------------
00118     enum AttTypes
00119     {
00120         CData               = 0
00121         , ID                = 1
00122         , IDRef             = 2
00123         , IDRefs            = 3
00124         , Entity            = 4
00125         , Entities          = 5
00126         , NmToken           = 6
00127         , NmTokens          = 7
00128         , Notation          = 8
00129         , Enumeration       = 9
00130 
00131         , AttTypes_Count
00132         , AttTypes_Min      = 0
00133         , AttTypes_Max      = 9
00134         , AttTypes_Unknown  = -1
00135     };
00136 
00137     enum DefAttTypes
00138     {
00139         Default             = 0
00140         , Required          = 1
00141         , Implied           = 2
00142         , Fixed             = 3
00143 
00144         , DefAttTypes_Count
00145         , DefAttTypes_Min   = 0
00146         , DefAttTypes_Max   = 3
00147         , DefAttTypes_Unknown = -1
00148     };
00149 
00150 
00151     // -----------------------------------------------------------------------
00152     //  Public static data members
00153     // -----------------------------------------------------------------------
00154     static const unsigned int fgInvalidAttrId;
00155 
00156 
00157     // -----------------------------------------------------------------------
00158     //  Public, static methods
00159     // -----------------------------------------------------------------------
00160 
00162     //{@
00163 
00174     static const XMLCh* getAttTypeString(const AttTypes attrType);
00175 
00186     static const XMLCh* getDefAttTypeString(const DefAttTypes attrType);
00187 
00188     //@}
00189 
00190 
00191     // -----------------------------------------------------------------------
00192     //  Destructor
00193     // -----------------------------------------------------------------------
00194 
00196     //@{
00197 
00201     virtual ~XMLAttDef();
00202     //@}
00203 
00204 
00205     // -----------------------------------------------------------------------
00206     //  The virtual attribute def interface
00207     // -----------------------------------------------------------------------
00208 
00210     //{@
00211 
00220     virtual const XMLCh* getFullName() const = 0;
00221 
00222     //@}
00223 
00224 
00225     // -----------------------------------------------------------------------
00226     //  Getter methods
00227     // -----------------------------------------------------------------------
00228 
00230     //{@
00231 
00240     DefAttTypes getDefaultType() const;
00241 
00251     const XMLCh* getEnumeration() const;
00252 
00261     unsigned int getId() const;
00262 
00273     const XMLCh* getKey() const;
00274 
00288     bool getProvided() const;
00289 
00299     AttTypes getType() const;
00300 
00310     const XMLCh* getValue() const;
00311 
00312     //@}
00313 
00314 
00315     // -----------------------------------------------------------------------
00316     //  Setter methods
00317     // -----------------------------------------------------------------------
00318 
00320     //{@
00321 
00330     void setDefaultType(const XMLAttDef::DefAttTypes newValue);
00331 
00340     void setId(const unsigned int newId);
00341 
00350     void setProvided(const bool newValue);
00351 
00359     void setType(const XMLAttDef::AttTypes newValue);
00360 
00371     void setValue(const XMLCh* const newValue);
00372 
00383     void setEnumeration(const XMLCh* const newValue);
00384 
00385     //@}
00386 
00387 protected :
00388     // -----------------------------------------------------------------------
00389     //  Hidden constructors
00390     // -----------------------------------------------------------------------
00391     XMLAttDef
00392     (
00393         const   AttTypes            type = CData
00394         , const DefAttTypes         defType = Implied
00395     );
00396     XMLAttDef
00397     (
00398         const   XMLCh* const        attValue
00399         , const AttTypes            type
00400         , const DefAttTypes         defType
00401         , const XMLCh* const        enumValues = 0
00402     );
00403 
00404 
00405 private :
00406     // -----------------------------------------------------------------------
00407     //  Unimplemented constructors and operators
00408     // -----------------------------------------------------------------------
00409     XMLAttDef(const XMLAttDef&);
00410     void operator=(const XMLAttDef&);
00411 
00412 
00413     // -----------------------------------------------------------------------
00414     //  Private helper methods
00415     // -----------------------------------------------------------------------
00416     void cleanUp();
00417 
00418 
00419     // -----------------------------------------------------------------------
00420     //  Private data members
00421     //
00422     //  fDefaultType
00423     //      Indicates what, if any, default stuff this attribute has.
00424     //
00425     //  fEnumeration
00426     //      If its an enumeration, this is the list of values as space
00427     //      separated values.
00428     //
00429     //  fId
00430     //      This is the unique id of this attribute, given to it when its put
00431     //      into the validator's attribute decl pool. It defaults to the
00432     //      special value XMLAttrDef::fgInvalidAttrId.
00433     //
00434     //  fProvided
00435     //      This field is really for use by the scanner. It is used to track
00436     //      which of the attributes of an element were provided. Any marked
00437     //      as not provided (after scanning the start tag) and having a 
00438     //      default type of Required, is in error.
00439     //
00440     //  fType
00441     //      The type of attribute, which is one of the AttTypes values.
00442     //
00443     //  fValue
00444     //      This is the value of the attribute, which is the default value
00445     //      given in the attribute declaration.
00446     // -----------------------------------------------------------------------
00447     DefAttTypes     fDefaultType;
00448     XMLCh*          fEnumeration;
00449     unsigned int    fId;
00450     bool            fProvided;
00451     AttTypes        fType;
00452     XMLCh*          fValue;
00453 };
00454 
00455 
00456 // ---------------------------------------------------------------------------
00457 //  Support named pool element semantics
00458 // ---------------------------------------------------------------------------
00459 inline const XMLCh* XMLAttDef::getKey() const
00460 {
00461     //
00462     //  Just call the virtual methods since only the validator specific
00463     //  derived class knows what the full name is.
00464     //
00465     return getFullName();
00466 }
00467 
00468 
00469 // ---------------------------------------------------------------------------
00470 //  Getter methods
00471 // ---------------------------------------------------------------------------
00472 inline XMLAttDef::DefAttTypes XMLAttDef::getDefaultType() const
00473 {
00474     return fDefaultType;
00475 }
00476 
00477 inline const XMLCh* XMLAttDef::getEnumeration() const
00478 {
00479     return fEnumeration;
00480 }
00481 
00482 inline unsigned int XMLAttDef::getId() const
00483 {
00484     return fId;
00485 }
00486 
00487 inline bool XMLAttDef::getProvided() const
00488 {
00489     return fProvided;
00490 }
00491 
00492 inline XMLAttDef::AttTypes XMLAttDef::getType() const
00493 {
00494     return fType;
00495 }
00496 
00497 inline const XMLCh* XMLAttDef::getValue() const
00498 {
00499     return fValue;
00500 }
00501 
00502 
00503 // ---------------------------------------------------------------------------
00504 //  XMLAttDef: Setter methods
00505 // ---------------------------------------------------------------------------
00506 inline void XMLAttDef::setDefaultType(const XMLAttDef::DefAttTypes newValue)
00507 {
00508     fDefaultType = newValue;
00509 }
00510 
00511 inline void XMLAttDef::setEnumeration(const XMLCh* const newValue)
00512 {
00513     delete [] fEnumeration;
00514     fEnumeration = XMLString::replicate(newValue);
00515 }
00516 
00517 inline void XMLAttDef::setId(const unsigned int newId)
00518 {
00519     fId = newId;
00520 }
00521 
00522 inline void XMLAttDef::setProvided(const bool newValue)
00523 {
00524     fProvided = newValue;
00525 }
00526 
00527 inline void XMLAttDef::setType(const XMLAttDef::AttTypes newValue)
00528 {
00529     fType = newValue;
00530 }
00531 
00532 inline void XMLAttDef::setValue(const XMLCh* const newValue)
00533 {
00534     delete [] fValue;
00535     fValue = XMLString::replicate(newValue);
00536 }
00537 
00538 #endif


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