Package org.apache.xerces.impl.validation

Examples of org.apache.xerces.impl.validation.InvalidDatatypeFacetException


        } catch (InvocationTargetException e) {
            if (fDebug) {
                System.out.println("!! The original error message is: " + e.getTargetException().getMessage() );
                e.getTargetException().printStackTrace();
            } else {
                throw new InvalidDatatypeFacetException( e.getTargetException().getMessage() );
                //System.out.println("Exception: " + e.getTargetException
                //validator = null;
            }
        }
        return validator;
View Full Code Here


                        String value = null;
                        try {
                            value  = ((String)facets.get(key));
                            fMaxInclusive = Float.valueOf(value).floatValue();
                        } catch (NumberFormatException ex ) {
                            throw new InvalidDatatypeFacetException( getErrorString(
                                                                                   DatatypeMessageProvider.IllegalFacetValue,
                                                                                   DatatypeMessageProvider.MSG_NONE, new Object [] { value, key}));
                        }
                    } else if (key.equals(SchemaSymbols.ELT_MAXEXCLUSIVE)) {
                        fFacetsDefined += DatatypeValidator.FACET_MAXEXCLUSIVE;
                        String value = null;
                        try {
                            value  = ((String)facets.get(key));
                            fMaxExclusive = Float.valueOf(value).floatValue();
                        } catch (NumberFormatException ex ) {
                            throw new InvalidDatatypeFacetException( getErrorString(
                                                                                   DatatypeMessageProvider.IllegalFacetValue,
                                                                                   DatatypeMessageProvider.MSG_NONE, new Object [] { value, key}));
                        }
                    } else if (key.equals(SchemaSymbols.ELT_MININCLUSIVE)) {
                        fFacetsDefined += DatatypeValidator.FACET_MININCLUSIVE;
                        String value = null;
                        try {
                            value  = ((String)facets.get(key));
                            fMinInclusive  = Float.valueOf(value).floatValue();
                        } catch (NumberFormatException ex ) {
                            throw new InvalidDatatypeFacetException( getErrorString(
                                                                                   DatatypeMessageProvider.IllegalFacetValue,
                                                                                   DatatypeMessageProvider.MSG_NONE, new Object [] { value, key}));
                        }
                    } else if (key.equals(SchemaSymbols.ELT_MINEXCLUSIVE)) {
                        fFacetsDefined += DatatypeValidator.FACET_MININCLUSIVE;
                        String value = null;
                        try {
                            value  = ((String)facets.get(key));
                            fMinExclusive  = Float.valueOf(value).floatValue();
                        } catch (NumberFormatException ex ) {
                            throw new InvalidDatatypeFacetException( getErrorString(
                                                                                   DatatypeMessageProvider.IllegalFacetValue,
                                                                                   DatatypeMessageProvider.MSG_NONE, new Object [] { value, key}));
                        }
                    } else {
                        throw new InvalidDatatypeFacetException( getErrorStringDatatypeMessageProvider.MSG_FORMAT_FAILURE,
                                                                                  DatatypeMessageProvider.MSG_NONE,
                                                                                  null));
                    }
                }
                isMaxExclusiveDefined = ((fFacetsDefined &
                                          DatatypeValidator.FACET_MAXEXCLUSIVE ) != 0 )?true:false;
                isMaxInclusiveDefined = ((fFacetsDefined &
                                          DatatypeValidator.FACET_MAXINCLUSIVE ) != 0 )?true:false;
                isMinExclusiveDefined = ((fFacetsDefined &
                                          DatatypeValidator.FACET_MINEXCLUSIVE ) != 0 )?true:false;
                isMinInclusiveDefined = ((fFacetsDefined &
                                          DatatypeValidator.FACET_MININCLUSIVE ) != 0 )?true:false;


                if ( isMaxExclusiveDefined && isMaxInclusiveDefined ) {
                    throw new InvalidDatatypeFacetException(
                                                           "It is an error for both maxInclusive and maxExclusive to be specified for the same datatype." );
                }
                if ( isMinExclusiveDefined && isMinInclusiveDefined ) {
                    throw new InvalidDatatypeFacetException(
                                                           "It is an error for both minInclusive and minExclusive to be specified for the same datatype." );
                }



                if ( (fFacetsDefined & DatatypeValidator.FACET_ENUMERATION ) != 0 ) {
                    Vector v = (Vector) facets.get(SchemaSymbols.ELT_ENUMERATION);   
                    if (v != null) {
                        fEnumFloats = new float[v.size()];
                        for (int i = 0; i < v.size(); i++)
                            try {
                                fEnumFloats[i] = Float.valueOf((String) v.elementAt(i)).floatValue();
                                boundsCheck(fEnumFloats[i]); // Check against max,min Inclusive, Exclusives
                            } catch (InvalidDatatypeValueException idve) {
                                throw new InvalidDatatypeFacetException(
                                                                       getErrorString(DatatypeMessageProvider.InvalidEnumValue,
                                                                                      DatatypeMessageProvider.MSG_NONE,
                                                                                      new Object [] { v.elementAt(i)}));
                            } catch (NumberFormatException nfe) {
                                System.out.println("Internal Error parsing enumerated values for real type");
View Full Code Here

                        String value = null;
                        try {
                            value  = ((String)facets.get(key));
                            fMaxInclusive = Double.valueOf(value).doubleValue();
                        } catch (NumberFormatException ex ) {
                            throw new InvalidDatatypeFacetException( getErrorString(
                                                                                   DatatypeMessageProvider.IllegalFacetValue,
                                                                                   DatatypeMessageProvider.MSG_NONE, new Object [] { value, key}));
                        }
                    } else if (key.equals(SchemaSymbols.ELT_MAXEXCLUSIVE)) {
                        fFacetsDefined += DatatypeValidator.FACET_MAXEXCLUSIVE;
                        String value = null;
                        try {
                            value  = ((String)facets.get(key));
                            fMaxExclusive = Double.valueOf(value).doubleValue();
                        } catch (NumberFormatException ex ) {
                            throw new InvalidDatatypeFacetException( getErrorString(
                                                                                   DatatypeMessageProvider.IllegalFacetValue,
                                                                                   DatatypeMessageProvider.MSG_NONE, new Object [] { value, key}));
                        }
                    } else if (key.equals(SchemaSymbols.ELT_MININCLUSIVE)) {
                        fFacetsDefined += DatatypeValidator.FACET_MININCLUSIVE;
                        String value = null;
                        try {
                            value  = ((String)facets.get(key));
                            fMinInclusive  = Double.valueOf(value).doubleValue();
                        } catch (NumberFormatException ex ) {
                            throw new InvalidDatatypeFacetException( getErrorString(
                                                                                   DatatypeMessageProvider.IllegalFacetValue,
                                                                                   DatatypeMessageProvider.MSG_NONE, new Object [] { value, key}));
                        }
                    } else if (key.equals(SchemaSymbols.ELT_MINEXCLUSIVE)) {
                        fFacetsDefined += DatatypeValidator.FACET_MININCLUSIVE;
                        String value = null;
                        try {
                            value  = ((String)facets.get(key));
                            fMinExclusive  = Double.valueOf(value).doubleValue();
                        } catch (NumberFormatException ex ) {
                            throw new InvalidDatatypeFacetException( getErrorString(
                                                                                   DatatypeMessageProvider.IllegalFacetValue,
                                                                                   DatatypeMessageProvider.MSG_NONE, new Object [] { value, key}));
                        }
                    } else {
                        throw new InvalidDatatypeFacetException( getErrorStringDatatypeMessageProvider.MSG_FORMAT_FAILURE,
                                                                                  DatatypeMessageProvider.MSG_NONE,
                                                                                  null));
                    }
                }
                isMaxExclusiveDefined = ((fFacetsDefined &
                                          DatatypeValidator.FACET_MAXEXCLUSIVE ) != 0 )?true:false;
                isMaxInclusiveDefined = ((fFacetsDefined &
                                          DatatypeValidator.FACET_MAXINCLUSIVE ) != 0 )?true:false;
                isMinExclusiveDefined = ((fFacetsDefined &
                                          DatatypeValidator.FACET_MINEXCLUSIVE ) != 0 )?true:false;
                isMinInclusiveDefined = ((fFacetsDefined &
                                          DatatypeValidator.FACET_MININCLUSIVE ) != 0 )?true:false;


                if ( isMaxExclusiveDefined && isMaxInclusiveDefined ) {
                    throw new InvalidDatatypeFacetException(
                                                           "It is an error for both maxInclusive and maxExclusive to be specified for the same datatype." );
                }
                if ( isMinExclusiveDefined && isMinInclusiveDefined ) {
                    throw new InvalidDatatypeFacetException(
                                                           "It is an error for both minInclusive and minExclusive to be specified for the same datatype." );
                }



                if ( (fFacetsDefined & DatatypeValidator.FACET_ENUMERATION ) != 0 ) {
                    Vector v = (Vector) facets.get(SchemaSymbols.ELT_ENUMERATION);   
                    if (v != null) {
                        fEnumDoubles = new double[v.size()];
                        for (int i = 0; i < v.size(); i++)
                            try {
                                fEnumDoubles[i] = Double.valueOf((String) v.elementAt(i)).doubleValue();
                                boundsCheck(fEnumDoubles[i]); // Check against max,min Inclusive, Exclusives
                            } catch (InvalidDatatypeValueException idve) {
                                throw new InvalidDatatypeFacetException(
                                                                       getErrorString(DatatypeMessageProvider.InvalidEnumValue,
                                                                                      DatatypeMessageProvider.MSG_NONE,
                                                                                      new Object [] { v.elementAt(i)}));
                            } catch (NumberFormatException nfe) {
                                System.out.println("Internal Error parsing enumerated values for real type");
View Full Code Here

                        fFacetsDefined += DatatypeValidator.FACET_LENGTH;
                        String lengthValue = (String)facets.get(key);
                        try {
                            fLength     = Integer.parseInt( lengthValue );
                        } catch (NumberFormatException nfe) {
                            throw new InvalidDatatypeFacetException("Length value '"+lengthValue+"' is invalid.");
                        }
                        if ( fLength < 0 )
                            throw new InvalidDatatypeFacetException("Length value '"+lengthValue+"'  must be a nonNegativeInteger.");

                    } else if (key.equals(SchemaSymbols.ELT_MINLENGTH) ) {
                        fFacetsDefined += DatatypeValidator.FACET_MINLENGTH;
                        String minLengthValue = (String)facets.get(key);
                        try {
                            fMinLength     = Integer.parseInt( minLengthValue );
                        } catch (NumberFormatException nfe) {
                            throw new InvalidDatatypeFacetException("maxLength value '"+minLengthValue+"' is invalid.");
                        }
                    } else if (key.equals(SchemaSymbols.ELT_MAXLENGTH) ) {
                        fFacetsDefined += DatatypeValidator.FACET_MAXLENGTH;
                        String maxLengthValue = (String)facets.get(key);
                        try {
                            fMaxLength     = Integer.parseInt( maxLengthValue );
                        } catch (NumberFormatException nfe) {
                            throw new InvalidDatatypeFacetException("maxLength value '"+maxLengthValue+"' is invalid.");
                        }
                    } else if (key.equals(SchemaSymbols.ELT_PATTERN)) {
                        fFacetsDefined += DatatypeValidator.FACET_PATTERN;
                        fPattern = (String)facets.get(key);
                        if ( fPattern != null )
                            fRegex = new RegularExpression(fPattern, "X" );

                    } else if (key.equals(SchemaSymbols.ELT_ENUMERATION)) {
                        fFacetsDefined += DatatypeValidator.FACET_ENUMERATION;
                        fEnumeration = (Vector)facets.get(key);
                    } else {
                        throw new InvalidDatatypeFacetException();
                    }
                }

                if (((fFacetsDefined & DatatypeValidator.FACET_LENGTH ) != 0 ) ) {
                    if (((fFacetsDefined & DatatypeValidator.FACET_MAXLENGTH ) != 0 ) ) {
                        throw new InvalidDatatypeFacetException(
                                                               "It is an error for both length and maxLength to be members of facets." )
                    } else if (((fFacetsDefined & DatatypeValidator.FACET_MINLENGTH ) != 0 ) ) {
                        throw new InvalidDatatypeFacetException(
                                                               "It is an error for both length and minLength to be members of facets." );
                    }
                }

                if ( ( (fFacetsDefined & ( DatatypeValidator.FACET_MINLENGTH |
                                           DatatypeValidator.FACET_MAXLENGTH) ) != 0 ) ) {
                    if ( fMinLength > fMaxLength ) {
                        throw new InvalidDatatypeFacetException( "Value of maxLength = " + fMaxLength +
                                                                 "must be greater that the value of minLength" + fMinLength );
                    }
                }
        }// End of Facets Setting
