Base64BinaryDatatypeValidator.cpp
上传用户:huihehuasu
上传日期:2007-01-10
资源大小:6948k
文件大小:7k
源码类别:

xml/soap/webservice

开发平台:

C/C++

  1. /*
  2.  * The Apache Software License, Version 1.1
  3.  * 
  4.  * Copyright (c) 2001 The Apache Software Foundation.  All rights
  5.  * reserved.
  6.  * 
  7.  * Redistribution and use in source and binary forms, with or without
  8.  * modification, are permitted provided that the following conditions
  9.  * are met:
  10.  * 
  11.  * 1. Redistributions of source code must retain the above copyright
  12.  *    notice, this list of conditions and the following disclaimer. 
  13.  * 
  14.  * 2. Redistributions in binary form must reproduce the above copyright
  15.  *    notice, this list of conditions and the following disclaimer in
  16.  *    the documentation and/or other materials provided with the
  17.  *    distribution.
  18.  * 
  19.  * 3. The end-user documentation included with the redistribution,
  20.  *    if any, must include the following acknowledgment:  
  21.  *       "This product includes software developed by the
  22.  *        Apache Software Foundation (http://www.apache.org/)."
  23.  *    Alternately, this acknowledgment may appear in the software itself,
  24.  *    if and wherever such third-party acknowledgments normally appear.
  25.  * 
  26.  * 4. The names "Xerces" and "Apache Software Foundation" must
  27.  *    not be used to endorse or promote products derived from this
  28.  *    software without prior written permission. For written 
  29.  *    permission, please contact apache@apache.org.
  30.  * 
  31.  * 5. Products derived from this software may not be called "Apache",
  32.  *    nor may "Apache" appear in their name, without prior written
  33.  *    permission of the Apache Software Foundation.
  34.  * 
  35.  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  36.  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  37.  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  38.  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  39.  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  40.  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  41.  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  42.  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  43.  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  44.  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  45.  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  46.  * SUCH DAMAGE.
  47.  * ====================================================================
  48.  * 
  49.  * This software consists of voluntary contributions made by many
  50.  * individuals on behalf of the Apache Software Foundation, and was
  51.  * originally based on software copyright (c) 2001, International
  52.  * Business Machines, Inc., http://www.ibm.com .  For more information
  53.  * on the Apache Software Foundation, please see
  54.  * <http://www.apache.org/>.
  55.  */
  56. /*
  57.  * $Log: Base64BinaryDatatypeValidator.cpp,v $
  58.  * Revision 1.12  2001/10/09 20:47:26  peiyongz
  59.  * init(): take 1 arg
  60.  *
  61.  * Revision 1.11  2001/10/02 18:59:29  peiyongz
  62.  * Invalid_Facet_Tag to display the tag name
  63.  *
  64.  * Revision 1.10  2001/09/24 15:33:15  peiyongz
  65.  * DTV Reorganization: virtual methods moved to *.cpp
  66.  *
  67.  * Revision 1.9  2001/09/19 18:49:40  peiyongz
  68.  * DTV reorganization: inherit from AbstractStringVaildator
  69.  *
  70.  * Revision 1.8  2001/08/21 18:42:53  peiyongz
  71.  * Bugzilla# 2816: cleanUp() declared with external linkage and called
  72.  *                          before defined as inline
  73.  *
  74.  * Revision 1.7  2001/06/20 17:56:47  peiyongz
  75.  * support for "fixed" option on constrainning facets
  76.  *
  77.  * Revision 1.6  2001/05/29 19:49:31  tng
  78.  * Schema: Constraint Checking Fix in datatypeValidators.  By Pei Yong Zhang.
  79.  *
  80.  * Revision 1.5  2001/05/28 21:11:17  tng
  81.  * Schema: Various DatatypeValidator fix.  By Pei Yong Zhang
  82.  *
  83.  * Revision 1.4  2001/05/18 13:36:41  tng
  84.  * Schema: Catch RegularExpression exception and NumberFormatException
  85.  *
  86.  * Revision 1.3  2001/05/18 13:23:43  tng
  87.  * Schema: Exception messages in DatatypeValidator.  By Pei Yong Zhang.
  88.  *
  89.  * Revision 1.2  2001/05/17 18:13:46  tng
  90.  * Schema Fix: issue error message when binary data is invalid.
  91.  *
  92.  * Revision 1.1  2001/05/16 15:24:40  tng
  93.  * Schema: Add Base64 and HexBin.  By Pei Yong Zhang.
  94.  *
  95.  */
  96. // ---------------------------------------------------------------------------
  97. //  Includes
  98. // ---------------------------------------------------------------------------
  99. #include <validators/datatype/Base64BinaryDatatypeValidator.hpp>
  100. #include <validators/datatype/InvalidDatatypeFacetException.hpp>
  101. #include <validators/datatype/InvalidDatatypeValueException.hpp>
  102. #include <util/Base64.hpp>
  103. // ---------------------------------------------------------------------------
  104. //  Constructors and Destructor
  105. // ---------------------------------------------------------------------------
  106. Base64BinaryDatatypeValidator::Base64BinaryDatatypeValidator()
  107. :AbstractStringValidator(0, 0, 0, DatatypeValidator::Base64Binary)
  108. {}
  109. Base64BinaryDatatypeValidator::~Base64BinaryDatatypeValidator()
  110. {}
  111. Base64BinaryDatatypeValidator::Base64BinaryDatatypeValidator(
  112.                           DatatypeValidator*            const baseValidator
  113.                         , RefHashTableOf<KVStringPair>* const facets     
  114.                         , RefVectorOf<XMLCh>*           const enums
  115.                         , const int                           finalSet)
  116. :AbstractStringValidator(baseValidator, facets, finalSet, DatatypeValidator::Base64Binary)
  117. {
  118.     init(enums);
  119. }
  120. DatatypeValidator* Base64BinaryDatatypeValidator::newInstance(
  121.                                       RefHashTableOf<KVStringPair>* const facets
  122.                                     , RefVectorOf<XMLCh>*           const enums
  123.                                     , const int                           finalSet)
  124. {
  125.     return (DatatypeValidator*) new Base64BinaryDatatypeValidator(this, facets, enums, finalSet);
  126. }
  127. // ---------------------------------------------------------------------------
  128. //  Utilities
  129. // ---------------------------------------------------------------------------
  130. void Base64BinaryDatatypeValidator::assignAdditionalFacet( const XMLCh* const key
  131.                                                          , const XMLCh* const)
  132. {
  133.     ThrowXML1(InvalidDatatypeFacetException
  134.             , XMLExcepts::FACET_Invalid_Tag
  135.             , key);
  136. }
  137. void Base64BinaryDatatypeValidator::inheritAdditionalFacet()
  138. {}
  139. void Base64BinaryDatatypeValidator::checkAdditionalFacetConstraints() const
  140. {}
  141. void Base64BinaryDatatypeValidator::checkAdditionalFacet(const XMLCh* const) const
  142. {}
  143. void Base64BinaryDatatypeValidator::checkValueSpace(const XMLCh* const content)
  144. {
  145.     if (getLength(content) <= 0) 
  146.     {
  147.         ThrowXML1(InvalidDatatypeValueException
  148.                 , XMLExcepts::VALUE_Not_Base64
  149.                 , content);
  150.     }
  151. }
  152. int Base64BinaryDatatypeValidator::getLength(const XMLCh* const content) const
  153. {
  154.     return Base64::getDataLength(content);
  155. }
  156. /**
  157.   * End of file Base64BinaryDatatypeValidator.cpp
  158.   */