Package org.apache.xerces.impl.validation

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


            }

            if (((fFacetsDefined & DatatypeValidator.FACET_ENCODING) != 0 ) ) { //Encode defined then validate
                if ( fEncoding.equals( SchemaSymbols.ATTVAL_BASE64)) { //Base64
                    if ( Base64.isBase64( content ) == false ) {
                        throw new InvalidDatatypeValueException( "Value '"+
                                                                 content+ "'  must be" + "is not encoded in Base64" );
                    }
                } else { //HexBin
                    if ( HexBin.isHex( content ) == false ) {
                        throw new InvalidDatatypeValueException( "Value '"+
                                                                 content+ "'  must be" + "is not encoded in Hex" );
                    }
                }
            }
    }
View Full Code Here


        StringTokenizer parsedList = new StringTokenizer( content );
        try {
            int numberOfTokens =  parsedList.countTokens();
            if ((fFacetsDefined & DatatypeValidator.FACET_MAXLENGTH) != 0) {
                if (numberOfTokens > fMaxLength) {
                    throw new InvalidDatatypeValueException("Value '"+content+
                                                            "' with length ='"+  numberOfTokens + "' tokens"+
                                                            "' exceeds maximum length facet of '"+fMaxLength+"' tokens.");
                }
            }
            if ((fFacetsDefined & DatatypeValidator.FACET_MINLENGTH) != 0) {
                if (numberOfTokens < fMinLength) {
                    throw new InvalidDatatypeValueException("Value '"+content+
                                                            "' with length ='"+ numberOfTokens+ "' tokens" +
                                                            "' is less than minimum length facet of '"+fMinLength+"' tokens." );
                }
            }

            if ((fFacetsDefined & DatatypeValidator.FACET_LENGTH) != 0) {
                if (numberOfTokens != fLength) {
                    throw new InvalidDatatypeValueException("Value '"+content+
                                                            "' with length ='"+ numberOfTokens+ "' tokens" +
                                                            "' is not equal to length facet of '"+fLength+"' tokens.");
                }
            }

            if ((fFacetsDefined & DatatypeValidator.FACET_ENUMERATION) != 0) {
                // Enumerations are defined in the value space so the contains method
                // of vector doesn't really do the right thing, we really should check using compare
                if (fEnumeration.contains( content ) == false)
                    throw new InvalidDatatypeValueException("Value '"+
                                                            content+"' must be one of "+fEnumeration);
            }
            try {
                if (this.fDerivedByList) {
                    if( numberOfTokens == 0 ){
                        InvalidDatatypeValueException error = new InvalidDatatypeValueException( content );
                        throw error;
                    }
                    while (parsedList.hasMoreTokens()) {       //Check each token in list against base type
                        if (this.fBaseValidator != null) {//validate against parent type if any
                            this.fBaseValidator.validate( parsedList.nextToken(), state );
                        }
                    }
                } else {
                    if (this.fBaseValidator != null) {//validate against parent type if any
                        this.fBaseValidator.validate( content, state );
                    }
                }
            } catch (InvalidDatatypeValueException ex) { //Keep bubbling up exception but change content to list content
                                                         //Unfortunately we need to throw a new Exception
                InvalidDatatypeValueException error = new InvalidDatatypeValueException( content );//Need Message
                error.setKeyIntoReporter( ex.getKeyIntoReporter() );
                throw error;//type message repacked with the List content message
            }

        } catch (NoSuchElementException e) {
            e.printStackTrace();
View Full Code Here

     */
    public void validate(String content, Object state ) throws InvalidDatatypeValueException{

        boolean status;
        if ((status = XMLChar.isValidName(content) ) == false) {//Check if is valid key-[81] EncName ::= [A-Za-z] ([A-Za-z0-9._] | '-')*
            InvalidDatatypeValueException error =  new
                                                   InvalidDatatypeValueException( content );
            error.setKeyIntoReporter( "IDInvalid" );
            throw error;
        }
        if (!addId( content)) { //It is OK to pass a null here
            InvalidDatatypeValueException error =
            new InvalidDatatypeValueException( content );
            error.setKeyIntoReporter( "IDNotUnique" );
            throw error;
        }
    }
View Full Code Here

    * @see         org.apache.xerces.validators.datatype.InvalidDatatypeValueException
    */
   public void validate(String content, Object state ) throws InvalidDatatypeValueException{
      //Pass content as a String
      if (!XMLChar.isValidName(content)) {//Check if is valid key
         InvalidDatatypeValueException error = new InvalidDatatypeValueException( content );//Need Message
         error.setKeyIntoReporter( "IDREFInvalid" );
         throw error;//Need Message
      }
      addIdRef( content, state);// We are storing IDs
   }
View Full Code Here

      while (en.hasMoreElements()) {
         String key = (String)en.nextElement();
         if ( this.fTableOfId == null || ! this.fTableOfId.containsKey(key)) {

            InvalidDatatypeValueException error =  new
                                                   InvalidDatatypeValueException( key );
            error.setKeyIntoReporter("MSG_ELEMENT_WITH_ID_REQUIRED" );
            throw error;
         }
      }

   } // checkIdRefs()
