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: XMLEntityDecl.hpp,v $
00059 * Revision 1.6 2000/02/24 20:00:23 abagchi
00060 * Swat for removing Log from API docs
00061 *
00062 * Revision 1.5 2000/02/16 23:03:48 roddey
00063 * More documentation updates
00064 *
00065 * Revision 1.4 2000/02/16 21:42:58 aruna1
00066 * API Doc++ summary changes in
00067 *
00068 * Revision 1.3 2000/02/15 01:21:30 roddey
00069 * Some initial documentation improvements. More to come...
00070 *
00071 * Revision 1.2 2000/02/06 07:47:48 rahulj
00072 * Year 2K copyright swat.
00073 *
00074 * Revision 1.1.1.1 1999/11/09 01:08:32 twl
00075 * Initial checkin
00076 *
00077 * Revision 1.2 1999/11/08 20:44:38 rahul
00078 * Swat for adding in Product name and CVS comment log variable.
00079 *
00080 */
00081
00082 #if !defined(XMLENTITYDECL_HPP)
00083 #define XMLENTITYDECL_HPP
00084
00085 #include <util/XMLString.hpp>
00086
00105 class XMLEntityDecl
00106 {
00107 public:
00108 // -----------------------------------------------------------------------
00109 // Constructors and Destructor
00110 // -----------------------------------------------------------------------
00111
00113 //@{
00114
00118 XMLEntityDecl();
00119
00124 XMLEntityDecl
00125 (
00126 const XMLCh* const entName
00127 );
00128
00135 XMLEntityDecl
00136 (
00137 const XMLCh* const entName
00138 , const XMLCh* const value
00139 );
00140
00147 XMLEntityDecl
00148 (
00149 const XMLCh* const entName
00150 , const XMLCh value
00151 );
00152 //@}
00153
00155 //@{
00156
00160 virtual ~XMLEntityDecl();
00161
00162 //@}
00163
00164
00165 // -----------------------------------------------------------------------
00166 // Virtual entity decl interface
00167 // -----------------------------------------------------------------------
00168
00170 //@{
00171
00179 virtual bool getDeclaredInIntSubset() const = 0;
00180
00186 virtual bool getIsParameter() const = 0;
00187
00193 virtual bool getIsSpecialChar() const = 0;
00194
00195 //@}
00196
00197
00198 // -----------------------------------------------------------------------
00199 // Getter methods
00200 // -----------------------------------------------------------------------
00201
00203 //@{
00204
00209 unsigned int getId() const;
00210
00216 const XMLCh* getName() const;
00217
00222 const XMLCh* getNotationName() const;
00223
00228 const XMLCh* getPublicId() const;
00229
00234 const XMLCh* getSystemId() const;
00235
00241 const XMLCh* getValue() const;
00242
00248 unsigned int getValueLen() const;
00249
00254 bool isExternal() const;
00255
00261 bool isUnparsed() const;
00262
00263 //@}
00264
00265
00266 // -----------------------------------------------------------------------
00267 // Setter methods
00268 // -----------------------------------------------------------------------
00269
00271 //@{
00272
00281 void setName
00282 (
00283 const XMLCh* const entName
00284 );
00285
00292 void setNotationName(const XMLCh* const newName);
00293
00300 void setPublicId(const XMLCh* const newId);
00301
00311 void setSystemId(const XMLCh* const newId);
00312
00320 void setValue(const XMLCh* const newValue);
00321
00322 //@}
00323
00324 /* For internal use only */
00325 void setId(const unsigned int newId);
00326
00327
00328 // -----------------------------------------------------------------------
00329 // Support named pool syntax
00330 // -----------------------------------------------------------------------
00331
00333 //@{
00334
00341 const XMLCh* getKey() const;
00342
00343 //@}
00344
00345
00346 private :
00347 // -----------------------------------------------------------------------
00348 // Unimplemented constructors and operators
00349 // -----------------------------------------------------------------------
00350 XMLEntityDecl(const XMLEntityDecl&);
00351 void operator=(XMLEntityDecl&);
00352
00353
00354 // -----------------------------------------------------------------------
00355 // XMLEntityDecl: Private helper methods
00356 // -----------------------------------------------------------------------
00357 void cleanUp();
00358
00359
00360 // -----------------------------------------------------------------------
00361 // Private data members
00362 //
00363 // fId
00364 // This is the unique id given to this entity decl.
00365 //
00366 // fName
00367 // The name of the enitity. Entity names are never namespace based.
00368 //
00369 // fNotationName
00370 // The optional notation of the entity. If there was none, then its
00371 // empty.
00372 //
00373 // fPublicId
00374 // The public id of the entity, which can be empty.
00375 //
00376 // fSystemId
00377 // The system id of the entity.
00378 //
00379 // fValue
00380 // fValueLen
00381 // The entity's value and length, which is only valid if its an
00382 // internal style entity.
00383 // -----------------------------------------------------------------------
00384 unsigned int fId;
00385 XMLCh* fName;
00386 XMLCh* fNotationName;
00387 XMLCh* fPublicId;
00388 XMLCh* fSystemId;
00389 XMLCh* fValue;
00390 unsigned int fValueLen;
00391 };
00392
00393
00394 // ---------------------------------------------------------------------------
00395 // XMLEntityDecl: Getter methods
00396 // ---------------------------------------------------------------------------
00397 inline unsigned int XMLEntityDecl::getId() const
00398 {
00399 return fId;
00400 }
00401
00402 inline const XMLCh* XMLEntityDecl::getName() const
00403 {
00404 return fName;
00405 }
00406
00407 inline const XMLCh* XMLEntityDecl::getNotationName() const
00408 {
00409 return fNotationName;
00410 }
00411
00412 inline const XMLCh* XMLEntityDecl::getPublicId() const
00413 {
00414 return fPublicId;
00415 }
00416
00417 inline const XMLCh* XMLEntityDecl::getSystemId() const
00418 {
00419 return fSystemId;
00420 }
00421
00422 inline const XMLCh* XMLEntityDecl::getValue() const
00423 {
00424 return fValue;
00425 }
00426
00427 inline unsigned int XMLEntityDecl::getValueLen() const
00428 {
00429 return fValueLen;
00430 }
00431
00432 inline bool XMLEntityDecl::isExternal() const
00433 {
00434 // If it has a system or public id, its external
00435 return ((fPublicId != 0) || (fSystemId != 0));
00436 }
00437
00438 inline bool XMLEntityDecl::isUnparsed() const
00439 {
00440 // If it has a notation, its unparsed
00441 return (fNotationName != 0);
00442 }
00443
00444
00445 // ---------------------------------------------------------------------------
00446 // XMLEntityDecl: Setter methods
00447 // ---------------------------------------------------------------------------
00448 inline void XMLEntityDecl::setId(const unsigned int newId)
00449 {
00450 fId = newId;
00451 }
00452
00453 inline void XMLEntityDecl::setNotationName(const XMLCh* const newName)
00454 {
00455 delete [] fNotationName;
00456 fNotationName = XMLString::replicate(newName);
00457 }
00458
00459 inline void XMLEntityDecl::setPublicId(const XMLCh* const newId)
00460 {
00461 delete [] fPublicId;
00462 fPublicId = XMLString::replicate(newId);
00463 }
00464
00465 inline void XMLEntityDecl::setSystemId(const XMLCh* const newId)
00466 {
00467 delete [] fSystemId;
00468 fSystemId = XMLString::replicate(newId);
00469 }
00470
00471 inline void XMLEntityDecl::setValue(const XMLCh* const newValue)
00472 {
00473 delete [] fValue;
00474 fValue = XMLString::replicate(newValue);
00475 fValueLen = XMLString::stringLen(newValue);
00476 }
00477
00478
00479 // ---------------------------------------------------------------------------
00480 // XMLEntityDecl: Support named pool syntax
00481 // ---------------------------------------------------------------------------
00482 inline const XMLCh* XMLEntityDecl::getKey() const
00483 {
00484 return fName;
00485 }
00486
00487 #endif