View Full Code Here

        } else if ( isMinExclusiveDefined ) {
            inLowerBound = ( f >  fMinExclusive );
        }

        if ( inUpperBound == false  || inLowerBound == false ) { // within bounds ?
            throw new InvalidDatatypeFacetException(
                                                   getErrorString(DatatypeMessageProvider.OutOfBounds,
                                                                  DatatypeMessageProvider.MSG_NONE,
                                                                  new Object [] { new Long(f),"","","",""}));//Revisit
        }
    }
View Full Code Here

                    fFacetsDefined += DatatypeValidator.FACET_LENGTH;
                    String lengthValue = (String)facets.get(key);
                    try {
                        fLength     = Integer.parseInt( lengthValue );
                    } catch (NumberFormatException nfe) {
                        throw new InvalidDatatypeFacetException("Length value '"+lengthValue+"' is invalid.");
                    }
                    if (fLength < 0)
                        throw new InvalidDatatypeFacetException("Length value '"+lengthValue+"'  must be a nonNegativeInteger.");

                } else if (key.equals(SchemaSymbols.ELT_MINLENGTH)) {
                    fFacetsDefined += DatatypeValidator.FACET_MINLENGTH;
                    String minLengthValue = (String)facets.get(key);
                    try {
                        fMinLength     = Integer.parseInt( minLengthValue );
                    } catch (NumberFormatException nfe) {
                        throw new InvalidDatatypeFacetException("maxLength value '"+minLengthValue+"' is invalid.");
                    }
                } else if (key.equals(SchemaSymbols.ELT_MAXLENGTH)) {
                    fFacetsDefined += DatatypeValidator.FACET_MAXLENGTH;
                    String maxLengthValue = (String)facets.get(key);
                    try {
                        fMaxLength     = Integer.parseInt( maxLengthValue );
                    } catch (NumberFormatException nfe) {
                        throw new InvalidDatatypeFacetException("maxLength value '"+maxLengthValue+"' is invalid.");
                    }
                } else if (key.equals(SchemaSymbols.ELT_ENUMERATION)) {
                    fFacetsDefined += DatatypeValidator.FACET_ENUMERATION;
                    fEnumeration    = (Vector)facets.get(key);
                } else {
                    throw new InvalidDatatypeFacetException("invalid facet tag : " + key);
                }
            }
            if (((fFacetsDefined & DatatypeValidator.FACET_LENGTH ) != 0 )) {
                if (((fFacetsDefined & DatatypeValidator.FACET_MAXLENGTH ) != 0 )) {
                    throw new InvalidDatatypeFacetException(
                                                           "It is an error for both length and maxLength to be members of facets." )
                } else if (((fFacetsDefined & DatatypeValidator.FACET_MINLENGTH ) != 0 )) {
                    throw new InvalidDatatypeFacetException(
                                                           "It is an error for both length and minLength to be members of facets." );
                }
            }

            if (( (fFacetsDefined & ( DatatypeValidator.FACET_MINLENGTH |
                                      DatatypeValidator.FACET_MAXLENGTH) ) != 0 )) {
                if (fMinLength > fMaxLength) {
                    throw new InvalidDatatypeFacetException( "Value of minLength = " + fMinLength +
                                                             "must be greater that the value of maxLength" + fMaxLength );
                }
            }
        }// End of Facets Setting
    }
