GME
13
|
00001 /* 00002 * Licensed to the Apache Software Foundation (ASF) under one or more 00003 * contributor license agreements. See the NOTICE file distributed with 00004 * this work for additional information regarding copyright ownership. 00005 * The ASF licenses this file to You under the Apache License, Version 2.0 00006 * (the "License"); you may not use this file except in compliance with 00007 * the License. You may obtain a copy of the License at 00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.0 00010 * 00011 * Unless required by applicable law or agreed to in writing, software 00012 * distributed under the License is distributed on an "AS IS" BASIS, 00013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 * See the License for the specific language governing permissions and 00015 * limitations under the License. 00016 */ 00017 00018 /* 00019 * $Id: NameDatatypeValidator.cpp 558817 2007-07-23 18:12:54Z cargilld $ 00020 */ 00021 00022 // --------------------------------------------------------------------------- 00023 // Includes 00024 // --------------------------------------------------------------------------- 00025 #include <xercesc/validators/datatype/NameDatatypeValidator.hpp> 00026 #include <xercesc/validators/datatype/InvalidDatatypeValueException.hpp> 00027 #include <xercesc/util/XMLChar.hpp> 00028 00029 XERCES_CPP_NAMESPACE_BEGIN 00030 00031 // --------------------------------------------------------------------------- 00032 // Constructors and Destructor 00033 // --------------------------------------------------------------------------- 00034 NameDatatypeValidator::NameDatatypeValidator(MemoryManager* const manager) 00035 :StringDatatypeValidator(0, 0, 0, DatatypeValidator::Name, manager) 00036 {} 00037 00038 NameDatatypeValidator::~NameDatatypeValidator() 00039 {} 00040 00041 NameDatatypeValidator::NameDatatypeValidator( 00042 DatatypeValidator* const baseValidator 00043 , RefHashTableOf<KVStringPair>* const facets 00044 , RefArrayVectorOf<XMLCh>* const enums 00045 , const int finalSet 00046 , MemoryManager* const manager) 00047 :StringDatatypeValidator(baseValidator, facets, finalSet, DatatypeValidator::Name, manager) 00048 { 00049 init(enums, manager); 00050 } 00051 00052 DatatypeValidator* NameDatatypeValidator::newInstance 00053 ( 00054 RefHashTableOf<KVStringPair>* const facets 00055 , RefArrayVectorOf<XMLCh>* const enums 00056 , const int finalSet 00057 , MemoryManager* const manager 00058 ) 00059 { 00060 return (DatatypeValidator*) new (manager) NameDatatypeValidator(this, facets, enums, finalSet, manager); 00061 } 00062 00063 NameDatatypeValidator::NameDatatypeValidator( 00064 DatatypeValidator* const baseValidator 00065 , RefHashTableOf<KVStringPair>* const facets 00066 , const int finalSet 00067 , const ValidatorType type 00068 , MemoryManager* const manager) 00069 :StringDatatypeValidator(baseValidator, facets, finalSet, type, manager) 00070 { 00071 // do not invoke init() here!!! 00072 } 00073 // ----------------------------------------------------------------------- 00074 // Compare methods 00075 // ----------------------------------------------------------------------- 00076 int NameDatatypeValidator::compare(const XMLCh* const lValue 00077 , const XMLCh* const rValue 00078 , MemoryManager* const) 00079 { 00080 return ( XMLString::equals(lValue, rValue)? 0 : -1); 00081 } 00082 00083 void NameDatatypeValidator::validate(const XMLCh* const content 00084 , ValidationContext* const context 00085 , MemoryManager* const manager) 00086 { 00087 // use StringDatatypeValidator (which in turn, invoke 00088 // the baseValidator) to validate content against 00089 // facets if any. 00090 // 00091 StringDatatypeValidator::validate(content, context, manager); 00092 00093 return; 00094 } 00095 00096 void NameDatatypeValidator::checkValueSpace(const XMLCh* const content 00097 , MemoryManager* const manager) 00098 { 00099 // 00100 // 3.3.6 check must: "Name" 00101 // 00102 if ( !XMLChar1_0::isValidName(content)) 00103 { 00104 ThrowXMLwithMemMgr2(InvalidDatatypeValueException 00105 , XMLExcepts::VALUE_Invalid_Name 00106 , content 00107 , SchemaSymbols::fgDT_NAME 00108 , manager); 00109 } 00110 00111 } 00112 00113 /*** 00114 * Support for Serialization/De-serialization 00115 ***/ 00116 00117 IMPL_XSERIALIZABLE_TOCREATE(NameDatatypeValidator) 00118 00119 void NameDatatypeValidator::serialize(XSerializeEngine& serEng) 00120 { 00121 StringDatatypeValidator::serialize(serEng); 00122 } 00123 00124 XERCES_CPP_NAMESPACE_END 00125