secureswitools/swisistools/source/xmlparser/xerces/include/xercesc/validators/datatype/AbstractStringValidator.hpp
changeset 0 ba25891c3a9e
child 1 c42dffbd5b4f
equal deleted inserted replaced
-1:000000000000 0:ba25891c3a9e
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 /*
       
    18  * Licensed to the Apache Software Foundation (ASF) under one or more
       
    19  * contributor license agreements.  See the NOTICE file distributed with
       
    20  * this work for additional information regarding copyright ownership.
       
    21  * The ASF licenses this file to You under the Apache License, Version 2.0
       
    22  * (the "License"); you may not use this file except in compliance with
       
    23  * the License.  You may obtain a copy of the License at
       
    24  * 
       
    25  *      http://www.apache.org/licenses/LICENSE-2.0
       
    26  * 
       
    27  * Unless required by applicable law or agreed to in writing, software
       
    28  * distributed under the License is distributed on an "AS IS" BASIS,
       
    29  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       
    30  * See the License for the specific language governing permissions and
       
    31  * limitations under the License.
       
    32  */
       
    33 
       
    34 /*
       
    35  * $Id: AbstractStringValidator.hpp 568078 2007-08-21 11:43:25Z amassari $
       
    36  */
       
    37 
       
    38 #if !defined(ABSTRACT_STRING_VALIDATOR_HPP)
       
    39 #define ABSTRACT_STRING_VALIDATOR_HPP
       
    40 
       
    41 #include <xercesc/validators/datatype/DatatypeValidator.hpp>
       
    42 
       
    43 XERCES_CPP_NAMESPACE_BEGIN
       
    44 
       
    45 class VALIDATORS_EXPORT AbstractStringValidator : public DatatypeValidator
       
    46 {
       
    47 public:
       
    48 
       
    49     // -----------------------------------------------------------------------
       
    50     //  Public ctor/dtor
       
    51     // -----------------------------------------------------------------------
       
    52 	/** @name Constructor. */
       
    53     //@{
       
    54 
       
    55     virtual ~AbstractStringValidator();
       
    56 
       
    57 	//@}
       
    58 
       
    59 	virtual const RefArrayVectorOf<XMLCh>* getEnumString() const;
       
    60 
       
    61     // -----------------------------------------------------------------------
       
    62     // Validation methods
       
    63     // -----------------------------------------------------------------------
       
    64     /** @name Validation Function */
       
    65     //@{
       
    66 
       
    67     /**
       
    68      * validate that a string matches the boolean datatype
       
    69      * @param content A string containing the content to be validated
       
    70      *
       
    71      * @exception throws InvalidDatatypeException if the content is
       
    72      * is not valid.
       
    73      */
       
    74 
       
    75 	virtual void validate
       
    76                  (
       
    77                   const XMLCh*             const content
       
    78                 ,       ValidationContext* const context = 0
       
    79                 ,       MemoryManager*     const manager = XMLPlatformUtils::fgMemoryManager
       
    80                   );
       
    81 
       
    82     //@}
       
    83 
       
    84     // -----------------------------------------------------------------------
       
    85     // Compare methods
       
    86     // -----------------------------------------------------------------------
       
    87     /** @name Compare Function */
       
    88     //@{
       
    89 
       
    90     virtual int compare(const XMLCh* const, const XMLCh* const
       
    91         ,       MemoryManager*     const manager = XMLPlatformUtils::fgMemoryManager
       
    92         );
       
    93 
       
    94     //@}
       
    95 
       
    96     /***
       
    97      * Support for Serialization/De-serialization
       
    98      ***/
       
    99     DECL_XSERIALIZABLE(AbstractStringValidator)
       
   100 
       
   101 protected:
       
   102 
       
   103     AbstractStringValidator
       
   104     (
       
   105         DatatypeValidator* const baseValidator
       
   106         , RefHashTableOf<KVStringPair>* const facets
       
   107         , const int finalSet
       
   108         , const ValidatorType type
       
   109         , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
       
   110     );
       
   111 
       
   112     void init(RefArrayVectorOf<XMLCh>*           const enums
       
   113         , MemoryManager* const manager);
       
   114 
       
   115     //
       
   116     // Abstract interface
       
   117     //
       
   118     virtual void assignAdditionalFacet(const XMLCh* const key
       
   119                                      , const XMLCh* const value
       
   120                                      , MemoryManager* const manager);
       
   121 
       
   122     virtual void inheritAdditionalFacet();
       
   123 
       
   124     virtual void checkAdditionalFacetConstraints(MemoryManager* const manager) const;
       
   125 
       
   126     virtual void checkAdditionalFacet(const XMLCh* const content
       
   127                                     , MemoryManager* const manager) const;
       
   128 
       
   129     virtual int  getLength(const XMLCh* const content
       
   130         , MemoryManager* const manager) const;
       
   131     
       
   132     virtual void checkValueSpace(const XMLCh* const content
       
   133         , MemoryManager* const manager) = 0;
       
   134 
       
   135     //
       
   136     //   to Allow ListDTV to overwrite
       
   137     //
       
   138     virtual void inspectFacetBase(MemoryManager* const manager);
       
   139 
       
   140     virtual void inheritFacet();
       
   141 
       
   142     virtual void checkContent(const XMLCh*             const content
       
   143                             ,       ValidationContext* const context
       
   144                             , bool                           asBase
       
   145                             , MemoryManager* const manager);
       
   146 
       
   147     /*
       
   148      **  Base64BinaryDatatypeValidator to overwrite
       
   149      */
       
   150     virtual void normalizeEnumeration(MemoryManager* const manager);
       
   151 
       
   152     virtual void normalizeContent(XMLCh* const, MemoryManager* const manager) const;
       
   153 
       
   154 public:
       
   155 // -----------------------------------------------------------------------
       
   156 // Getter methods
       
   157 // -----------------------------------------------------------------------
       
   158 
       
   159     inline unsigned int         getLength() const;
       
   160 
       
   161     inline unsigned int         getMaxLength() const;
       
   162 
       
   163     inline unsigned int         getMinLength() const;
       
   164 
       
   165     inline RefArrayVectorOf<XMLCh>*  getEnumeration() const;
       
   166 
       
   167 protected:
       
   168 // -----------------------------------------------------------------------
       
   169 // Setter methods
       
   170 // -----------------------------------------------------------------------
       
   171 
       
   172     inline void                 setLength(unsigned int);
       
   173 
       
   174     inline void                 setMaxLength(unsigned int);
       
   175 
       
   176     inline void                 setMinLength(unsigned int);
       
   177 
       
   178     inline void                 setEnumeration(RefArrayVectorOf<XMLCh>*, bool);
       
   179 
       
   180 private:
       
   181 
       
   182     void assignFacet(MemoryManager* const manager);
       
   183 
       
   184     void inspectFacet(MemoryManager* const manager);
       
   185 
       
   186     // -----------------------------------------------------------------------
       
   187     //  Unimplemented constructors and operators
       
   188     // -----------------------------------------------------------------------
       
   189     AbstractStringValidator(const AbstractStringValidator&);
       
   190     AbstractStringValidator& operator=(const AbstractStringValidator&);
       
   191 
       
   192     // -----------------------------------------------------------------------
       
   193     //  Private data members
       
   194     //
       
   195     // -----------------------------------------------------------------------
       
   196      unsigned int         fLength;
       
   197      unsigned int         fMaxLength;
       
   198      unsigned int         fMinLength;
       
   199      bool                 fEnumerationInherited;
       
   200      RefArrayVectorOf<XMLCh>*  fEnumeration;
       
   201 };
       
   202 
       
   203 // -----------------------------------------------------------------------
       
   204 // Getter methods
       
   205 // -----------------------------------------------------------------------
       
   206 
       
   207 inline unsigned int AbstractStringValidator::getLength() const
       
   208 {
       
   209     return fLength;
       
   210 }
       
   211 
       
   212 inline unsigned int AbstractStringValidator::getMaxLength() const
       
   213 {
       
   214     return fMaxLength;
       
   215 }
       
   216 
       
   217 inline unsigned int AbstractStringValidator::getMinLength() const
       
   218 {
       
   219     return fMinLength;
       
   220 }
       
   221 
       
   222 inline RefArrayVectorOf<XMLCh>* AbstractStringValidator:: getEnumeration() const
       
   223 {
       
   224     return fEnumeration;
       
   225 }
       
   226 
       
   227 // -----------------------------------------------------------------------
       
   228 // Setter methods
       
   229 // -----------------------------------------------------------------------
       
   230 
       
   231 inline void AbstractStringValidator::setLength(unsigned int newLength)
       
   232 {
       
   233     fLength = newLength;
       
   234 }
       
   235 
       
   236 inline void AbstractStringValidator::setMaxLength(unsigned int newMaxLength)
       
   237 {
       
   238     fMaxLength = newMaxLength;
       
   239 }
       
   240 
       
   241 inline void AbstractStringValidator::setMinLength(unsigned int newMinLength)
       
   242 {
       
   243     fMinLength = newMinLength;
       
   244 }
       
   245 
       
   246 inline void AbstractStringValidator::setEnumeration(RefArrayVectorOf<XMLCh>* enums
       
   247                                            , bool                inherited)
       
   248 {
       
   249     if (enums)
       
   250     {
       
   251         if ( !fEnumerationInherited && fEnumeration)
       
   252             delete fEnumeration;
       
   253 
       
   254         fEnumeration = enums;
       
   255         fEnumerationInherited = inherited;
       
   256         setFacetsDefined(DatatypeValidator::FACET_ENUMERATION);
       
   257     }
       
   258 }
       
   259 
       
   260 XERCES_CPP_NAMESPACE_END
       
   261 
       
   262 #endif
       
   263 
       
   264 /**
       
   265   * End of file AbstractStringValidator.hpp
       
   266   */