KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > apache > xerces > validators > datatype > AbstractNumericFacetValidator


1 /*
2  * The Apache Software License, Version 1.1
3  *
4  *
5  * Copyright (c) 1999, 2000, 2001 The Apache Software Foundation. All rights
6  * reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * 1. Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  *
15  * 2. Redistributions in binary form must reproduce the above copyright
16  * notice, this list of conditions and the following disclaimer in
17  * the documentation and/or other materials provided with the
18  * distribution.
19  *
20  * 3. The end-user documentation included with the redistribution,
21  * if any, must include the following acknowledgment:
22  * "This product includes software developed by the
23  * Apache Software Foundation (http://www.apache.org/)."
24  * Alternately, this acknowledgment may appear in the software itself,
25  * if and wherever such third-party acknowledgments normally appear.
26  *
27  * 4. The names "Xerces" and "Apache Software Foundation" must
28  * not be used to endorse or promote products derived from this
29  * software without prior written permission. For written
30  * permission, please contact apache@apache.org.
31  *
32  * 5. Products derived from this software may not be called "Apache",
33  * nor may "Apache" appear in their name, without prior written
34  * permission of the Apache Software Foundation.
35  *
36  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
37  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
38  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
39  * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
40  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
42  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
43  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
44  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
45  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
46  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
47  * SUCH DAMAGE.
48  * ====================================================================
49  *
50  * This software consists of voluntary contributions made by many
51  * individuals on behalf of the Apache Software Foundation and was
52  * originally based on software copyright (c) 2001, International
53  * Business Machines, Inc., http://www.apache.org. For more
54  * information on the Apache Software Foundation, please see
55  * <http://www.apache.org/>.
56  */

57
58 package org.enhydra.apache.xerces.validators.datatype;
59
60
61 import java.util.Enumeration JavaDoc;
62 import java.util.Hashtable JavaDoc;
63 import java.util.Vector JavaDoc;
64
65 import org.enhydra.apache.xerces.utils.regex.RegularExpression;
66 import org.enhydra.apache.xerces.validators.schema.SchemaSymbols;
67
68 /**
69  * AbstractNumericFacetValidator is a base class for decimal, double, float,
70  * and all date/time datatype validators. It implements evaluation of common facets -
71  * minInclusive, maxInclusive, minExclusive, maxExclusive according to schema specs.
72  *
73  * @author Elena Litani
74  * @version $Id: AbstractNumericFacetValidator.java,v 1.2 2005/01/26 08:28:44 jkjome Exp $
75  */

