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

TimeDV

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

Fields Summary
Constructors Summary
Methods Summary
protected java.lang.StringdateToString(int[] date)
Converts time object representation to String

param
date time object
return
lexical representation of time: hh:mm:ss.sss with an optional time zone sign

        StringBuffer message = new StringBuffer(16);
        append(message, date[h], 2);
        message.append(':");
        append(message, date[m], 2);
        message.append(':");
        append(message, date[s], 2);
        message.append('.");
        message.append(date[ms]);
        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)
Convert a string to a compiled form

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

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

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

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

        // time
        // initialize to default values
        date[CY]=YEAR;
        date[M]=MONTH;
        date[D]=DAY;
        getTime(str, 0, len, date, timeZone);

        //validate and normalize

        validateDateTime(date, timeZone);

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