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