1 57 58 package com.sun.org.apache.xerces.internal.impl.dv.xs; 59 60 import com.sun.org.apache.xerces.internal.impl.dv.InvalidDatatypeValueException; 61 import com.sun.org.apache.xerces.internal.impl.dv.ValidationContext; 62 63 71 public class YearMonthDV extends AbstractDateTimeDV{ 72 73 79 public Object getActualValue(String content, ValidationContext context) throws InvalidDatatypeValueException{ 80 try{ 81 return new DateTimeData(parse(content), this); 82 } catch(Exception ex){ 83 throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object []{content, "gYearMonth"}); 84 } 85 } 86 87 96 protected int[] parse(String str) throws SchemaDateTimeException{ 97 int len = str.length(); 98 int[] date = new int[TOTAL_SIZE]; 99 int[] timeZone = new int[2]; 100 101 int end = getYearMonth(str, 0, len, date); 103 date[D] = DAY; 104 parseTimeZone (str, end, len, date, timeZone); 105 106 108 validateDateTime(date, timeZone); 109 110 if ( date[utc]!=0 && date[utc]!='Z' ) { 111 normalize(date, timeZone); 112 } 113 return date; 114 } 115 116 protected String dateToString(int[] date) { 117 StringBuffer message = new StringBuffer (25); 118 append(message, date[CY], 4); 119 message.append('-'); 120 append(message, date[M], 2); 121 append(message, (char)date[utc], 0); 122 return message.toString(); 123 } 124 125 } 126 127 128 | Popular Tags |