View Full Code Here

                            value = ((String) facets.get(key ));
                            fFacetsDefined += DatatypeValidator.FACET_SCALE;
                            isScaleDefined  = true;
                            fScale          = Integer.parseInt( value );
                        } else {
                            throw new InvalidDatatypeFacetException(
                                                                   getErrorString( DatatypeMessageProvider.MSG_FORMAT_FAILURE,
                                                                                   DatatypeMessageProvider.MSG_NONE, null));
                        }
                    } catch ( Exception ex ){
                        throw new InvalidDatatypeFacetException( getErrorString(
                                                                               DatatypeMessageProvider.IllegalFacetValue,
                                                                               DatatypeMessageProvider.MSG_NONE, new Object [] { value, key}));
                    }
                }
                isMaxExclusiveDefined = ((fFacetsDefined &
                                          DatatypeValidator.FACET_MAXEXCLUSIVE ) != 0 )?true:false;
                isMaxInclusiveDefined = ((fFacetsDefined &
                                          DatatypeValidator.FACET_MAXINCLUSIVE ) != 0 )?true:false;

                isMinExclusiveDefined = ((fFacetsDefined &
                                          DatatypeValidator.FACET_MINEXCLUSIVE ) != 0 )?true:false;
                isMinInclusiveDefined = ((fFacetsDefined &
                                          DatatypeValidator.FACET_MININCLUSIVE ) != 0 )?true:false;

                //checkForFacetConsistency( base );// Check the current facets against base facets

                if ( isMaxExclusiveDefined && isMaxInclusiveDefined ) {
                    throw new InvalidDatatypeFacetException(
                                                           "It is an error for both maxInclusive and maxExclusive to be specified for the same datatype." );
                }
                if ( isMinExclusiveDefined && isMinInclusiveDefined ) {
                    throw new InvalidDatatypeFacetException(
                                                           "It is an error for both minInclusive and minExclusive to be specified for the same datatype." );
                }

                if ( isMaxExclusiveDefined && isMinExclusiveDefined ){
                    int compareTo = this.fMaxExclusive.compareTo( this.fMinExclusive );
                    if ( compareTo != 1)
                        throw new InvalidDatatypeFacetException(
                                                               "maxExclusive value ='" + this.fMaxExclusive + "'must be > than minExclusive value ='" +
                                                               this.fMinExclusive + "'. " );

                }
                if ( isMaxInclusiveDefined && isMinInclusiveDefined ){
                    int compareTo = this.fMaxInclusive.compareTo( this.fMinInclusive );

                    if ( compareTo == -)
                        throw new InvalidDatatypeFacetException(
                                                               "maxInclusive value ='" + this.fMaxInclusive + "'must be >= than minInclusive value ='" +
                                                               this.fMinInclusive + "'. " );
                }


                if ( isMaxExclusiveDefined && isMinInclusiveDefined ){
                    int compareTo = this.fMaxExclusive.compareTo( this.fMinInclusive );
                    if ( compareTo != 1)
                        throw new InvalidDatatypeFacetException(
                                                               "maxExclusive value ='" + this.fMaxExclusive + "'must be > than minInclusive value ='" +
                                                               this.fMinInclusive + "'. " );

                }
                if ( isMaxInclusiveDefined && isMinExclusiveDefined ){
                    int compareTo = this.fMaxInclusive.compareTo( this.fMinExclusive );
                    if ( compareTo != 1)
                        throw new InvalidDatatypeFacetException(
                                                               "maxInclusive value ='" + this.fMaxInclusive + "'must be > than minExclusive value ='" +
                                                               this.fMinExclusive + "'. " );
                }


                if ( (fFacetsDefined & DatatypeValidator.FACET_ENUMERATION ) != 0 ) {
                    if (enumeration != null) {
                        fEnumDecimal = new BigDecimal[enumeration.size()];
                        int i = 0;
                        try {
                            for ( ; i < enumeration.size(); i++) {
                                fEnumDecimal[i] =
                                new BigDecimal( stripPlusIfPresent(((String) enumeration.elementAt(i))));
                                boundsCheck(fEnumDecimal[i]); // Check against max,min Inclusive, Exclusives
                            }

                        } catch ( Exception idve ){
                            throw new InvalidDatatypeFacetException(
                                                                   getErrorString(DatatypeMessageProvider.InvalidEnumValue,
                                                                                  DatatypeMessageProvider.MSG_NONE,
                                                                                  new Object [] { enumeration.elementAt(i)}));
                        }
View Full Code Here

                        fFacetsDefined += DatatypeValidator.FACET_LENGTH;
                        String lengthValue = (String)facets.get(key);
                        try {
                            fLength     = Integer.parseInt( lengthValue );
                        } catch (NumberFormatException nfe) {
                            throw new InvalidDatatypeFacetException("Length value '"+lengthValue+"' is invalid.");
                        }
                        if ( fLength < 0 )
                            throw new InvalidDatatypeFacetException("Length value '"+lengthValue+"'  must be a nonNegativeInteger.");

                    } else if (key.equals(SchemaSymbols.ELT_MINLENGTH) ) {
                        fFacetsDefined += DatatypeValidator.FACET_MINLENGTH;
                        String minLengthValue = (String)facets.get(key);
                        try {
                            fMinLength     = Integer.parseInt( minLengthValue );
                        } catch (NumberFormatException nfe) {
                            throw new InvalidDatatypeFacetException("maxLength value '"+minLengthValue+"' is invalid.");
                        }
                    } else if (key.equals(SchemaSymbols.ELT_MAXLENGTH) ) {
                        fFacetsDefined += DatatypeValidator.FACET_MAXLENGTH;
                        String maxLengthValue = (String)facets.get(key);
                        try {
                            fMaxLength     = Integer.parseInt( maxLengthValue );
                        } catch (NumberFormatException nfe) {
                            throw new InvalidDatatypeFacetException("maxLength value '"+maxLengthValue+"' is invalid.");
                        }
                    } else if (key.equals(SchemaSymbols.ELT_PATTERN)) {
                        fFacetsDefined += DatatypeValidator.FACET_PATTERN;
                        fPattern = (String)facets.get(key);
                        fRegex   = new RegularExpression(fPattern, "X");
                    } else if (key.equals(SchemaSymbols.ELT_ENUMERATION)) {
                        fFacetsDefined += DatatypeValidator.FACET_ENUMERATION;
                        fEnumeration = (Vector)facets.get(key);
                    } else if (key.equals(SchemaSymbols.ELT_MAXINCLUSIVE)) {
                        fFacetsDefined += DatatypeValidator.FACET_MAXINCLUSIVE;
                        fMaxInclusive = (String)facets.get(key);
                    } else if (key.equals(SchemaSymbols.ELT_MAXEXCLUSIVE)) {
                        fFacetsDefined += DatatypeValidator.FACET_MAXEXCLUSIVE;
                        fMaxExclusive = (String)facets.get(key);
                    } else if (key.equals(SchemaSymbols.ELT_MININCLUSIVE)) {
                        fFacetsDefined += DatatypeValidator.FACET_MININCLUSIVE;
                        fMinInclusive = (String)facets.get(key);
                    } else if (key.equals(SchemaSymbols.ELT_MINEXCLUSIVE)) {
                        fFacetsDefined += DatatypeValidator.FACET_MINEXCLUSIVE;
                        fMinExclusive = (String)facets.get(key);
                    } else {
                        throw new InvalidDatatypeFacetException();
                    }
                }

                if (((fFacetsDefined & DatatypeValidator.FACET_LENGTH ) != 0 ) ) {
                    if (((fFacetsDefined & DatatypeValidator.FACET_MAXLENGTH ) != 0 ) ) {
                        throw new InvalidDatatypeFacetException(
                                                               "It is an error for both length and maxLength to be members of facets." )
                    } else if (((fFacetsDefined & DatatypeValidator.FACET_MINLENGTH ) != 0 ) ) {
                        throw new InvalidDatatypeFacetException(
                                                               "It is an error for both length and minLength to be members of facets." );
                    }
                }

                if ( ( (fFacetsDefined & ( DatatypeValidator.FACET_MINLENGTH |
                                           DatatypeValidator.FACET_MAXLENGTH) ) != 0 ) ) {
                    if ( fMinLength > fMaxLength ) {
                        throw new InvalidDatatypeFacetException( "Value of maxLength = " + fMaxLength +
                                                                 "must be greater that the value of minLength" + fMinLength );
                    }
                }

                isMaxExclusiveDefined = ((fFacetsDefined &
                                          DatatypeValidator.FACET_MAXEXCLUSIVE ) != 0 )?true:false;
                isMaxInclusiveDefined = ((fFacetsDefined &
                                          DatatypeValidator.FACET_MAXINCLUSIVE ) != 0 )?true:false;
                isMinExclusiveDefined = ((fFacetsDefined &
                                          DatatypeValidator.FACET_MINEXCLUSIVE ) != 0 )?true:false;
                isMinInclusiveDefined = ((fFacetsDefined &
                                          DatatypeValidator.FACET_MININCLUSIVE ) != 0 )?true:false;

                if ( isMaxExclusiveDefined && isMaxInclusiveDefined ) {
                    throw new InvalidDatatypeFacetException(
                                                           "It is an error for both maxInclusive and maxExclusive to be specified for the same datatype." );
                }
                if ( isMinExclusiveDefined && isMinInclusiveDefined ) {
                    throw new InvalidDatatypeFacetException(
                                                           "It is an error for both minInclusive and minExclusive to be specified for the same datatype." );
                }
        }// End of Facets Setting