76
77 public abstract class AbstractNumericFacetValidator extends AbstractDatatypeValidator {
78
79     protected Object JavaDoc[] fEnumeration = null;
80     protected Object JavaDoc fMaxInclusive = null;
81     protected Object JavaDoc fMaxExclusive = null;
82     protected Object JavaDoc fMinInclusive = null;
83     protected Object JavaDoc fMinExclusive = null;
84
85     protected static final short INDETERMINATE=2;
86
87     public AbstractNumericFacetValidator () throws InvalidDatatypeFacetException {
88         this( null, null, false ); // Native, No Facets defined, Restriction
89
}
90
91     public AbstractNumericFacetValidator ( DatatypeValidator base,
92                                            Hashtable JavaDoc facets,
93                                            boolean derivedByList) throws InvalidDatatypeFacetException {
94         fBaseValidator = base;
95         
96         // list types are handled by ListDatatypeValidator, we do nothing here.
97
if ( derivedByList )
98             return;
99         initializeValues();
100         // Set Facets if any defined
101
if ( facets != null ) {
102             int result; // result of comparison
103
Vector JavaDoc enumeration = null;
104             for ( Enumeration JavaDoc e = facets.keys(); e.hasMoreElements(); ) {
105                 String JavaDoc key = (String JavaDoc) e.nextElement();
106                 String JavaDoc value = null;
107                 try {
108                     if ( key.equals(SchemaSymbols.ELT_PATTERN) ) {
109                         fFacetsDefined |= DatatypeValidator.FACET_PATTERN;
110                         fPattern = (String JavaDoc) facets.get(key);
111                         if ( fPattern != null )
112                             fRegex = new RegularExpression(fPattern, "X" );
113                     }
114                     else if ( key.equals(SchemaSymbols.ELT_ENUMERATION) ) {
115                         enumeration = (Vector JavaDoc)facets.get(key);
116                         fFacetsDefined |= DatatypeValidator.FACET_ENUMERATION;
117                     }
118                     else if ( key.equals(SchemaSymbols.ELT_MAXINCLUSIVE) ) {
119                         value = ((String JavaDoc) facets.get(key ));
120                         fFacetsDefined |= DatatypeValidator.FACET_MAXINCLUSIVE;
121                         setMaxInclusive(value);
122                     }
123                     else if ( key.equals(SchemaSymbols.ELT_MAXEXCLUSIVE) ) {
124                         value = ((String JavaDoc) facets.get(key ));
125                         fFacetsDefined |= DatatypeValidator.FACET_MAXEXCLUSIVE;
126                         setMaxExclusive(value);
127                     }
128                     else if ( key.equals(SchemaSymbols.ELT_MININCLUSIVE) ) {
129                         value = ((String JavaDoc) facets.get(key ));
130                         fFacetsDefined |= DatatypeValidator.FACET_MININCLUSIVE;
131                         setMinInclusive(value);
132                     }
133                     else if ( key.equals(SchemaSymbols.ELT_MINEXCLUSIVE) ) {
134                         value = ((String JavaDoc) facets.get(key ));
135                         fFacetsDefined |= DatatypeValidator.FACET_MINEXCLUSIVE;
136                         setMinExclusive(value);
137                     }
138                     else if (key.equals(DatatypeValidator.FACET_FIXED)) {// fixed flags
139
fFlags = ((Short JavaDoc)facets.get(key)).shortValue();
140                     }
141                     else {
142                         assignAdditionalFacets(key, facets);
143                     }
144                 }
145                 catch ( Exception JavaDoc ex ) {
146                     if (value == null) {
147                         //invalid facet error
148
throw new InvalidDatatypeFacetException( ex.getMessage());
149                     }
150                     else{
151                         throw new InvalidDatatypeFacetException( (getErrorString (DatatypeMessageProvider.ILLEGAL_FACET_VALUE,
152                                                                                   DatatypeMessageProvider.MSG_NONE, new Object JavaDoc [] { value, key})));
153                     }
154                 }
155             }
156              
157             if ( fFacetsDefined != 0 ) {
158                 // check 4.3.8.c1 error: maxInclusive + maxExclusive
159
if ( ((fFacetsDefined & DatatypeValidator.FACET_MAXEXCLUSIVE) != 0) &&
160                      ((fFacetsDefined & DatatypeValidator.FACET_MAXINCLUSIVE) != 0) ) {
161                     throw new InvalidDatatypeFacetException( "It is an error for both maxInclusive and maxExclusive to be specified for the same datatype." );
162                 }
163                 // check 4.3.9.c1 error: minInclusive + minExclusive
164
if ( ((fFacetsDefined & DatatypeValidator.FACET_MINEXCLUSIVE) != 0) &&
165                      ((fFacetsDefined & DatatypeValidator.FACET_MININCLUSIVE) != 0) ) {
166                     throw new InvalidDatatypeFacetException( "It is an error for both minInclusive and minExclusive to be specified for the same datatype." );
167                 }
168
169                 // check 4.3.7.c1 must: minInclusive <= maxInclusive
170
if ( ((fFacetsDefined & DatatypeValidator.FACET_MAXINCLUSIVE) != 0) &&
171                      ((fFacetsDefined & DatatypeValidator.FACET_MININCLUSIVE) != 0) ) {
172                     result = compareValues(fMinInclusive, fMaxInclusive);
173                     if ( result == 1 || result == INDETERMINATE)
174                         throw new InvalidDatatypeFacetException( "minInclusive value ='" + getMinInclusive(false) + "'must be <= maxInclusive value ='" +
175                                                                  getMaxInclusive(false) + "'. " );
176                 }
177                 // check 4.3.8.c2 must: minExclusive <= maxExclusive ??? minExclusive < maxExclusive
178
if ( ((fFacetsDefined & DatatypeValidator.FACET_MAXEXCLUSIVE) != 0) && ((fFacetsDefined & DatatypeValidator.FACET_MINEXCLUSIVE) != 0) ) {
179                     result =compareValues(fMinExclusive, fMaxExclusive);
180                     if ( result == 1 || result == INDETERMINATE)
181                         throw new InvalidDatatypeFacetException( "minExclusive value ='" + getMinExclusive(false) + "'must be <= maxExclusive value ='" +
182                                                                  getMaxExclusive(false) + "'. " );
183                 }
184                 // check 4.3.9.c2 must: minExclusive < maxInclusive
185
if ( ((fFacetsDefined & DatatypeValidator.FACET_MAXINCLUSIVE) != 0) && ((fFacetsDefined & DatatypeValidator.FACET_MINEXCLUSIVE) != 0) ) {
186                     if ( compareValues(fMinExclusive, fMaxInclusive) != -1 )
187                         throw new InvalidDatatypeFacetException( "minExclusive value ='" + getMinExclusive(false) + "'must be > maxInclusive value ='" +
188                                                                  getMaxInclusive(false) + "'. " );
189                 }
190                 // check 4.3.10.c1 must: minInclusive < maxExclusive
191
if ( ((fFacetsDefined & DatatypeValidator.FACET_MAXEXCLUSIVE) != 0) && ((fFacetsDefined & DatatypeValidator.FACET_MININCLUSIVE) != 0) ) {
192                     if ( compareValues(fMinInclusive, fMaxExclusive) != -1 )
193                         throw new InvalidDatatypeFacetException( "minInclusive value ='" + getMinInclusive(false) + "'must be < maxExclusive value ='" +
194                                                                  getMaxExclusive(false) + "'. " );
195                 }
196                 checkFacetConstraints();
197                 
198             }
199
200             if ( base != null ) {
201                 AbstractNumericFacetValidator numBase = (AbstractNumericFacetValidator)base;
202                 if ( fFacetsDefined != 0 ) {
203
204                     // check 4.3.7.c2 error:
205
// maxInclusive > base.maxInclusive
206
// maxInclusive >= base.maxExclusive
207
// maxInclusive < base.minInclusive
208
// maxInclusive <= base.minExclusive
209

210                     if ( ((fFacetsDefined & DatatypeValidator.FACET_MAXINCLUSIVE) != 0) ) {
211                         if ( ((numBase.fFacetsDefined & DatatypeValidator.FACET_MAXINCLUSIVE) != 0)){
212                              result = compareValues(fMaxInclusive, numBase.fMaxInclusive);
213                              if ((numBase.fFlags & DatatypeValidator.FACET_MAXINCLUSIVE) != 0 &&
214                                 result != 0) {
215                                 throw new InvalidDatatypeFacetException( "maxInclusive value = '" + getMaxInclusive(false) +
216                                                                          "' must be equal to base.maxInclusive value = '" +
217                                                                      getMaxInclusive(true) + "' with attribute {fixed} = true" );
218                              }
219                              if ( result == 1 || result == INDETERMINATE){
220                                 throw new InvalidDatatypeFacetException( "maxInclusive value ='" + getMaxInclusive(false) + "' must be <= base.maxInclusive value ='" +
221                                                                      getMaxInclusive(true) + "'." );
222                              }
223                         }
224                         if ( ((numBase.fFacetsDefined & DatatypeValidator.FACET_MAXEXCLUSIVE) != 0) &&
225                              compareValues(fMaxInclusive, numBase.fMaxExclusive) != -1 )
226                             throw new InvalidDatatypeFacetException(
227                                                                    "maxInclusive value ='" + getMaxInclusive(false) + "' must be < base.maxExclusive value ='" +
228                                                                    getMaxExclusive(true) + "'." );
229                         if ( (( numBase.fFacetsDefined & DatatypeValidator.FACET_MININCLUSIVE) != 0)){
230                              result = compareValues(fMaxInclusive, numBase.fMinInclusive);
231                              if (result == -1 || result == INDETERMINATE) {
232                             throw new InvalidDatatypeFacetException( "maxInclusive value ='" + getMaxInclusive(false) + "' must be >= base.minInclusive value ='" +
233                                                                      getMinInclusive(true) + "'." );
234                              }
235                         }
236                         if ( (( numBase.fFacetsDefined & DatatypeValidator.FACET_MINEXCLUSIVE) != 0) &&
237                              compareValues(fMaxInclusive, numBase.fMinExclusive ) != 1 )
238                             throw new InvalidDatatypeFacetException(
239                                                                    "maxInclusive value ='" + getMaxInclusive(false) + "' must be > base.minExclusive value ='" +
240                                                                    getMinExclusive(true) + "'." );
241                     }
242
243                     // check 4.3.8.c3 error:
244
// maxExclusive > base.maxExclusive
245
// maxExclusive > base.maxInclusive
246
// maxExclusive <= base.minInclusive
247
// maxExclusive <= base.minExclusive
248
if ( ((fFacetsDefined & DatatypeValidator.FACET_MAXEXCLUSIVE) != 0) ) {
249                         if ( (( numBase.fFacetsDefined & DatatypeValidator.FACET_MAXEXCLUSIVE) != 0)){
250                             result= compareValues(fMaxExclusive, numBase.fMaxExclusive);
251                             if ((numBase.fFlags & DatatypeValidator.FACET_MAXEXCLUSIVE) != 0 &&
252                                 result != 0) {
253                                 throw new InvalidDatatypeFacetException( "maxExclusive value = '" + getMaxExclusive(false) +
254                                                                          "' must be equal to base.maxExclusive value = '" +
255                                                                      getMaxExclusive(true) + "' with attribute {fixed} = true" );
256                              }
257                             if (result == 1 || result == INDETERMINATE) {
258                                throw new InvalidDatatypeFacetException( "maxExclusive value ='" + getMaxExclusive(false) + "' must be < base.maxExclusive value ='" +
259                                                                      getMaxExclusive(true) + "'." );
260                             }
261                         }
262                         if ( (( numBase.fFacetsDefined & DatatypeValidator.FACET_MAXINCLUSIVE) != 0)){
263                             result= compareValues(fMaxExclusive, numBase.fMaxInclusive);
264                             if (result == 1 || result == INDETERMINATE) {
265                             throw new InvalidDatatypeFacetException( "maxExclusive value ='" + getMaxExclusive(false) + "' must be <= base.maxInclusive value ='" +
266                                                                      getMaxInclusive(true) + "'." );
267                             }
268                         }
269                         if ( (( numBase.fFacetsDefined & DatatypeValidator.FACET_MINEXCLUSIVE) != 0) &&
270                              compareValues(fMaxExclusive, numBase.fMinExclusive ) != 1 )
271                             throw new InvalidDatatypeFacetException( "maxExclusive value ='" + getMaxExclusive(false) + "' must be > base.minExclusive value ='" +
272                                                                      getMinExclusive(true) + "'." );
273                         if ( (( numBase.fFacetsDefined & DatatypeValidator.FACET_MININCLUSIVE) != 0) &&
274                              compareValues(fMaxExclusive, numBase.fMinInclusive) != 1 )
275                             throw new InvalidDatatypeFacetException( "maxExclusive value ='" + getMaxExclusive(false) + "' must be > base.minInclusive value ='" +
276                                                                      getMinInclusive(true) + "'." );
277                     }
278
279                     // check 4.3.9.c3 error:
280
// minExclusive < base.minExclusive
281
// minExclusive > base.maxInclusive ??? minExclusive >= base.maxInclusive
282
// minExclusive < base.minInclusive
283
// minExclusive >= base.maxExclusive
284
if ( ((fFacetsDefined & DatatypeValidator.FACET_MINEXCLUSIVE) != 0) ) {
285                         if ( (( numBase.fFacetsDefined & DatatypeValidator.FACET_MINEXCLUSIVE) != 0)){
286                             result= compareValues(fMinExclusive, numBase.fMinExclusive);
287                             if ((numBase.fFlags & DatatypeValidator.FACET_MINEXCLUSIVE) != 0 &&
288                                 result != 0) {
289                                 throw new InvalidDatatypeFacetException( "minExclusive value = '" + getMinExclusive(false) +
290                                                                      "' must be equal to base.minExclusive value = '" +
291                                                                  getMinExclusive(true) + "' with attribute {fixed} = true" );
292                             }
293                             if (result == -1 || result == INDETERMINATE) {
294                                 throw new InvalidDatatypeFacetException( "minExclusive value ='" + getMinExclusive(false) + "' must be >= base.minExclusive value ='" +
295                                                                      getMinExclusive(true) + "'." );
296                             }
297                         }
298                         if ( (( numBase.fFacetsDefined & DatatypeValidator.FACET_MAXINCLUSIVE) != 0)){
299                              result=compareValues(fMinExclusive, numBase.fMaxInclusive);
300                              if (result == 1 || result == INDETERMINATE) {
301                             throw new InvalidDatatypeFacetException(
302                                                                    "minExclusive value ='" + getMinExclusive(false) + "' must be <= base.maxInclusive value ='" +
303                                                                    getMaxInclusive(true) + "'." );
304                              }
305                         }
306                         if ( (( numBase.fFacetsDefined & DatatypeValidator.FACET_MININCLUSIVE) != 0)){
307                              result = compareValues(fMinExclusive, numBase.fMinInclusive);
308                              if (result == -1 || result == INDETERMINATE) {
309                             throw new InvalidDatatypeFacetException(
310                                                                    "minExclusive value ='" + getMinExclusive(false) + "' must be >= base.minInclusive value ='" +
311                                                                    getMinInclusive(true) + "'." );
312                              }
313                         }
314                         if ( (( numBase.fFacetsDefined & DatatypeValidator.FACET_MAXEXCLUSIVE) != 0) &&
315                              compareValues(fMinExclusive, numBase.fMaxExclusive) != -1 )
316                             throw new InvalidDatatypeFacetException( "minExclusive value ='" + getMinExclusive(false) + "' must be < base.maxExclusive value ='" +
317                                                                      getMaxExclusive(true) + "'." );
318                     }
319
320                     // check 4.3.10.c2 error:
321
// minInclusive < base.minInclusive
322
// minInclusive > base.maxInclusive
323
// minInclusive <= base.minExclusive
324
// minInclusive >= base.maxExclusive
325
if ( ((fFacetsDefined & DatatypeValidator.FACET_MININCLUSIVE) != 0) ) {
326                         if ( ((numBase.fFacetsDefined & DatatypeValidator.FACET_MININCLUSIVE) != 0)){
327                              result = compareValues(fMinInclusive, numBase.fMinInclusive);
328                              if ((numBase.fFlags & DatatypeValidator.FACET_MININCLUSIVE) != 0 &&
329                                 result != 0) {
330                                 throw new InvalidDatatypeFacetException( "minInclusive value = '" + getMinInclusive(false) +
331                                                                      "' must be equal to base.minInclusive value = '" +
332                                                                  getMinInclusive(true) + "' with attribute {fixed} = true" );
333                              }
334                              if (result == -1 || result == INDETERMINATE){
335                                 throw new InvalidDatatypeFacetException( "minInclusive value ='" + getMinInclusive(false) + "' must be >= base.minInclusive value ='" +
336                                                                      getMinInclusive(true) + "'." );
337                              }
338                         }
339                         if ( (( numBase.fFacetsDefined & DatatypeValidator.FACET_MAXINCLUSIVE) != 0)){
340                              result=compareValues(fMinInclusive, numBase.fMaxInclusive);
341                              if (result == 1 || result == INDETERMINATE) {
342                             throw new InvalidDatatypeFacetException( "minInclusive value ='" + getMinInclusive(false) + "' must be <= base.maxInclusive value ='" +
343                                                                      getMaxInclusive(true) + "'." );
344                              }
345                         }
346                         if ( (( numBase.fFacetsDefined & DatatypeValidator.FACET_MINEXCLUSIVE) != 0) &&
347                              compareValues(fMinInclusive, numBase.fMinExclusive ) != 1 )
348                             throw new InvalidDatatypeFacetException( "minInclusive value ='" + getMinInclusive(false) + "' must be > base.minExclusive value ='" +
349                                                                      getMinExclusive(true) + "'." );
350                         if ( (( numBase.fFacetsDefined & DatatypeValidator.FACET_MAXEXCLUSIVE) != 0) &&
351                              compareValues(fMinInclusive, numBase.fMaxExclusive) != -1 )
352                             throw new InvalidDatatypeFacetException( "minInclusive value ='" + getMinInclusive(false) + "' must be < base.maxExclusive value ='" +
353                                                                      getMaxExclusive(true) + "'." );
354                     }
355                     checkBaseFacetConstraints();
356                     
357                 }
358                 // check question error: fractionDigits > base.fractionDigits ???
359
// check question error: fractionDigits > base.totalDigits ???
360
// check question error: totalDigits conflicts with bounds ???
361

362                 // inherit enumeration
363
if ( (fFacetsDefined & DatatypeValidator.FACET_ENUMERATION) == 0 &&
364                      (numBase.fFacetsDefined & DatatypeValidator.FACET_ENUMERATION) != 0 ) {
365                     fFacetsDefined |= DatatypeValidator.FACET_ENUMERATION;
366                     fEnumeration = numBase.fEnumeration;
367                 }
368                 // inherit maxExclusive
369
if ( (( numBase.fFacetsDefined & DatatypeValidator.FACET_MAXEXCLUSIVE) != 0) &&
370                      !((fFacetsDefined & DatatypeValidator.FACET_MAXEXCLUSIVE) != 0) && !((fFacetsDefined & DatatypeValidator.FACET_MAXINCLUSIVE) != 0) ) {
371                     fFacetsDefined |= FACET_MAXEXCLUSIVE;
372                     fMaxExclusive = numBase.fMaxExclusive;
373                 }
374                 // inherit maxInclusive
375
if ( (( numBase.fFacetsDefined & DatatypeValidator.FACET_MAXINCLUSIVE) != 0) &&
376                      !((fFacetsDefined & DatatypeValidator.FACET_MAXEXCLUSIVE) != 0) && !((fFacetsDefined & DatatypeValidator.FACET_MAXINCLUSIVE) != 0) ) {
377                     fFacetsDefined |= FACET_MAXINCLUSIVE;
378                     fMaxInclusive = numBase.fMaxInclusive;
379                 }
380                 // inherit minExclusive
381
if ( (( numBase.fFacetsDefined & DatatypeValidator.FACET_MINEXCLUSIVE) != 0) &&
382                      !((fFacetsDefined & DatatypeValidator.FACET_MINEXCLUSIVE) != 0) && !((fFacetsDefined & DatatypeValidator.FACET_MININCLUSIVE) != 0) ) {
383                     fFacetsDefined |= FACET_MINEXCLUSIVE;
384                     fMinExclusive = numBase.fMinExclusive;
385                 }
386                 // inherit minExclusive
387
if ( (( numBase.fFacetsDefined & DatatypeValidator.FACET_MININCLUSIVE) != 0) &&
388                      !((fFacetsDefined & DatatypeValidator.FACET_MINEXCLUSIVE) != 0) && !((fFacetsDefined & DatatypeValidator.FACET_MININCLUSIVE) != 0) ) {
389                     fFacetsDefined |= FACET_MININCLUSIVE;
390                     fMinInclusive = numBase.fMinInclusive;
391                 }
392
393                 inheritAdditionalFacets();
394                 
395                 //inherit fixed values
396
fFlags |= numBase.fFlags;
397                 
398                 // check 4.3.5.c0 must: enumeration values from the value space of base
399
if ( (fFacetsDefined & DatatypeValidator.FACET_ENUMERATION) != 0 ) {
400                     if ( enumeration != null ) {
401                         try {
402                             setEnumeration(enumeration);
403                         }
404                         catch ( Exception JavaDoc idve ) {
405                             throw new InvalidDatatypeFacetException( idve.getMessage());
406                         }
407                     }
408
409                 }
410             }
411         }//End of Facet setup
412
}
413
414
415     //
416
// Compares values in value space of give datatype
417
//
418
abstract protected int compareValues (Object JavaDoc value1, Object JavaDoc value2);
419
420     //
421
// set* functions used to set facets values
422
//
423
abstract protected void setMaxInclusive (String JavaDoc value);
424     abstract protected void setMinInclusive (String JavaDoc value);
425     abstract protected void setMaxExclusive (String JavaDoc value);
426     abstract protected void setMinExclusive (String JavaDoc value);
427     abstract protected void setEnumeration (Vector JavaDoc enumeration)
428     throws InvalidDatatypeValueException;
429
430     //
431
// get* functions used to output error messages
432
//
433
abstract protected String JavaDoc getMaxInclusive (boolean isBase);
434     abstract protected String JavaDoc getMinInclusive (boolean isBase);
435     abstract protected String JavaDoc getMaxExclusive (boolean isBase);
436     abstract protected String JavaDoc getMinExclusive (boolean isBase);
437
438     //
439
// date/times need to initialize structure objects
440
//
441
protected void initializeValues() {}
442
443     //
444
// decimal has fractionDigits and totalDigits facets
445
// all other datatypes will throw InvalidDatatypeFacetException
446
//
447
abstract protected void assignAdditionalFacets(String JavaDoc key, Hashtable JavaDoc facets)
448     throws InvalidDatatypeFacetException;
449
450     //
451
// decimal needs to inherit totalDigits and fractionDigits
452
//
453
protected void inheritAdditionalFacets() {}
454
455     //
456
// decimal needs to check constraints on totalDigits and fractionDigits
457
// check is done against fBaseValidator
458
//
459
protected void checkBaseFacetConstraints() throws InvalidDatatypeFacetException {}
460
461     //
462
// decimal needs to check constraints on totalDigits and fractionDigits
463
//
464
protected void checkFacetConstraints() throws InvalidDatatypeFacetException {}
465
466 }
467
Popular Tags