1 16 package org.apache.xerces.impl.dv.xs; 17 18 import java.math.BigInteger ; 19 20 import javax.xml.datatype.DatatypeConstants ; 21 import javax.xml.datatype.Duration ; 22 23 import org.apache.xerces.impl.dv.InvalidDatatypeValueException; 24 import org.apache.xerces.impl.dv.ValidationContext; 25 26 35 class YearMonthDurationDV extends DurationDV { 36 37 public Object getActualValue(String content, ValidationContext context) 38 throws InvalidDatatypeValueException { 39 try { 40 return parse(content, DurationDV.YEARMONTHDURATION_TYPE); 41 } 42 catch (Exception ex) { 43 throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object []{content, "yearMonthDuration"}); 44 } 45 } 46 47 protected Duration getDuration(DateTimeData date) { 48 int sign = 1; 49 if ( date.year<0 || date.month<0) { 50 sign = -1; 51 } 52 return factory.newDuration(sign == 1, 53 date.year != DatatypeConstants.FIELD_UNDEFINED?BigInteger.valueOf(sign*date.year):null, 54 date.month != DatatypeConstants.FIELD_UNDEFINED?BigInteger.valueOf(sign*date.month):null, 55 null, 56 null, 57 null, 58 null); 59 } 60 } 61 | Popular Tags |