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/10/18 01:27:11 UTC

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

jeffreyr    00/10/17 16:27:11

  Modified:    java/src/org/apache/xerces/validators/datatype
                        DoubleDatatypeValidator.java
  Log:
  need this logic also in the Double type to deal with INF, -INF and NaN
  
  Revision  Changes    Path
  1.10      +13 -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.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- DoubleDatatypeValidator.java	2000/10/17 00:52:39	1.9
  +++ DoubleDatatypeValidator.java	2000/10/17 23:27:11	1.10
  @@ -69,7 +69,7 @@
    * @author Ted Leung
    * @author Jeffrey Rodriguez
    * @author Mark Swinkles - List Validation refactoring
  - * @version $Id: DoubleDatatypeValidator.java,v 1.9 2000/10/17 00:52:39 jeffreyr Exp $
  + * @version $Id: DoubleDatatypeValidator.java,v 1.10 2000/10/17 23:27:11 jeffreyr Exp $
    */
   
   public class DoubleDatatypeValidator extends AbstractDatatypeValidator {
  @@ -229,10 +229,18 @@
           try {
               d = Double.valueOf(content).doubleValue();
           } catch (NumberFormatException nfe) {
  -            throw new InvalidDatatypeValueException(
  -                                                    getErrorString(DatatypeMessageProvider.NotReal,
  -                                                                    DatatypeMessageProvider.MSG_NONE,
  -                                                                    new Object [] { content}));
  +           if( content.equals("INF") ){
  +                   d=Double.POSITIVE_INFINITY;
  +               } else if( content.equals("-INF") ){
  +                   d=Double.NEGATIVE_INFINITY;
  +               } else if( content.equals("NaN" ) ) {
  +                   d=Double.NaN;
  +               } else {
  +                   throw new InvalidDatatypeValueException(
  +                                 getErrorString(DatatypeMessageProvider.NotFloat,
  +                                                DatatypeMessageProvider.MSG_NONE,
  +                                                          new Object [] { content}));
  +               }
           }
           boundsCheck(d);