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