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