View Full Code Here

        } catch (InvocationTargetException e) {
            if (fDebug) {
                System.out.println("!! The original error message is: " + e.getTargetException().getMessage() );
                e.getTargetException().printStackTrace();
            } else {
                throw new InvalidDatatypeFacetException( e.getTargetException().getMessage() );
                //System.out.println("Exception: " + e.getTargetException
                //validator = null;
            }
        }
        return validator;
View Full Code Here

               fFacetsDefined += DatatypeValidator.FACET_LENGTH;
               String lengthValue = (String)facets.get(key);
               try {
                  fLength     = Integer.parseInt( lengthValue );
               } catch (NumberFormatException nfe) {
                  throw new InvalidDatatypeFacetException("Length value '"+lengthValue+"' is invalid.");
               }
               if ( fLength < 0 )
                  throw new InvalidDatatypeFacetException("Length value '"+lengthValue+"'  must be a nonNegativeInteger.");

            } else if (key.equals(SchemaSymbols.ELT_MINLENGTH) ) {
               fFacetsDefined += DatatypeValidator.FACET_MINLENGTH;
               String minLengthValue = (String)facets.get(key);
               try {
                  fMinLength     = Integer.parseInt( minLengthValue );
               } catch (NumberFormatException nfe) {
                  throw new InvalidDatatypeFacetException("minLength value '"+minLengthValue+"' is invalid.");
               }
            } else if (key.equals(SchemaSymbols.ELT_MAXLENGTH) ) {
               fFacetsDefined += DatatypeValidator.FACET_MAXLENGTH;
               String maxLengthValue = (String)facets.get(key);
               try {
                  fMaxLength     = Integer.parseInt( maxLengthValue );
               } catch (NumberFormatException nfe) {
                  throw new InvalidDatatypeFacetException("maxLength value '"+maxLengthValue+"' is invalid.");
               }
            } else if (key.equals(SchemaSymbols.ELT_PATTERN)) {
               fFacetsDefined += DatatypeValidator.FACET_PATTERN;
               fPattern = (String)facets.get(key);
               fRegex   = new RegularExpression(fPattern, "X");
            } else if (key.equals(SchemaSymbols.ELT_ENUMERATION)) {
               fFacetsDefined += DatatypeValidator.FACET_ENUMERATION;
               fEnumeration = (Vector)facets.get(key);
               /* Per Schema CR - October 23 spec we don't have this facets in String datatype
           } else if (key.equals(SchemaSymbols.ELT_MAXINCLUSIVE)) {
               fFacetsDefined += DatatypeValidator.FACET_MAXINCLUSIVE;
               fMaxInclusive = (String)facets.get(key);
           } else if (key.equals(SchemaSymbols.ELT_MAXEXCLUSIVE)) {
               fFacetsDefined += DatatypeValidator.FACET_MAXEXCLUSIVE;
               fMaxExclusive = (String)facets.get(key);
           } else if (key.equals(SchemaSymbols.ELT_MININCLUSIVE)) {
               fFacetsDefined += DatatypeValidator.FACET_MININCLUSIVE;
               fMinInclusive = (String)facets.get(key);
           } else if (key.equals(SchemaSymbols.ELT_MINEXCLUSIVE)) {
               fFacetsDefined += DatatypeValidator.FACET_MINEXCLUSIVE;
               fMinExclusive = (String)facets.get(key);
               */
            } else if (key.equals(SchemaSymbols.ELT_WHITESPACE)) {
               String         whiteSpaceChoice = (String)facets.get(key);
               fFacetsDefined += DatatypeValidator.FACET_WHITESPACE;
               if ( whiteSpaceChoice.equals("preserve" ) ) {
                  fWhiteSpace = DatatypeValidator.WHITESPACE_PRESERVE;
               } else if ( whiteSpaceChoice.equals("replace") ) {
                  fWhiteSpace = DatatypeValidator.WHITESPACE_REPLACE;
               } else if ( whiteSpaceChoice.equals("collapse") ) {
                  fWhiteSpace = DatatypeValidator.WHITESPACE_COLLAPSE;
               }
            } else {
               throw new InvalidDatatypeFacetException("invalid facet tag : " + key);
            }
         }

         if (((fFacetsDefined & DatatypeValidator.FACET_LENGTH ) != 0 ) ) {
            if (((fFacetsDefined & DatatypeValidator.FACET_MAXLENGTH ) != 0 ) ) {
               throw new InvalidDatatypeFacetException(
                                                      "It is an error for both length and maxLength to be members of facets." )
            } else if (((fFacetsDefined & DatatypeValidator.FACET_MINLENGTH ) != 0 ) ) {
               throw new InvalidDatatypeFacetException(
                                                      "It is an error for both length and minLength to be members of facets." );
            }
         }

         if ( ( (fFacetsDefined & ( DatatypeValidator.FACET_MINLENGTH |
                                    DatatypeValidator.FACET_MAXLENGTH) ) != 0 ) ) {
            if ( fMinLength > fMaxLength ) {
               throw new InvalidDatatypeFacetException( "Value of minLength = '" + fMinLength +
                                                        "'must be less than the value of maxLength = '" + fMaxLength + "'.");
            }
         }

         isMaxExclusiveDefined = ((fFacetsDefined &
                                   DatatypeValidator.FACET_MAXEXCLUSIVE ) != 0 )?true:false;
         isMaxInclusiveDefined = ((fFacetsDefined &
                                   DatatypeValidator.FACET_MAXINCLUSIVE ) != 0 )?true:false;
         isMinExclusiveDefined = ((fFacetsDefined &
                                   DatatypeValidator.FACET_MINEXCLUSIVE ) != 0 )?true:false;
         isMinInclusiveDefined = ((fFacetsDefined &
                                   DatatypeValidator.FACET_MININCLUSIVE ) != 0 )?true:false;

         if ( isMaxExclusiveDefined && isMaxInclusiveDefined ) {
            throw new InvalidDatatypeFacetException(
                                                   "It is an error for both maxInclusive and maxExclusive to be specified for the same datatype." );
         }
         if ( isMinExclusiveDefined && isMinInclusiveDefined ) {
            throw new InvalidDatatypeFacetException(
                                                   "It is an error for both minInclusive and minExclusive to be specified for the same datatype." );
         }

      }// End of Facets Setting
   }
View Full Code Here

TOP

Related Classes of org.apache.xerces.impl.validation.InvalidDatatypeFacetException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.