You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by el...@apache.org on 2001/03/12 15:23:24 UTC

cvs commit: xml-xerces/java/src/org/apache/xerces/validators/datatype URIReferenceDatatypeValidator.java

elena       01/03/12 06:23:23

  Modified:    java/src/org/apache/xerces/validators/datatype
                        URIReferenceDatatypeValidator.java
  Log:
  Added validation against facets
  
  Revision  Changes    Path
  1.11      +24 -3     xml-xerces/java/src/org/apache/xerces/validators/datatype/URIReferenceDatatypeValidator.java
  
  Index: URIReferenceDatatypeValidator.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/validators/datatype/URIReferenceDatatypeValidator.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- URIReferenceDatatypeValidator.java	2000/10/17 00:52:40	1.10
  +++ URIReferenceDatatypeValidator.java	2001/03/12 14:23:18	1.11
  @@ -78,7 +78,7 @@
    * @author Mark Swinkles - List Validation refactoring
    * @see          RFC 2396 
    * @see Tim Berners-Lee, et. al. RFC 2396: Uniform Resource Identifiers (URI): Generic Syntax.. 1998 Available at: http://www.ietf.org/rfc/rfc2396.txt 
  - * @version  $Id: URIReferenceDatatypeValidator.java,v 1.10 2000/10/17 00:52:40 jeffreyr Exp $
  + * @version  $Id: URIReferenceDatatypeValidator.java,v 1.11 2001/03/12 14:23:18 elena Exp $
    */
   public class URIReferenceDatatypeValidator extends AbstractDatatypeValidator {
       private DatatypeValidator fBaseValidator     = null;
  @@ -186,16 +186,37 @@
       {
           StringTokenizer parsedList = null;
           URI             uriContent = null;
  -
  +        int length=content.length();
           if ( (fFacetsDefined & DatatypeValidator.FACET_PATTERN ) != 0 ) {
               if ( fRegex == null || fRegex.matches( content) == false )
                   throw new InvalidDatatypeValueException("Value '"+content+
                                                           "' does not match regular expression facet" + fPattern );
           }
  +        if ( (fFacetsDefined & DatatypeValidator.FACET_MAXLENGTH) != 0 ) {
  +            if ( length > fMaxLength ) {
  +                throw new InvalidDatatypeValueException("Value '"+content+
  +                                                        "' with length '"+content.length()+
  +                                                        "' exceeds maximum length facet of '"+fMaxLength+"'.");
  +            }
  +        }
  +        if ( (fFacetsDefined & DatatypeValidator.FACET_MINLENGTH) != 0 ) {
  +            if ( 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 ( length != fLength ) {
  +                throw new InvalidDatatypeValueException("Value '"+content+
  +                                                        "' with length '"+content.length()+
  +                                                        "' is not equal to length facet '"+fLength+"'.");
  +            }
  +        }
              
           try {
  -            if( content.trim().length() != 0 ) //Validate non null URI 
  +            if( length != 0 ) //Validate non null URI
                   uriContent = new URI( content );
               //else it is valid anyway
           } catch (  URI.MalformedURIException ex ) {
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org