You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by an...@apache.org on 2004/11/29 19:21:45 UTC

cvs commit: xml-xerces/java/src/org/apache/xerces/impl/dv/xs YearDV.java TimeDV.java DateTimeDV.java DateDV.java MonthDayDV.java AbstractDateTimeDV.java DurationDV.java YearMonthDV.java MonthDV.java

ankitp      2004/11/29 10:21:45

  Modified:    java/src/org/apache/xerces/impl/dv/xs YearDV.java
                        TimeDV.java DateTimeDV.java DateDV.java
                        MonthDayDV.java AbstractDateTimeDV.java
                        DurationDV.java YearMonthDV.java MonthDV.java
  Log:
  fixes for date/time comparisons
  
  Revision  Changes    Path
  1.14      +2 -22     xml-xerces/java/src/org/apache/xerces/impl/dv/xs/YearDV.java
  
  Index: YearDV.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/dv/xs/YearDV.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- YearDV.java	25 Nov 2004 22:03:49 -0000	1.13
  +++ YearDV.java	29 Nov 2004 18:21:45 -0000	1.14
  @@ -82,28 +82,9 @@
           if ( date.utc!=0 && date.utc!='Z' ) {
               normalize(date);
           }
  +        date.position = 0;
           return date;
       }
  -    
  -    /**
  -     * Given normalized values, determines order-relation
  -     * between give date/time objects.
  -     *
  -     * @param date1  date/time object
  -     * @param date2  date/time object
  -     * @return 0 if date1 and date2 are equal, a value less than 0 if date1 is less than date2, a value greater than 0 if date1 is greater than date2
  -     */
  -    protected short compareOrder(DateTimeData date1, DateTimeData date2) {
  -        if (date1.year < date2.year)
  -            return -1;
  -        if (date1.year > date2.year)
  -            return 1;
  -        if (date1.utc < date2.utc)
  -            return -1;
  -        if (date1.utc > date2.utc)
  -            return 1;
  -        return 0;
  -    }
   
       /**
        * Converts year object representation to String
  @@ -117,7 +98,6 @@
           append(message, (char)date.utc, 0);
           return message.toString();
       }
  -
   }
   
   
  
  
  
  1.15      +22 -30    xml-xerces/java/src/org/apache/xerces/impl/dv/xs/TimeDV.java
  
  Index: TimeDV.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/dv/xs/TimeDV.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- TimeDV.java	25 Nov 2004 22:03:49 -0000	1.14
  +++ TimeDV.java	29 Nov 2004 18:21:45 -0000	1.15
  @@ -62,7 +62,7 @@
           // initialize to default values
           date.year=YEAR;
           date.month=MONTH;
  -        date.day=DAY;
  +        date.day=15;
           getTime(str, 0, len, date);
   
           //validate and normalize
  @@ -72,36 +72,9 @@
           if ( date.utc!=0 ) {
               normalize(date);
           }
  +        date.position = 2;
           return date;
       }
  -    
  -    /**
  -     * Given normalized values, determines order-relation
  -     * between give date/time objects.
  -     *
  -     * @param date1  date/time object
  -     * @param date2  date/time object
  -     * @return 0 if date1 and date2 are equal, a value less than 0 if date1 is less than date2, a value greater than 0 if date1 is greater than date2
  -     */
  -    protected short compareOrder(DateTimeData date1, DateTimeData date2) {
  -        if (date1.hour < date2.hour)
  -            return -1;
  -        if (date1.hour > date2.hour)
  -            return 1;
  -        if (date1.minute < date2.minute)
  -            return -1;
  -        if (date1.minute > date2.minute)
  -            return 1;
  -        if (date1.second < date2.second)
  -            return -1;
  -        if (date1.second > date2.second)
  -            return 1;
  -        if (date1.utc < date2.utc)
  -            return -1;
  -        if (date1.utc > date2.utc)
  -            return 1;
  -        return 0;
  -    }
   
       /**
        * Converts time object representation to String
  @@ -120,5 +93,24 @@
           append(message, (char)date.utc, 0);
           return message.toString();
       }
  +
  +	/* (non-Javadoc)
  +	 * @see org.apache.xerces.impl.dv.xs.AbstractDateTimeDV#compareOrder2(org.apache.xerces.impl.dv.xs.AbstractDateTimeDV.DateTimeData, org.apache.xerces.impl.dv.xs.AbstractDateTimeDV.DateTimeData)
  +	 */
  +	protected short compareOrder2(DateTimeData date1, DateTimeData date2) {
  +        if (date1.hour < date2.hour)
  +            return -1;
  +        if (date1.hour > date2.hour)
  +            return 1;
  +        if (date1.minute < date2.minute)
  +            return -1;
  +        if (date1.minute > date2.minute)
  +            return 1;
  +        if (date1.second < date2.second)
  +            return -1;
  +        if (date1.second > date2.second)
  +            return 1;
  +        return 0;
  +	}
   
   }
  
  
  
  1.13      +1 -2      xml-xerces/java/src/org/apache/xerces/impl/dv/xs/DateTimeDV.java
  
  Index: DateTimeDV.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/dv/xs/DateTimeDV.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- DateTimeDV.java	6 Oct 2004 14:56:47 -0000	1.12
  +++ DateTimeDV.java	29 Nov 2004 18:21:45 -0000	1.13
  @@ -74,5 +74,4 @@
           }
           return date;
       }
  -
   }
  
  
  
  1.16      +1 -27     xml-xerces/java/src/org/apache/xerces/impl/dv/xs/DateDV.java
  
  Index: DateDV.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/dv/xs/DateDV.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- DateDV.java	25 Nov 2004 22:03:49 -0000	1.15
  +++ DateDV.java	29 Nov 2004 18:21:45 -0000	1.16
  @@ -62,32 +62,6 @@
           }
           return date;
       }
  -    
  -    /**
  -     * Given normalized values, determines order-relation
  -     * between give date/time objects.
  -     *
  -     * @param date1  date/time object
  -     * @param date2  date/time object
  -     * @return 0 if date1 and date2 are equal, a value less than 0 if date1 is less than date2, a value greater than 0 if date1 is greater than date2
  -     */
  -    protected short compareOrder(DateTimeData date1, DateTimeData date2) {
  -        if (date1.year < date2.year)
  -            return -1;
  -        if (date1.year > date2.year)
  -            return 1;
  -        if (date1.month < date2.month)
  -            return -1;
  -        if (date1.month > date2.month)
  -            return 1;
  -        if (date1.day < date2.day)
  -            return -1;
  -        if (date1.day > date2.day)
  -            return 1;
  -        if (date1.utc > date2.utc)
  -            return 1;
  -        return 0;
  -    }
   
       protected String dateToString(DateTimeData date) {
           StringBuffer message = new StringBuffer(25);
  
  
  
  1.14      +2 -26     xml-xerces/java/src/org/apache/xerces/impl/dv/xs/MonthDayDV.java
  
  Index: MonthDayDV.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/dv/xs/MonthDayDV.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- MonthDayDV.java	25 Nov 2004 22:03:49 -0000	1.13
  +++ MonthDayDV.java	29 Nov 2004 18:21:45 -0000	1.14
  @@ -92,32 +92,9 @@
           if ( date.utc!=0 && date.utc!='Z' ) {
               normalize(date);
           }
  +        date.position = 1;
           return date;
       }
  -    
  -    /**
  -     * Given normalized values, determines order-relation
  -     * between give date/time objects.
  -     *
  -     * @param date1  date/time object
  -     * @param date2  date/time object
  -     * @return 0 if date1 and date2 are equal, a value less than 0 if date1 is less than date2, a value greater than 0 if date1 is greater than date2
  -     */
  -    protected short compareOrder(DateTimeData date1, DateTimeData date2) {
  -        if (date1.month < date2.month)
  -            return -1;
  -        if (date1.month > date2.month)
  -            return 1;
  -        if (date1.day < date2.day)
  -            return -1;
  -        if (date1.day > date2.day)
  -            return 1;
  -        if (date1.utc < date2.utc)
  -            return -1;
  -        if (date1.utc > date2.utc)
  -            return 1;
  -        return 0;
  -    }
   
       /**
        * Converts gMonthDay object representation to String
  @@ -135,6 +112,5 @@
           append(message, (char)date.utc, 0);
           return message.toString();
       }
  -
   }
   
  
  
  
  1.23      +23 -11    xml-xerces/java/src/org/apache/xerces/impl/dv/xs/AbstractDateTimeDV.java
  
  Index: AbstractDateTimeDV.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/dv/xs/AbstractDateTimeDV.java,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- AbstractDateTimeDV.java	17 Nov 2004 20:19:36 -0000	1.22
  +++ AbstractDateTimeDV.java	29 Nov 2004 18:21:45 -0000	1.23
  @@ -50,7 +50,7 @@
       //all date/time excluding duration
       protected final static int YEAR=2000;
       protected final static int MONTH=01;
  -    protected final static int DAY = 15;
  +    protected final static int DAY = 01;
   
       public short getAllowedFacets(){
           return ( XSSimpleTypeDecl.FACET_PATTERN | XSSimpleTypeDecl.FACET_WHITESPACE | XSSimpleTypeDecl.FACET_ENUMERATION |XSSimpleTypeDecl.FACET_MAXINCLUSIVE |XSSimpleTypeDecl.FACET_MININCLUSIVE | XSSimpleTypeDecl.FACET_MAXEXCLUSIVE  | XSSimpleTypeDecl.FACET_MINEXCLUSIVE  );
  @@ -94,7 +94,7 @@
        */
       protected short compareDates(DateTimeData date1, DateTimeData date2, boolean strict) {
           if (date1.utc == date2.utc) {
  -            return compareOrder(date1, date2);
  +            return compareOrder2(date1, date2);
           }
           short c1, c2;
   
  @@ -165,6 +165,10 @@
           return INDETERMINATE;
   
       }
  +    
  +    protected short compareOrder2(DateTimeData date1, DateTimeData date2) {
  +    	return compareOrder(date1, date2);
  +    }
   
       /**
        * Given normalized values, determines order-relation
  @@ -175,14 +179,18 @@
        * @return 0 if date1 and date2 are equal, a value less than 0 if date1 is less than date2, a value greater than 0 if date1 is greater than date2
        */
       protected short compareOrder(DateTimeData date1, DateTimeData date2) {
  -        if (date1.year < date2.year)
  -            return -1;
  -        if (date1.year > date2.year)
  -            return 1;
  -        if (date1.month < date2.month)
  -            return -1;
  -        if (date1.month > date2.month)
  -            return 1;
  +        if(date1.position < 1) {
  +            if (date1.year < date2.year)
  +                return -1;
  +            if (date1.year > date2.year)
  +                return 1;
  +        }
  +        if(date1.position < 2) {
  +            if (date1.month < date2.month)
  +                return -1;
  +            if (date1.month > date2.month)
  +                return 1;
  +        }
           if (date1.day < date2.day)
               return -1;
           if (date1.day > date2.day)
  @@ -788,6 +796,10 @@
           int year, month, day, hour, minute, utc;
           double second;
           int timezoneHr, timezoneMin;
  +        
  +        // used for comparisons - to decide the 'interesting' portions of
  +        // a date/time based data type.
  +        int position;
           // a pointer to the type that was used go generate this data
           // note that this is not the actual simple type, but one of the
           // statically created XXXDV objects, so this won't cause any GC problem.
  
  
  
  1.15      +1 -2      xml-xerces/java/src/org/apache/xerces/impl/dv/xs/DurationDV.java
  
  Index: DurationDV.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/dv/xs/DurationDV.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- DurationDV.java	25 Nov 2004 19:24:06 -0000	1.14
  +++ DurationDV.java	29 Nov 2004 18:21:45 -0000	1.15
  @@ -202,7 +202,6 @@
   
           //add constA to both durations
           short resultA, resultB= INDETERMINATE;
  -
           //try and see if the objects are equal
           resultA = compareOrder (date1, date2);
           if ( resultA == 0 ) {
  
  
  
  1.14      +2 -26     xml-xerces/java/src/org/apache/xerces/impl/dv/xs/YearMonthDV.java
  
  Index: YearMonthDV.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/dv/xs/YearMonthDV.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- YearMonthDV.java	25 Nov 2004 22:03:49 -0000	1.13
  +++ YearMonthDV.java	29 Nov 2004 18:21:45 -0000	1.14
  @@ -69,32 +69,9 @@
           if ( date.utc!=0 && date.utc!='Z' ) {
               normalize(date);
           }
  +        date.position = 0;
           return date;
       }
  -    
  -    /**
  -     * Given normalized values, determines order-relation
  -     * between give date/time objects.
  -     *
  -     * @param date1  date/time object
  -     * @param date2  date/time object
  -     * @return 0 if date1 and date2 are equal, a value less than 0 if date1 is less than date2, a value greater than 0 if date1 is greater than date2
  -     */
  -    protected short compareOrder(DateTimeData date1, DateTimeData date2) {
  -        if (date1.year < date2.year)
  -            return -1;
  -        if (date1.year > date2.year)
  -            return 1;
  -        if (date1.month < date2.month)
  -            return -1;
  -        if (date1.month > date2.month)
  -            return 1;
  -        if (date1.utc < date2.utc)
  -            return -1;
  -        if (date1.utc > date2.utc)
  -            return 1;
  -        return 0;
  -    }
   
       protected String dateToString(DateTimeData date) {
           StringBuffer message = new StringBuffer(25);
  @@ -104,7 +81,6 @@
           append(message, (char)date.utc, 0);
           return message.toString();
       }
  -
   }
   
   
  
  
  
  1.16      +2 -22     xml-xerces/java/src/org/apache/xerces/impl/dv/xs/MonthDV.java
  
  Index: MonthDV.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/dv/xs/MonthDV.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- MonthDV.java	25 Nov 2004 22:03:49 -0000	1.15
  +++ MonthDV.java	29 Nov 2004 18:21:45 -0000	1.16
  @@ -89,28 +89,9 @@
           if ( date.utc!=0 && date.utc!='Z' ) {
               normalize(date);
           }
  +        date.position = 1;
           return date;
       }
  -    
  -    /**
  -     * Given normalized values, determines order-relation
  -     * between give date/time objects.
  -     *
  -     * @param date1  date/time object
  -     * @param date2  date/time object
  -     * @return 0 if date1 and date2 are equal, a value less than 0 if date1 is less than date2, a value greater than 0 if date1 is greater than date2
  -     */
  -    protected short compareOrder(DateTimeData date1, DateTimeData date2) {
  -        if (date1.month < date2.month)
  -            return -1;
  -        if (date1.month > date2.month)
  -            return 1;
  -        if (date1.utc < date2.utc)
  -            return -1;
  -        if (date1.utc > date2.utc)
  -            return 1;
  -        return 0;
  -    }
   
       /**
        * Overwrite compare algorithm to optimize month comparison
  @@ -168,5 +149,4 @@
           append(message, (char)date.utc, 0);
           return message.toString();
       }
  -
   }
  
  
  

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