View Full Code Here

     * @see org.apache.xerces.validators.datatype.InvalidDatatypeValueException
     */
    public void validate(String content, Object state ) throws InvalidDatatypeValueException{
        int entityDeclIndex = -1;
        if (fGrammar == null) {
            InvalidDatatypeValueException error =
            new InvalidDatatypeValueException();//Need Message
            error.setKeyIntoReporter( "ENTITYFailedInitializeGrammar");
            throw error;
        }

        fEntityDecl.clear();//Reset Entity Decl struct

        entityDeclIndex = fGrammar.getEntityDeclIndex( content );

        if (entityDeclIndex > -1) {
            fGrammar.getEntityDecl( entityDeclIndex, fEntityDecl );
            if (fEntityDecl.notation == null) {// not unparsed entity
                InvalidDatatypeValueException error =
                new InvalidDatatypeValueException( content );
                error.setKeyIntoReporter( "ENTITYNotUnparsed" );
                throw error;
            }
        } else {
            InvalidDatatypeValueException error =
            new InvalidDatatypeValueException( content );
            error.setKeyIntoReporter( "ENTITYNotValid" );
            throw error;
        }
    }
View Full Code Here

    * @exception InvalidDatatypeValueException
    */
   public void validate(String content, Object state
        throws InvalidDatatypeValueException {
       if (!XMLChar.isValidNmtoken(content)) {
           throw new InvalidDatatypeValueException(content+" is not a NMTOKEN");
       }
   }
View Full Code Here

         this.fBaseValidator.validate( content, state );
      }

      if ( (fFacetsDefined & DatatypeValidator.FACET_MAXLENGTH) != 0 ) {
         if ( content.length() > fMaxLength ) {
            throw new InvalidDatatypeValueException("Value '"+content+
                                                    "' with length '"+content.length()+
                                                    "' exceeds maximum length facet of '"+fMaxLength+"'.");
         }
      }
      if ( (fFacetsDefined & DatatypeValidator.FACET_MINLENGTH) != 0 ) {
         if ( content.length() < fMinLength ) {
            throw new InvalidDatatypeValueException("Value '"+content+
                                                    "' with length '"+content.length()+
                                                    "' is less than minimum length facet of '"+fMinLength+"'." );
         }
      }

      if ( (fFacetsDefined & DatatypeValidator.FACET_LENGTH) != 0 ) {
         if ( content.length() != fLength ) {
            throw new InvalidDatatypeValueException("Value '"+content+
                                                    "' with length '"+content.length()+
                                                    "' is not equal to length facet '"+fLength+"'.");
         }
      }



      if ( (fFacetsDefined & DatatypeValidator.FACET_ENUMERATION) != 0 ) {
         if ( fEnumeration.contains( content ) == false )
            throw new InvalidDatatypeValueException("Value '"+content+"' must be one of "+fEnumeration);
      }
      /*  Per October 23 CR - facets don't apply to StringValidator
      if ( isMaxExclusiveDefined == true ) {
          int comparisonResult;
          comparisonResult  = compare( content, fMaxExclusive );
View Full Code Here

TOP

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

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.