YearDVpublic class YearDV extends AbstractDateTimeDV Validator for <gYear> datatype (W3C Schema Datatypes) |
Methods Summary |
---|
protected java.lang.String | dateToString(DateTimeData date)Converts year object representation to String
StringBuffer message = new StringBuffer(5);
append(message, date.year, 4);
append(message, (char)date.utc, 0);
return message.toString();
| public java.lang.Object | getActualValue(java.lang.String content, org.apache.xerces.impl.dv.ValidationContext context)Convert a string to a compiled form
try{
return parse(content);
} catch(Exception ex){
throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object[]{content, "gYear"});
}
| protected javax.xml.datatype.XMLGregorianCalendar | getXMLGregorianCalendar(DateTimeData date)
return factory.newXMLGregorianCalendar(date.unNormYear, DatatypeConstants.FIELD_UNDEFINED, DatatypeConstants.FIELD_UNDEFINED
, DatatypeConstants.FIELD_UNDEFINED, DatatypeConstants.FIELD_UNDEFINED, DatatypeConstants.FIELD_UNDEFINED, DatatypeConstants.FIELD_UNDEFINED, date.timezoneHr * 60 + date.timezoneMin);
| protected DateTimeData | parse(java.lang.String str)Parses, validates and computes normalized version of gYear object
DateTimeData date = new DateTimeData(str, this);
int len = str.length();
// check for preceding '-' sign
int start = 0;
if (str.charAt(0)=='-") {
start = 1;
}
int sign = findUTCSign(str, start, len);
if (sign == -1) {
date.year=parseIntYear(str, len);
}
else {
date.year=parseIntYear(str, sign);
getTimeZone (str, date, sign, len);
}
//initialize values
date.month=MONTH;
date.day=1;
//validate and normalize
validateDateTime(date);
//save unnormalized values
saveUnnormalized(date);
if ( date.utc!=0 && date.utc!='Z" ) {
normalize(date);
}
date.position = 0;
return date;
|
|