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/06/21 22:56:27 UTC
cvs commit: xml-xerces/java/src/org/apache/xerces/validators/datatype DateDatatypeValidator.java DateTimeDatatypeValidator.java DateTimeValidator.java DayDatatypeValidator.java MonthDatatypeValidator.java MonthDayDatatypeValidator.java TimeDatatypeValidator.java YearDatatypeValidator.java YearMonthDatatypeValidator.java
elena 01/06/21 13:56:27
Modified: java/src/org/apache/xerces/utils/regex RegexParser.java
java/src/org/apache/xerces/validators/datatype
DateDatatypeValidator.java
DateTimeDatatypeValidator.java
DateTimeValidator.java DayDatatypeValidator.java
MonthDatatypeValidator.java
MonthDayDatatypeValidator.java
TimeDatatypeValidator.java
YearDatatypeValidator.java
YearMonthDatatypeValidator.java
Log:
Update error reporting in date/time
Revision Changes Path
1.6 +3 -0 xml-xerces/java/src/org/apache/xerces/utils/regex/RegexParser.java
Index: RegexParser.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/utils/regex/RegexParser.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- RegexParser.java 2001/06/18 23:18:56 1.5
+++ RegexParser.java 2001/06/21 20:55:55 1.6
@@ -665,6 +665,9 @@
if (ch!='}' && ch !=',' && (ch < '0' || ch > '9')) {
throw new RuntimeException("Invalid quantifier '"+(char)ch+"' in " + regex);
}
+ //REVISIT: check for invalid quantifiers!
+ //
+
else if (ch == ',') {
if (ch == '}') {
max = -1; // {min,}
1.4 +5 -7 xml-xerces/java/src/org/apache/xerces/validators/datatype/DateDatatypeValidator.java
Index: DateDatatypeValidator.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/validators/datatype/DateDatatypeValidator.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- DateDatatypeValidator.java 2001/04/25 20:41:55 1.3
+++ DateDatatypeValidator.java 2001/06/21 20:55:59 1.4
@@ -64,7 +64,7 @@
* Validator for <date> datatype (W3C Schema datatypes)
*
* @author Elena Litani
- * @version $Id: DateDatatypeValidator.java,v 1.3 2001/04/25 20:41:55 elena Exp $
+ * @version $Id: DateDatatypeValidator.java,v 1.4 2001/06/21 20:55:59 elena Exp $
*/
public class DateDatatypeValidator extends DateTimeValidator {
@@ -101,12 +101,10 @@
parseTimeZone (fEnd, date);
//validate and normalize
- if ( !validateDateTime(date) ) {
- //REVISIT: should we throw an exeption?
- // we should not try normalizing in this case ..
- throw new SchemaDateTimeException ("Not valid date");
- }
- else if ( date[utc]!=0 && date[utc]!='Z' ) {
+ //REVISIT: do we need SchemaDateTimeException?
+ validateDateTime(date);
+
+ if ( date[utc]!=0 && date[utc]!='Z' ) {
normalize(date);
}
return date;
1.5 +7 -7 xml-xerces/java/src/org/apache/xerces/validators/datatype/DateTimeDatatypeValidator.java
Index: DateTimeDatatypeValidator.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/validators/datatype/DateTimeDatatypeValidator.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- DateTimeDatatypeValidator.java 2001/05/31 21:51:46 1.4
+++ DateTimeDatatypeValidator.java 2001/06/21 20:56:01 1.5
@@ -64,7 +64,7 @@
* Validator for <dateTime> datatype (W3C Schema Datatypes)
*
* @author Elena Litani
- * @version $Id: DateTimeDatatypeValidator.java,v 1.4 2001/05/31 21:51:46 elena Exp $
+ * @version $Id: DateTimeDatatypeValidator.java,v 1.5 2001/06/21 20:56:01 elena Exp $
*/
public class DateTimeDatatypeValidator extends DateTimeValidator {
@@ -102,12 +102,12 @@
getTime(end+1, fEnd, date);
//validate and normalize
- if ( !validateDateTime(date) ) {
- //REVISIT: should we throw an exeption?
- // we should not try normalizing in this case ..
- throw new SchemaDateTimeException ("Not valid date");
- }
- else if ( date[utc]!=0 && date[utc]!='Z') {
+
+ //REVISIT: do we need SchemaDateTimeException?
+ validateDateTime(date);
+
+
+ if ( date[utc]!=0 && date[utc]!='Z') {
normalize(date);
}
return date;
1.13 +18 -23 xml-xerces/java/src/org/apache/xerces/validators/datatype/DateTimeValidator.java
Index: DateTimeValidator.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/validators/datatype/DateTimeValidator.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- DateTimeValidator.java 2001/06/06 15:36:40 1.12
+++ DateTimeValidator.java 2001/06/21 20:56:04 1.13
@@ -72,7 +72,7 @@
* @author Elena Litani
* @author Len Berman
*
- * @version $Id: DateTimeValidator.java,v 1.12 2001/06/06 15:36:40 elena Exp $
+ * @version $Id: DateTimeValidator.java,v 1.13 2001/06/21 20:56:04 elena Exp $
*/
public abstract class DateTimeValidator extends AbstractNumericFacetValidator {
@@ -246,7 +246,7 @@
}
catch ( RuntimeException e ) {
throw new InvalidDatatypeValueException("Value '"+content+
- "' is not legal value for current datatype" );
+ "' is not legal value for current datatype. " +e.getMessage() );
}
validateDate (fDateValue, content);
return null;
@@ -523,7 +523,7 @@
getYearMonth(start, end, date);
if (fBuffer.charAt(fStart++) !='-') {
- throw new RuntimeException("CCYY-MM must be followed by '-' sign.");
+ throw new RuntimeException("CCYY-MM must be followed by '-' sign");
}
int stop = fStart + 2;
date[D]=parseInt(fStart, stop);
@@ -548,17 +548,17 @@
start++;
}
int i = indexOf(start, end, '-');
- if ( i==-1 ) throw new RuntimeException("Year separator is missing or misplaced.");
+ if ( i==-1 ) throw new RuntimeException("Year separator is missing or misplaced");
int length = i-start;
if (length<4) {
- throw new RuntimeException("Year must have 'CCYY' format.");
+ throw new RuntimeException("Year must have 'CCYY' format");
}
else if (length > 4 && fBuffer.charAt(start)=='0'){
throw new RuntimeException("Leading zeros are required if the year value would otherwise have fewer than four digits; otherwise they are forbidden");
}
date[CY]= parseIntYear(i);
if (fBuffer.charAt(i)!='-') {
- throw new RuntimeException("CCYY must be followed by '-' sign.");
+ throw new RuntimeException("CCYY must be followed by '-' sign");
}
start = ++i;
i = start +2;
@@ -660,55 +660,50 @@
* @param data
* @return
*/
- protected boolean validateDateTime (int[] data) {
+ protected void validateDateTime (int[] data) {
//REVISIT: should we throw an exception for not valid dates
// or reporting an error message should be sufficient?
if ( data[CY]==0 ) {
- System.err.println("[Error]: The year \"0000\" is an illegal year value.");
- return false;
+ throw new RuntimeException("The year \"0000\" is an illegal year value");
+
}
if ( data[M]<1 || data[M]>12 ) {
- System.err.println("[Error]: The month must have values 1 to 12.");
- return false;
+ throw new RuntimeException("The month must have values 1 to 12");
+
}
//validate days
if ( data[D]>maxDayInMonthFor(data[CY], data[M]) ) {
- System.err.println("[Error]: The day must have values 1 to 31.");
+ throw new RuntimeException("The day must have values 1 to 31");
}
//validate hours
if ( data[h]>23 || data[h]<0 ) {
- System.err.println("[Error] Hour must have values 0-23.");
- return false;
+ throw new RuntimeException("Hour must have values 0-23");
}
//validate
if ( data[m]>59 || data[m]<0 ) {
- System.err.println("[Error] Minute must have values 0-59.");
- return false;
+ throw new RuntimeException("Minute must have values 0-59");
}
//validate
if ( data[s]>60 || data[s]<0 ) {
- System.err.println("[Error] Second must have values 0-60.");
- return false;
+ throw new RuntimeException("Second must have values 0-60");
+
}
//validate
if ( timeZone[hh]>14 || timeZone[hh]<-14 ) {
- System.err.println("[Error] Time zone should have range -14..+14.");
- return false;
+ throw new RuntimeException("Time zone should have range -14..+14");
}
//validate
if ( timeZone[mm]>59 || timeZone[mm]<-59 ) {
- System.err.println("[Error] Minute must have values 0-59.");
- return false;
+ throw new RuntimeException("Minute must have values 0-59");
}
- return true;
}
1.5 +6 -6 xml-xerces/java/src/org/apache/xerces/validators/datatype/DayDatatypeValidator.java
Index: DayDatatypeValidator.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/validators/datatype/DayDatatypeValidator.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- DayDatatypeValidator.java 2001/04/25 20:41:58 1.4
+++ DayDatatypeValidator.java 2001/06/21 20:56:05 1.5
@@ -64,7 +64,7 @@
* Validator for <gDay> datatype (W3C Schema datatypes)
*
* @author Elena Litani
- * @version $Id: DayDatatypeValidator.java,v 1.4 2001/04/25 20:41:58 elena Exp $
+ * @version $Id: DayDatatypeValidator.java,v 1.5 2001/06/21 20:56:05 elena Exp $
*/
public class DayDatatypeValidator extends DateTimeValidator {
@@ -121,11 +121,11 @@
}
}
//validate and normalize
- if ( !validateDateTime(date) ) {
- //REVISIT: error message?
- throw new SchemaDateTimeException ();
- }
- else if ( date[utc]!=0 && date[utc]!='Z' ) {
+
+ //REVISIT: do we need SchemaDateTimeException?
+ validateDateTime(date);
+
+ if ( date[utc]!=0 && date[utc]!='Z' ) {
normalize(date);
}
return date;
1.5 +6 -6 xml-xerces/java/src/org/apache/xerces/validators/datatype/MonthDatatypeValidator.java
Index: MonthDatatypeValidator.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/validators/datatype/MonthDatatypeValidator.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- MonthDatatypeValidator.java 2001/06/05 23:45:55 1.4
+++ MonthDatatypeValidator.java 2001/06/21 20:56:06 1.5
@@ -63,7 +63,7 @@
* Validator for <gMonth> datatype (W3C Schema Datatypes)
*
* @author Elena Litani
- * @version $Id: MonthDatatypeValidator.java,v 1.4 2001/06/05 23:45:55 elena Exp $
+ * @version $Id: MonthDatatypeValidator.java,v 1.5 2001/06/21 20:56:06 elena Exp $
*/
public class MonthDatatypeValidator extends DateTimeValidator {
@@ -118,11 +118,11 @@
}
}
//validate and normalize
- if ( !validateDateTime(date) ) {
- //REVISIT: error message?
- throw new SchemaDateTimeException ();
- }
- else if ( date[utc]!=0 && date[utc]!='Z' ) {
+
+ //REVISIT: do we need SchemaDateTimeException?
+ validateDateTime(date);
+
+ if ( date[utc]!=0 && date[utc]!='Z' ) {
normalize(date);
}
return date;
1.5 +6 -6 xml-xerces/java/src/org/apache/xerces/validators/datatype/MonthDayDatatypeValidator.java
Index: MonthDayDatatypeValidator.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/validators/datatype/MonthDayDatatypeValidator.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- MonthDayDatatypeValidator.java 2001/06/05 23:45:56 1.4
+++ MonthDayDatatypeValidator.java 2001/06/21 20:56:07 1.5
@@ -64,7 +64,7 @@
* Validator for <gMonthDay> datatype (W3C Schema Datatypes)
*
* @author Elena Litani
- * @version $Id: MonthDayDatatypeValidator.java,v 1.4 2001/06/05 23:45:56 elena Exp $
+ * @version $Id: MonthDayDatatypeValidator.java,v 1.5 2001/06/21 20:56:07 elena Exp $
*/
public class MonthDayDatatypeValidator extends DateTimeValidator {
@@ -125,11 +125,11 @@
}
}
//validate and normalize
- if ( !validateDateTime(date) ) {
- //REVISIT: error message?
- throw new SchemaDateTimeException ();
- }
- else if ( date[utc]!=0 && date[utc]!='Z' ) {
+
+ //REVISIT: do we need SchemaDateTimeException?
+ validateDateTime(date);
+
+ if ( date[utc]!=0 && date[utc]!='Z' ) {
normalize(date);
}
return date;
1.5 +6 -7 xml-xerces/java/src/org/apache/xerces/validators/datatype/TimeDatatypeValidator.java
Index: TimeDatatypeValidator.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/validators/datatype/TimeDatatypeValidator.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- TimeDatatypeValidator.java 2001/04/25 20:42:09 1.4
+++ TimeDatatypeValidator.java 2001/06/21 20:56:10 1.5
@@ -64,7 +64,7 @@
* Validator for <time> datatype (W3C Schema Datatypes)
*
* @author Elena Litani
- * @version $Id: TimeDatatypeValidator.java,v 1.4 2001/04/25 20:42:09 elena Exp $
+ * @version $Id: TimeDatatypeValidator.java,v 1.5 2001/06/21 20:56:10 elena Exp $
*/
public class TimeDatatypeValidator extends DateTimeValidator {
@@ -106,12 +106,11 @@
getTime(fStart, fEnd, date);
//validate and normalize
- if ( !validateDateTime(date) ) {
- //REVISIT: should we throw an exeption?
- // we should not try normalizing in this case ..
- throw new SchemaDateTimeException ();
- }
- else if ( date[utc]!=0 ) {
+
+ //REVISIT: do we need SchemaDateTimeException?
+ validateDateTime(date);
+
+ if ( date[utc]!=0 ) {
normalize(date);
}
return date;
1.5 +6 -7 xml-xerces/java/src/org/apache/xerces/validators/datatype/YearDatatypeValidator.java
Index: YearDatatypeValidator.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/validators/datatype/YearDatatypeValidator.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- YearDatatypeValidator.java 2001/06/05 23:45:57 1.4
+++ YearDatatypeValidator.java 2001/06/21 20:56:11 1.5
@@ -66,7 +66,7 @@
* Validator for <gYear> datatype (W3C Schema Datatypes)
*
* @author Elena Litani
- * @version $Id: YearDatatypeValidator.java,v 1.4 2001/06/05 23:45:57 elena Exp $
+ * @version $Id: YearDatatypeValidator.java,v 1.5 2001/06/21 20:56:11 elena Exp $
*/
public class YearDatatypeValidator extends DateTimeValidator {
@@ -118,12 +118,11 @@
date[D]=1;
//validate and normalize
- if ( !validateDateTime(date) ) {
- //REVISIT: should we throw an exeption?
- // we should not try normalizing in this case ..
- throw new SchemaDateTimeException ("Not valid date: "+str);
- }
- else if ( date[utc]!=0 && date[utc]!='Z' ) {
+
+ //REVISIT: do we need SchemaDateTimeException?
+ validateDateTime(date);
+
+ if ( date[utc]!=0 && date[utc]!='Z' ) {
normalize(date);
}
return date;
1.4 +6 -7 xml-xerces/java/src/org/apache/xerces/validators/datatype/YearMonthDatatypeValidator.java
Index: YearMonthDatatypeValidator.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/validators/datatype/YearMonthDatatypeValidator.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- YearMonthDatatypeValidator.java 2001/04/25 20:42:11 1.3
+++ YearMonthDatatypeValidator.java 2001/06/21 20:56:13 1.4
@@ -65,7 +65,7 @@
* Validator for <gYearMonth> datatype (W3C Schema Datatypes)
*
* @author Elena Litani
- * @version $Id: YearMonthDatatypeValidator.java,v 1.3 2001/04/25 20:42:11 elena Exp $
+ * @version $Id: YearMonthDatatypeValidator.java,v 1.4 2001/06/21 20:56:13 elena Exp $
*/
public class YearMonthDatatypeValidator extends DateTimeValidator {
@@ -103,12 +103,11 @@
parseTimeZone (fEnd, date);
//validate and normalize
- if ( !validateDateTime(date) ) {
- //REVISIT: should we throw an exeption?
- // we should not try normalizing in this case ..
- throw new SchemaDateTimeException ("Not valid date");
- }
- else if ( date[utc]!=0 && date[utc]!='Z' ) {
+
+ //REVISIT: do we need SchemaDateTimeException?
+ validateDateTime(date);
+
+ if ( date[utc]!=0 && date[utc]!='Z' ) {
normalize(date);
}
return date;
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org