FileDocCategorySizeDatePackage
YearDV.javaAPI DocApache Xerces 3.0.14058Fri Sep 14 20:33:54 BST 2007org.apache.xerces.impl.dv.xs

YearDV

public class YearDV extends AbstractDateTimeDV
Validator for <gYear> datatype (W3C Schema Datatypes)
xerces.internal
author
Elena Litani
author
Gopal Sharma, SUN Microsystem Inc.
version
$Id: YearDV.java 446745 2006-09-15 21:43:58Z mrglavas $

Fields Summary
Constructors Summary
Methods Summary
protected java.lang.StringdateToString(DateTimeData date)
Converts year object representation to String

param
date year object
return
lexical representation of month: CCYY with optional time zone sign

        StringBuffer message = new StringBuffer(5);
        append(message, date.year, 4);
        append(message, (char)date.utc, 0);
        return message.toString();
    
public java.lang.ObjectgetActualValue(java.lang.String content, org.apache.xerces.impl.dv.ValidationContext context)
Convert a string to a compiled form

param
content The lexical representation of time
return
a valid and normalized time object

        try{
            return parse(content);
        } catch(Exception ex){
            throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object[]{content, "gYear"});
        }
    
protected javax.xml.datatype.XMLGregorianCalendargetXMLGregorianCalendar(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 DateTimeDataparse(java.lang.String str)
Parses, validates and computes normalized version of gYear object

param
str The lexical representation of year object CCYY with possible time zone Z or (-),(+)hh:mm
return
normalized date representation
exception
SchemaDateTimeException Invalid lexical representation

        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;