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: DatatypeValidator.hpp 568078 2007-08-21 11:43:25Z amassari $ |
---|
20 | */ |
---|
21 | |
---|
22 | #if !defined(DATATYPEVALIDATOR_HPP) |
---|
23 | #define DATATYPEVALIDATOR_HPP |
---|
24 | |
---|
25 | #include <xercesc/util/PlatformUtils.hpp> |
---|
26 | #include <xercesc/util/RefHashTableOf.hpp> |
---|
27 | #include <xercesc/util/KVStringPair.hpp> |
---|
28 | #include <xercesc/util/XMLUniDefs.hpp> |
---|
29 | #include <xercesc/util/regx/RegularExpression.hpp> |
---|
30 | #include <xercesc/validators/schema/SchemaSymbols.hpp> |
---|
31 | #include <xercesc/internal/XSerializable.hpp> |
---|
32 | #include <xercesc/framework/psvi/XSSimpleTypeDefinition.hpp> |
---|
33 | #include <xercesc/framework/ValidationContext.hpp> |
---|
34 | |
---|
35 | XERCES_CPP_NAMESPACE_BEGIN |
---|
36 | |
---|
37 | class MemoryManager; |
---|
38 | |
---|
39 | /** |
---|
40 | * DataTypeValidator defines the interface that data type validators must |
---|
41 | * obey. These validators can be supplied by the application writer and may |
---|
42 | * be useful as standalone code as well as plugins to the validator |
---|
43 | * architecture. |
---|
44 | * |
---|
45 | * Notice: |
---|
46 | * The datatype validator will own the facets hashtable passed to it during |
---|
47 | * construction, which means that the datatype validator will be responsible |
---|
48 | * for the deletion. The facets hashtable will be created during parsing and |
---|
49 | * passed to the appropriate datatype validator which in turn will delete it |
---|
50 | * upon its destruction. |
---|
51 | * |
---|
52 | */ |
---|
53 | |
---|
54 | |
---|
55 | class VALIDATORS_EXPORT DatatypeValidator : public XSerializable, public XMemory |
---|
56 | { |
---|
57 | public: |
---|
58 | // ----------------------------------------------------------------------- |
---|
59 | // Constant data |
---|
60 | // ----------------------------------------------------------------------- |
---|
61 | //facets |
---|
62 | enum { |
---|
63 | FACET_LENGTH = 1, |
---|
64 | FACET_MINLENGTH = 1<<1, |
---|
65 | FACET_MAXLENGTH = 1<<2, |
---|
66 | FACET_PATTERN = 1<<3, |
---|
67 | FACET_ENUMERATION = 1<<4, |
---|
68 | FACET_MAXINCLUSIVE = 1<<5, |
---|
69 | FACET_MAXEXCLUSIVE = 1<<6, |
---|
70 | FACET_MININCLUSIVE = 1<<7, |
---|
71 | FACET_MINEXCLUSIVE = 1<<8, |
---|
72 | FACET_TOTALDIGITS = 1<<9, |
---|
73 | FACET_FRACTIONDIGITS = 1<<10, |
---|
74 | FACET_ENCODING = 1<<11, |
---|
75 | FACET_DURATION = 1<<12, |
---|
76 | FACET_PERIOD = 1<<13, |
---|
77 | FACET_WHITESPACE = 1<<14 |
---|
78 | }; |
---|
79 | |
---|
80 | //2.4.2.6 whiteSpace - Datatypes |
---|
81 | enum { |
---|
82 | PRESERVE = 0, |
---|
83 | REPLACE = 1, |
---|
84 | COLLAPSE = 2 |
---|
85 | }; |
---|
86 | |
---|
87 | enum ValidatorType { |
---|
88 | String, |
---|
89 | AnyURI, |
---|
90 | QName, |
---|
91 | Name, |
---|
92 | NCName, |
---|
93 | Boolean, |
---|
94 | Float, |
---|
95 | Double, |
---|
96 | Decimal, |
---|
97 | HexBinary, |
---|
98 | Base64Binary, |
---|
99 | Duration, |
---|
100 | DateTime, |
---|
101 | Date, |
---|
102 | Time, |
---|
103 | MonthDay, |
---|
104 | YearMonth, |
---|
105 | Year, |
---|
106 | Month, |
---|
107 | Day, |
---|
108 | ID, |
---|
109 | IDREF, |
---|
110 | ENTITY, |
---|
111 | NOTATION, |
---|
112 | List, |
---|
113 | Union, |
---|
114 | AnySimpleType, |
---|
115 | UnKnown |
---|
116 | }; |
---|
117 | |
---|
118 | // ----------------------------------------------------------------------- |
---|
119 | // Public Destructor |
---|
120 | // ----------------------------------------------------------------------- |
---|
121 | /** @name Destructor. */ |
---|
122 | //@{ |
---|
123 | |
---|
124 | virtual ~DatatypeValidator(); |
---|
125 | |
---|
126 | //@} |
---|
127 | |
---|
128 | // ----------------------------------------------------------------------- |
---|
129 | // Getter methods |
---|
130 | // ----------------------------------------------------------------------- |
---|
131 | /** @name Getter Functions */ |
---|
132 | //@{ |
---|
133 | |
---|
134 | /** |
---|
135 | * Returns the final values of the simpleType |
---|
136 | */ |
---|
137 | int getFinalSet() const; |
---|
138 | |
---|
139 | /** |
---|
140 | * Returns the datatype facet if any is set. |
---|
141 | */ |
---|
142 | RefHashTableOf<KVStringPair>* getFacets() const; |
---|
143 | |
---|
144 | /** |
---|
145 | * Returns default value (collapse) for whiteSpace facet. |
---|
146 | * This function is overwritten in StringDatatypeValidator. |
---|
147 | */ |
---|
148 | short getWSFacet () const; |
---|
149 | |
---|
150 | /** |
---|
151 | * Returns the base datatype validator if set. |
---|
152 | */ |
---|
153 | DatatypeValidator* getBaseValidator() const; |
---|
154 | |
---|
155 | /** |
---|
156 | * Returns the 'class' type of datatype validator |
---|
157 | */ |
---|
158 | ValidatorType getType() const; |
---|
159 | |
---|
160 | /** |
---|
161 | * Returns whether the type is atomic or not |
---|
162 | * |
---|
163 | * To be redefined in List/Union validators |
---|
164 | */ |
---|
165 | virtual bool isAtomic() const; |
---|
166 | |
---|
167 | /** |
---|
168 | * Returns the datatype enumeration if any is set. |
---|
169 | * Derived class shall provide their own copy. |
---|
170 | */ |
---|
171 | virtual const RefArrayVectorOf<XMLCh>* getEnumString() const = 0; |
---|
172 | |
---|
173 | /** |
---|
174 | * returns true if this type is anonymous |
---|
175 | **/ |
---|
176 | bool getAnonymous() const; |
---|
177 | |
---|
178 | /** |
---|
179 | * sets this type to be anonymous |
---|
180 | **/ |
---|
181 | void setAnonymous(); |
---|
182 | |
---|
183 | /** |
---|
184 | * Fundamental Facet: ordered |
---|
185 | */ |
---|
186 | XSSimpleTypeDefinition::ORDERING getOrdered() const; |
---|
187 | |
---|
188 | /** |
---|
189 | * Fundamental Facet: cardinality. |
---|
190 | */ |
---|
191 | bool getFinite() const; |
---|
192 | |
---|
193 | /** |
---|
194 | * Fundamental Facet: bounded. |
---|
195 | */ |
---|
196 | bool getBounded() const; |
---|
197 | |
---|
198 | /** |
---|
199 | * Fundamental Facet: numeric. |
---|
200 | */ |
---|
201 | bool getNumeric() const; |
---|
202 | |
---|
203 | /** |
---|
204 | * Canonical Representation |
---|
205 | * |
---|
206 | * Derivative datatype may overwrite this method once |
---|
207 | * it has its own canonical representation other than |
---|
208 | * the default one. |
---|
209 | * |
---|
210 | * @param rawData: data in raw string |
---|
211 | * @param memMgr: memory manager |
---|
212 | * @param toValiate: to validate the raw string or not |
---|
213 | * |
---|
214 | * @return: canonical representation of the data |
---|
215 | * |
---|
216 | * Note: |
---|
217 | * |
---|
218 | * 1. the return value is kept in memory allocated |
---|
219 | * by the memory manager passed in or by dv's |
---|
220 | * if no memory manager is provided. |
---|
221 | * |
---|
222 | * 2. client application is responsible for the |
---|
223 | * proper deallcation of the memory allocated |
---|
224 | * for the returned value. |
---|
225 | * |
---|
226 | * 3. In the case where the rawData is not valid |
---|
227 | * with regards to the fundamental datatype, |
---|
228 | * a null string is returned. |
---|
229 | * |
---|
230 | */ |
---|
231 | virtual const XMLCh* getCanonicalRepresentation |
---|
232 | ( |
---|
233 | const XMLCh* const rawData |
---|
234 | , MemoryManager* const memMgr = 0 |
---|
235 | , bool toValidate = false |
---|
236 | ) const; |
---|
237 | |
---|
238 | //@} |
---|
239 | |
---|
240 | // ----------------------------------------------------------------------- |
---|
241 | // Validation methods |
---|
242 | // ----------------------------------------------------------------------- |
---|
243 | /** @name Validation Function */ |
---|
244 | //@{ |
---|
245 | |
---|
246 | /** |
---|
247 | * Checks that the "content" string is valid datatype. |
---|
248 | * If invalid, a Datatype validation exception is thrown. |
---|
249 | * |
---|
250 | * @param content A string containing the content to be validated |
---|
251 | * |
---|
252 | */ |
---|
253 | virtual void validate |
---|
254 | ( |
---|
255 | const XMLCh* const content |
---|
256 | , ValidationContext* const context = 0 |
---|
257 | , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager |
---|
258 | ) = 0; |
---|
259 | |
---|
260 | /** |
---|
261 | * Checks whether a given type can be used as a substitute |
---|
262 | * |
---|
263 | * @param toCheck A datatype validator of the type to be used as a |
---|
264 | * substitute |
---|
265 | * |
---|
266 | * To be redefined in UnionDatatypeValidator |
---|
267 | */ |
---|
268 | |
---|
269 | virtual bool isSubstitutableBy(const DatatypeValidator* const toCheck); |
---|
270 | |
---|
271 | //@} |
---|
272 | |
---|
273 | // ----------------------------------------------------------------------- |
---|
274 | // Compare methods |
---|
275 | // ----------------------------------------------------------------------- |
---|
276 | /** @name Compare Function */ |
---|
277 | //@{ |
---|
278 | |
---|
279 | /** |
---|
280 | * Compares content in the Domain value vs. lexical value. |
---|
281 | * |
---|
282 | * e.g. If type is a float then 1.0 may be equivalent to 1 even though |
---|
283 | * both are lexically different. |
---|
284 | * |
---|
285 | * @param value1 string to compare |
---|
286 | * |
---|
287 | * @param value2 string to compare |
---|
288 | * |
---|
289 | * We will provide a default behavior that should be redefined at the |
---|
290 | * children level, if necessary (i.e. boolean case). |
---|
291 | */ |
---|
292 | virtual int compare(const XMLCh* const value1, const XMLCh* const value2 |
---|
293 | , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager |
---|
294 | ); |
---|
295 | |
---|
296 | //@} |
---|
297 | |
---|
298 | /** |
---|
299 | * Returns an instance of the base datatype validator class |
---|
300 | * Used by the DatatypeValidatorFactory. |
---|
301 | */ |
---|
302 | virtual DatatypeValidator* newInstance |
---|
303 | ( |
---|
304 | RefHashTableOf<KVStringPair>* const facets |
---|
305 | , RefArrayVectorOf<XMLCh>* const enums |
---|
306 | , const int finalSet |
---|
307 | , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager |
---|
308 | ) = 0; |
---|
309 | |
---|
310 | /** |
---|
311 | * Returns the uri,name of the type this validator is for |
---|
312 | */ |
---|
313 | const XMLCh* getTypeName() const; |
---|
314 | |
---|
315 | /** |
---|
316 | * sets the uri,name that this validator is for - typeName is uri,name string. |
---|
317 | * due to the internals of xerces this will set the uri to be the schema uri if |
---|
318 | * there is no comma in typeName |
---|
319 | */ |
---|
320 | void setTypeName(const XMLCh* const typeName); |
---|
321 | |
---|
322 | /** |
---|
323 | * sets the uri,name that this validator is for |
---|
324 | */ |
---|
325 | void setTypeName(const XMLCh* const name, const XMLCh* const uri); |
---|
326 | |
---|
327 | /** |
---|
328 | * Returns the uri of the type this validator is for |
---|
329 | */ |
---|
330 | const XMLCh* getTypeUri() const; |
---|
331 | |
---|
332 | /** |
---|
333 | * Returns the name of the type this validator is for |
---|
334 | */ |
---|
335 | const XMLCh* getTypeLocalName() const; |
---|
336 | |
---|
337 | /** |
---|
338 | * Returns the plugged-in memory manager |
---|
339 | */ |
---|
340 | MemoryManager* getMemoryManager() const; |
---|
341 | |
---|
342 | /*** |
---|
343 | * Support for Serialization/De-serialization |
---|
344 | ***/ |
---|
345 | DECL_XSERIALIZABLE(DatatypeValidator) |
---|
346 | |
---|
347 | /*** |
---|
348 | * |
---|
349 | * Serialzie DatatypeValidator derivative |
---|
350 | * |
---|
351 | * Param |
---|
352 | * serEng: serialize engine |
---|
353 | * dv: DatatypeValidator derivative |
---|
354 | * |
---|
355 | * Return: |
---|
356 | * |
---|
357 | ***/ |
---|
358 | static void storeDV(XSerializeEngine& serEng |
---|
359 | , DatatypeValidator* const dv); |
---|
360 | |
---|
361 | /*** |
---|
362 | * |
---|
363 | * Create a DatatypeValidator derivative from the binary |
---|
364 | * stream. |
---|
365 | * |
---|
366 | * Param |
---|
367 | * serEng: serialize engine |
---|
368 | * |
---|
369 | * Return: |
---|
370 | * DatatypeValidator derivative |
---|
371 | * |
---|
372 | ***/ |
---|
373 | static DatatypeValidator* loadDV(XSerializeEngine& serEng); |
---|
374 | |
---|
375 | protected: |
---|
376 | // ----------------------------------------------------------------------- |
---|
377 | // Protected Constructors |
---|
378 | // ----------------------------------------------------------------------- |
---|
379 | /** @name Constructors */ |
---|
380 | //@{ |
---|
381 | |
---|
382 | /** |
---|
383 | * |
---|
384 | * @param baseValidator The base datatype validator for derived |
---|
385 | * validators. Null if native validator. |
---|
386 | * |
---|
387 | * @param facets A hashtable of datatype facets (except enum). |
---|
388 | * |
---|
389 | * @param finalSet 'final' value of the simpleType |
---|
390 | */ |
---|
391 | |
---|
392 | DatatypeValidator(DatatypeValidator* const baseValidator, |
---|
393 | RefHashTableOf<KVStringPair>* const facets, |
---|
394 | const int finalSet, |
---|
395 | const ValidatorType type, |
---|
396 | MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); |
---|
397 | |
---|
398 | //@} |
---|
399 | |
---|
400 | |
---|
401 | friend class DatatypeValidatorFactory; |
---|
402 | friend class XSObjectFactory; |
---|
403 | |
---|
404 | /** |
---|
405 | * facetDefined |
---|
406 | */ |
---|
407 | int getFacetsDefined() const; |
---|
408 | void setFacetsDefined(int); |
---|
409 | |
---|
410 | /** |
---|
411 | * fixed |
---|
412 | */ |
---|
413 | int getFixed() const; |
---|
414 | void setFixed(int); |
---|
415 | |
---|
416 | |
---|
417 | /** |
---|
418 | * fPattern |
---|
419 | */ |
---|
420 | const XMLCh* getPattern() const; |
---|
421 | void setPattern(const XMLCh* ); |
---|
422 | |
---|
423 | /** |
---|
424 | * fRegex |
---|
425 | */ |
---|
426 | RegularExpression* getRegex() const; |
---|
427 | void setRegex(RegularExpression* const); |
---|
428 | |
---|
429 | /** |
---|
430 | * set fType |
---|
431 | */ |
---|
432 | void setType(ValidatorType); |
---|
433 | |
---|
434 | /** |
---|
435 | * set fWhiteSpace |
---|
436 | */ |
---|
437 | void setWhiteSpace(short); |
---|
438 | |
---|
439 | /** |
---|
440 | * get WSString |
---|
441 | */ |
---|
442 | const XMLCh* getWSstring(const short WSType) const; |
---|
443 | |
---|
444 | /** |
---|
445 | * Fundamental Facet: ordered |
---|
446 | */ |
---|
447 | void setOrdered(XSSimpleTypeDefinition::ORDERING ordered); |
---|
448 | |
---|
449 | /** |
---|
450 | * Fundamental Facet: cardinality. |
---|
451 | */ |
---|
452 | void setFinite(bool finite); |
---|
453 | |
---|
454 | /** |
---|
455 | * Fundamental Facet: bounded. |
---|
456 | */ |
---|
457 | void setBounded(bool bounded); |
---|
458 | |
---|
459 | /** |
---|
460 | * Fundamental Facet: numeric. |
---|
461 | */ |
---|
462 | void setNumeric(bool numeric); |
---|
463 | |
---|
464 | private: |
---|
465 | // ----------------------------------------------------------------------- |
---|
466 | // CleanUp methods |
---|
467 | // ----------------------------------------------------------------------- |
---|
468 | void cleanUp(); |
---|
469 | |
---|
470 | // ----------------------------------------------------------------------- |
---|
471 | // Unimplemented constructors and operators |
---|
472 | // ----------------------------------------------------------------------- |
---|
473 | DatatypeValidator(const DatatypeValidator&); |
---|
474 | DatatypeValidator& operator=(const DatatypeValidator&); |
---|
475 | |
---|
476 | // ----------------------------------------------------------------------- |
---|
477 | // Private data members |
---|
478 | // |
---|
479 | // fFinalSet |
---|
480 | // stores "final" values of simpleTypes |
---|
481 | // |
---|
482 | // fBaseValidator |
---|
483 | // This is a pointer to a base datatype validator. If value is null, |
---|
484 | // it means we have a native datatype validator not a derived one. |
---|
485 | // |
---|
486 | // fFacets |
---|
487 | // This is a hashtable of dataype facets. |
---|
488 | // |
---|
489 | // fType |
---|
490 | // Stores the class type of datatype validator |
---|
491 | // |
---|
492 | // fFacetsDefined |
---|
493 | // Stores the constaiting facets flag |
---|
494 | // |
---|
495 | // fPattern |
---|
496 | // the pointer to the String of the pattern. The actual data is |
---|
497 | // in the Facets. |
---|
498 | // |
---|
499 | // fRegex |
---|
500 | // pointer to the RegularExpress object |
---|
501 | // |
---|
502 | // |
---|
503 | // fFixed |
---|
504 | // if {fixed} is true, then types for which this type is the |
---|
505 | // {base type definition} cannot specify a value for a specific |
---|
506 | // facet. |
---|
507 | // |
---|
508 | // fTypeName |
---|
509 | // the uri,name of the type this validator will validate |
---|
510 | // |
---|
511 | // fTypeLocalName |
---|
512 | // the name of the type this validator will validate |
---|
513 | // |
---|
514 | // fTypeUri |
---|
515 | // the uri of the type this validator will validate |
---|
516 | // fAnonymous |
---|
517 | // true if this type is anonynous |
---|
518 | // |
---|
519 | // ----------------------------------------------------------------------- |
---|
520 | bool fAnonymous; |
---|
521 | bool fFinite; |
---|
522 | bool fBounded; |
---|
523 | bool fNumeric; |
---|
524 | |
---|
525 | short fWhiteSpace; |
---|
526 | int fFinalSet; |
---|
527 | int fFacetsDefined; |
---|
528 | int fFixed; |
---|
529 | |
---|
530 | ValidatorType fType; |
---|
531 | XSSimpleTypeDefinition::ORDERING fOrdered; |
---|
532 | |
---|
533 | DatatypeValidator* fBaseValidator; |
---|
534 | RefHashTableOf<KVStringPair>* fFacets; |
---|
535 | XMLCh* fPattern; |
---|
536 | RegularExpression* fRegex; |
---|
537 | XMLCh* fTypeName; |
---|
538 | const XMLCh* fTypeLocalName; |
---|
539 | const XMLCh* fTypeUri; |
---|
540 | |
---|
541 | protected: |
---|
542 | // ----------------------------------------------------------------------- |
---|
543 | // Protected data members |
---|
544 | // |
---|
545 | // fMemoryManager |
---|
546 | // Pluggable memory manager for dynamic allocation/deallocation. |
---|
547 | // ----------------------------------------------------------------------- |
---|
548 | MemoryManager* fMemoryManager; |
---|
549 | |
---|
550 | }; |
---|
551 | |
---|
552 | |
---|
553 | // --------------------------------------------------------------------------- |
---|
554 | // DatatypeValidator: Getters |
---|
555 | // --------------------------------------------------------------------------- |
---|
556 | inline int DatatypeValidator::getFinalSet() const { |
---|
557 | |
---|
558 | return fFinalSet; |
---|
559 | } |
---|
560 | |
---|
561 | inline RefHashTableOf<KVStringPair>* DatatypeValidator::getFacets() const { |
---|
562 | |
---|
563 | return fFacets; |
---|
564 | } |
---|
565 | |
---|
566 | inline DatatypeValidator* DatatypeValidator::getBaseValidator() const { |
---|
567 | |
---|
568 | return fBaseValidator; |
---|
569 | } |
---|
570 | |
---|
571 | inline short DatatypeValidator::getWSFacet() const { |
---|
572 | |
---|
573 | return fWhiteSpace; |
---|
574 | } |
---|
575 | |
---|
576 | inline DatatypeValidator::ValidatorType DatatypeValidator::getType() const |
---|
577 | { |
---|
578 | return fType; |
---|
579 | } |
---|
580 | |
---|
581 | inline int DatatypeValidator::getFacetsDefined() const |
---|
582 | { |
---|
583 | return fFacetsDefined; |
---|
584 | } |
---|
585 | |
---|
586 | inline int DatatypeValidator::getFixed() const |
---|
587 | { |
---|
588 | return fFixed; |
---|
589 | } |
---|
590 | |
---|
591 | inline const XMLCh* DatatypeValidator::getPattern() const |
---|
592 | { |
---|
593 | return fPattern; |
---|
594 | } |
---|
595 | |
---|
596 | inline RegularExpression* DatatypeValidator::getRegex() const |
---|
597 | { |
---|
598 | return fRegex; |
---|
599 | } |
---|
600 | |
---|
601 | inline const XMLCh* DatatypeValidator::getTypeName() const |
---|
602 | { |
---|
603 | return fTypeName; |
---|
604 | } |
---|
605 | |
---|
606 | inline bool DatatypeValidator::getAnonymous() const |
---|
607 | { |
---|
608 | return fAnonymous; |
---|
609 | } |
---|
610 | |
---|
611 | inline const XMLCh* DatatypeValidator::getTypeLocalName() const |
---|
612 | { |
---|
613 | return fTypeLocalName; |
---|
614 | } |
---|
615 | |
---|
616 | inline const XMLCh* DatatypeValidator::getTypeUri() const |
---|
617 | { |
---|
618 | return fTypeUri; |
---|
619 | } |
---|
620 | |
---|
621 | inline MemoryManager* DatatypeValidator::getMemoryManager() const |
---|
622 | { |
---|
623 | return fMemoryManager; |
---|
624 | } |
---|
625 | |
---|
626 | inline XSSimpleTypeDefinition::ORDERING DatatypeValidator::getOrdered() const |
---|
627 | { |
---|
628 | return fOrdered; |
---|
629 | } |
---|
630 | |
---|
631 | inline bool DatatypeValidator::getFinite() const |
---|
632 | { |
---|
633 | return fFinite; |
---|
634 | } |
---|
635 | |
---|
636 | inline bool DatatypeValidator::getBounded() const |
---|
637 | { |
---|
638 | return fBounded; |
---|
639 | } |
---|
640 | |
---|
641 | inline bool DatatypeValidator::getNumeric() const |
---|
642 | { |
---|
643 | return fNumeric; |
---|
644 | } |
---|
645 | |
---|
646 | // --------------------------------------------------------------------------- |
---|
647 | // DatatypeValidator: Setters |
---|
648 | // --------------------------------------------------------------------------- |
---|
649 | inline void DatatypeValidator::setType(ValidatorType theType) |
---|
650 | { |
---|
651 | fType = theType; |
---|
652 | } |
---|
653 | |
---|
654 | inline void DatatypeValidator::setWhiteSpace(short newValue) |
---|
655 | { |
---|
656 | fWhiteSpace = newValue; |
---|
657 | } |
---|
658 | |
---|
659 | inline void DatatypeValidator::setFacetsDefined(int facets) |
---|
660 | { |
---|
661 | fFacetsDefined |= facets; |
---|
662 | } |
---|
663 | |
---|
664 | inline void DatatypeValidator::setFixed(int fixed) |
---|
665 | { |
---|
666 | fFixed |= fixed; |
---|
667 | } |
---|
668 | |
---|
669 | inline void DatatypeValidator::setPattern(const XMLCh* pattern) |
---|
670 | { |
---|
671 | if (fPattern) { |
---|
672 | fMemoryManager->deallocate(fPattern);//delete [] fPattern; |
---|
673 | delete fRegex; |
---|
674 | } |
---|
675 | fPattern = XMLString::replicate(pattern, fMemoryManager); |
---|
676 | fRegex = new (fMemoryManager) RegularExpression(fPattern, SchemaSymbols::fgRegEx_XOption, fMemoryManager); |
---|
677 | } |
---|
678 | |
---|
679 | inline void DatatypeValidator::setRegex(RegularExpression* const regex) |
---|
680 | { |
---|
681 | fRegex = regex; |
---|
682 | } |
---|
683 | |
---|
684 | inline bool DatatypeValidator::isAtomic() const { |
---|
685 | |
---|
686 | return true; |
---|
687 | } |
---|
688 | |
---|
689 | inline void DatatypeValidator::setAnonymous() { |
---|
690 | fAnonymous = true; |
---|
691 | } |
---|
692 | |
---|
693 | inline void DatatypeValidator::setOrdered(XSSimpleTypeDefinition::ORDERING ordered) |
---|
694 | { |
---|
695 | fOrdered = ordered; |
---|
696 | } |
---|
697 | |
---|
698 | inline void DatatypeValidator::setFinite(bool finite) |
---|
699 | { |
---|
700 | fFinite = finite; |
---|
701 | } |
---|
702 | |
---|
703 | inline void DatatypeValidator::setBounded(bool bounded) |
---|
704 | { |
---|
705 | fBounded = bounded; |
---|
706 | } |
---|
707 | |
---|
708 | inline void DatatypeValidator::setNumeric(bool numeric) |
---|
709 | { |
---|
710 | fNumeric = numeric; |
---|
711 | } |
---|
712 | |
---|
713 | // --------------------------------------------------------------------------- |
---|
714 | // DatatypeValidators: Compare methods |
---|
715 | // --------------------------------------------------------------------------- |
---|
716 | inline int DatatypeValidator::compare(const XMLCh* const lValue, |
---|
717 | const XMLCh* const rValue |
---|
718 | , MemoryManager* const) |
---|
719 | { |
---|
720 | return XMLString::compareString(lValue, rValue); |
---|
721 | } |
---|
722 | |
---|
723 | // --------------------------------------------------------------------------- |
---|
724 | // DatatypeValidators: Validation methods |
---|
725 | // --------------------------------------------------------------------------- |
---|
726 | inline bool |
---|
727 | DatatypeValidator::isSubstitutableBy(const DatatypeValidator* const toCheck) |
---|
728 | { |
---|
729 | const DatatypeValidator* dv = toCheck; |
---|
730 | |
---|
731 | while (dv != 0) { |
---|
732 | |
---|
733 | if (dv == this) { |
---|
734 | return true; |
---|
735 | } |
---|
736 | |
---|
737 | dv = dv->getBaseValidator(); |
---|
738 | } |
---|
739 | |
---|
740 | return false; |
---|
741 | } |
---|
742 | |
---|
743 | XERCES_CPP_NAMESPACE_END |
---|
744 | |
---|
745 | #endif |
---|
746 | |
---|
747 | /** |
---|
748 | * End of file DatatypeValidator.hpp |
---|
749 | */ |
---|