FileDocCategorySizeDatePackage
DayDV.javaAPI DocJava SE 5 API5520Fri Aug 26 14:55:48 BST 2005com.sun.org.apache.xerces.internal.impl.dv.xs

DayDV

public class DayDV extends AbstractDateTimeDV
Validator for datatype (W3C Schema datatypes)
author
Elena Litani
author
Gopal Sharma, SUN Microsystem Inc.
version
$Id: DayDV.java,v 1.7 2003/01/16 18:34:04 sandygao Exp $

Fields Summary
private static final int
DAY_SIZE
Constructors Summary
Methods Summary
protected java.lang.StringdateToString(int[] date)
Converts gDay object representation to String

param
date gDay object
return
lexical representation of gDay: ---DD with an optional time zone sign

        StringBuffer message = new StringBuffer(6);
        message.append('-");
        message.append('-");
        message.append('-");
        append(message, date[D], 2);
        append(message, (char)date[utc], 0);
        return message.toString();
    
public java.lang.ObjectgetActualValue(java.lang.String content, com.sun.org.apache.xerces.internal.impl.dv.ValidationContext context)


            
        try{
            return new DateTimeData(parse(content), this);
        } catch(Exception ex){
            throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object[]{content, "gDay"});
        }
    
protected int[]parse(java.lang.String str)
Parses, validates and computes normalized version of gDay object

param
str The lexical representation of gDay object ---DD with possible time zone Z or (-),(+)hh:mm Pattern: ---(\\d\\d)(Z|(([-+])(\\d\\d)(:(\\d\\d))?
param
date uninitialized date object
return
normalized date representation
exception
SchemaDateTimeException Invalid lexical representation

        int len = str.length();
        int[] date=new int[TOTAL_SIZE];
        int[] timeZone = new int[2];

        if (str.charAt(0)!='-" || str.charAt(1)!='-" || str.charAt(2)!='-") {
            throw new SchemaDateTimeException ("Error in day parsing");
        }

        //initialize values
        date[CY]=YEAR;
        date[M]=MONTH;

        date[D]=parseInt(str, 3,5);

        if ( DAY_SIZE<len ) {
            int sign = findUTCSign(str, DAY_SIZE, len);
            if ( sign<0 ) {
                throw new SchemaDateTimeException ("Error in day parsing");
            }
            else {
                getTimeZone(str, date, sign, len, timeZone);
            }
        }

       //validate and normalize
        validateDateTime(date, timeZone);

        if ( date[utc]!=0 && date[utc]!='Z" ) {
            normalize(date, timeZone);
        }
        return date;