You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by je...@locus.apache.org on 2000/09/26 01:58:45 UTC

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

jeffreyr    00/09/25 16:58:45

  Modified:    java/src/org/apache/xerces/validators/datatype
                        DoubleDatatypeValidator.java
                        FloatDatatypeValidator.java
  Log:
  Had wrong value for absolute  minimum/maximum facet values
  
  Revision  Changes    Path
  1.8       +5 -5      xml-xerces/java/src/org/apache/xerces/validators/datatype/DoubleDatatypeValidator.java
  
  Index: DoubleDatatypeValidator.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/validators/datatype/DoubleDatatypeValidator.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- DoubleDatatypeValidator.java	2000/09/07 07:39:01	1.7
  +++ DoubleDatatypeValidator.java	2000/09/25 23:58:44	1.8
  @@ -68,7 +68,7 @@
    *
    * @author Ted Leung
    * @author Jeffrey Rodriguez
  - * @version $Id: DoubleDatatypeValidator.java,v 1.7 2000/09/07 07:39:01 jeffreyr Exp $
  + * @version $Id: DoubleDatatypeValidator.java,v 1.8 2000/09/25 23:58:44 jeffreyr Exp $
    */
   
   public class DoubleDatatypeValidator extends AbstractDatatypeValidator {
  @@ -77,10 +77,10 @@
       private boolean           fDerivedByList = false; //Derived by restriction is defaul
       private double[]          fEnumDoubles      = null;
       private String            fPattern          = null;
  -    private double            fMaxInclusive     = Double.MAX_VALUE;
  -    private double            fMaxExclusive     = Double.MAX_VALUE;
  -    private double            fMinInclusive     = Double.MIN_VALUE;
  -    private double            fMinExclusive     = Double.MIN_VALUE;
  +    private double            fMaxInclusive     = Double.POSITIVE_INFINITY;
  +    private double            fMaxExclusive     = Double.POSITIVE_INFINITY;
  +    private double            fMinInclusive     = Double.NEGATIVE_INFINITY;
  +    private double            fMinExclusive     = Double.NEGATIVE_INFINITY;
       private int               fFacetsDefined    = 0;
   
       private boolean           isMaxExclusiveDefined = false;
  
  
  
  1.10      +30 -19    xml-xerces/java/src/org/apache/xerces/validators/datatype/FloatDatatypeValidator.java
  
  Index: FloatDatatypeValidator.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/validators/datatype/FloatDatatypeValidator.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- FloatDatatypeValidator.java	2000/09/07 07:47:17	1.9
  +++ FloatDatatypeValidator.java	2000/09/25 23:58:44	1.10
  @@ -70,7 +70,7 @@
    *
    * @author Ted Leung
    * @author Jeffrey Rodriguez
  - * @version  $Id: FloatDatatypeValidator.java,v 1.9 2000/09/07 07:47:17 jeffreyr Exp $
  + * @version  $Id: FloatDatatypeValidator.java,v 1.10 2000/09/25 23:58:44 jeffreyr Exp $
    */
   
   public class FloatDatatypeValidator extends AbstractDatatypeValidator {
  @@ -79,10 +79,10 @@
       private float[]   fEnumFloats           = null;
       private String    fPattern              = null;
       private boolean   fDerivedByList     = false; // Default is restriction
  -    private float     fMaxInclusive         = Float.MAX_VALUE;
  -    private float     fMaxExclusive         = Float.MAX_VALUE;
  -    private float     fMinInclusive         = Float.MIN_VALUE;
  -    private float     fMinExclusive         = Float.MIN_VALUE;
  +    private float     fMaxInclusive         = Float.POSITIVE_INFINITY ;
  +    private float     fMaxExclusive         = Float.POSITIVE_INFINITY;
  +    private float     fMinInclusive         = Float.NEGATIVE_INFINITY;
  +    private float     fMinExclusive         = Float.NEGATIVE_INFINITY;
       private int       fFacetsDefined        = 0;
   
       private boolean   isMaxExclusiveDefined = false;
  @@ -219,14 +219,24 @@
   
   
       /**
  -     * validate that a string matches the real datatype
  +     * Validate string content to be a valid float as
  +     * defined 3.2.3. Datatype.
  +     * IEEE single-precision 32-bit floatin point type
  +     * [IEEE] 754-1985]. The basic value space of float
  +     * consists of the values mx2^e, where m is an integer
  +     * whose absolute value is less than 2^24, and e
  +     * is an integer between -149 and 104 inclusive.
  +     * 
        * @param content A string containing the content to be validated
  +     * @param state
  +     * @return 
        * @exception throws InvalidDatatypeException if the content is
  -     *  is not a W3C real type
  +     *                   is not a W3C real type
  +     * @exception InvalidDatatypeValueException
        */
  -
       public Object validate(String content, Object state) 
       throws InvalidDatatypeValueException {
  +
           if ( fDerivedByList == false  ) {
               checkContent(  content );
           } else {
  @@ -257,7 +267,6 @@
           String  lowerBoundIndicator = "";
           String  upperBoundIndicator = "";
   
  -
           if ( isMaxInclusiveDefined) {
               maxOk = (d <= fMaxInclusive);
               upperBound          = Float.toString( fMaxInclusive );
  @@ -309,17 +318,8 @@
                                             upperBound, lowerBoundIndicator, upperBoundIndicator}));
   
       }
  -
  -    private void enumCheck(float v) throws InvalidDatatypeValueException {
  -        for (int i = 0; i < fEnumFloats.length; i++) {
  -            if (v == fEnumFloats[i]) return;
  -        }
  -        throw new InvalidDatatypeValueException(
  -                                               getErrorString(DatatypeMessageProvider.NotAnEnumValue,
  -                                                              DatatypeMessageProvider.MSG_NONE,
  -                                                              new Object [] { new Float(v)}));
  -    }
   
  +  
       /**
        * set the locate to be used for error messages
        */
  @@ -345,6 +345,17 @@
       public Object clone() throws CloneNotSupportedException {
           throw new CloneNotSupportedException("clone() is not supported in "+this.getClass().getName());
       }
  +
  +
  +    private void enumCheck(float v) throws InvalidDatatypeValueException {
  +       for (int i = 0; i < fEnumFloats.length; i++) {
  +           if (v == fEnumFloats[i]) return;
  +       }
  +       throw new InvalidDatatypeValueException(
  +                                              getErrorString(DatatypeMessageProvider.NotAnEnumValue,
  +                                                             DatatypeMessageProvider.MSG_NONE,
  +                                                             new Object [] { new Float(v)}));
  +   }
   
   
       private String getErrorString(int major, int minor, Object args[]) {