com.thaiopensource.datatype.xsd
Class DurationDatatype

java.lang.Object
  extended by com.thaiopensource.datatype.xsd.DatatypeBase
      extended by com.thaiopensource.datatype.xsd.TokenDatatype
          extended by com.thaiopensource.datatype.xsd.RegexDatatype
              extended by com.thaiopensource.datatype.xsd.DurationDatatype
All Implemented Interfaces:
Datatype2, Measure, OrderRelation, Datatype

 class DurationDatatype
extends RegexDatatype
implements OrderRelation


Nested Class Summary
private static class DurationDatatype.Duration
           
 
Field Summary
private static String PATTERN
           
private static int[] REF_YEAR_MONTHS
           
 
Fields inherited from class com.thaiopensource.datatype.xsd.DatatypeBase
WHITE_SPACE_COLLAPSE, WHITE_SPACE_PRESERVE, WHITE_SPACE_REPLACE
 
Fields inherited from interface org.relaxng.datatype.Datatype
ID_TYPE_ID, ID_TYPE_IDREF, ID_TYPE_IDREFS, ID_TYPE_NULL
 
Constructor Summary
DurationDatatype()
           
 
Method Summary
private static BigInteger computeDays(BigInteger months, int refYear, int refMonth)
          Returns the number of days spanned by a period of months starting with a particular reference year and month.
private static BigInteger computeMonths(DurationDatatype.Duration d)
          Returns the total number of months specified by the year and month fields of the duration
private static BigDecimal computeSeconds(DurationDatatype.Duration d)
          Returns the total number of seconds specified by the days, hours, minuts and seconds fields of the duration.
private static int daysInMonth(int year, int month)
           
private static BigDecimal daysPlusSeconds(BigInteger days, BigDecimal seconds)
          Returns the total number of seconds from a specified number of days and seconds.
private static BigDecimal getDecimalField(String str, char code)
           
private static BigInteger getIntegerField(String str, char code)
           
(package private)  OrderRelation getOrderRelation()
           
(package private)  Object getValue(String str, ValidationContext vc)
           
private static boolean isLeapYear(int year)
           
 boolean isLessThan(Object obj1, Object obj2)
           
 boolean lexicallyAllows(String str)
           
static void main(String[] args)
           
 
Methods inherited from class com.thaiopensource.datatype.xsd.RegexDatatype
alwaysValid, compile
 
Methods inherited from class com.thaiopensource.datatype.xsd.TokenDatatype
getLength, getMeasure
 
Methods inherited from class com.thaiopensource.datatype.xsd.DatatypeBase
allowsValue, checkValid, createStreamingValidator, createValue, getIdType, getPrimitive, getWhiteSpace, isContextDependent, isValid, normalizeWhiteSpace, sameValue, valueHashCode
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PATTERN

private static final String PATTERN
See Also:
Constant Field Values

REF_YEAR_MONTHS

private static final int[] REF_YEAR_MONTHS
Constructor Detail

DurationDatatype

DurationDatatype()
Method Detail

lexicallyAllows

public boolean lexicallyAllows(String str)
Overrides:
lexicallyAllows in class RegexDatatype

getValue

Object getValue(String str,
                ValidationContext vc)
Overrides:
getValue in class TokenDatatype

getIntegerField

private static BigInteger getIntegerField(String str,
                                          char code)

getDecimalField

private static BigDecimal getDecimalField(String str,
                                          char code)

getOrderRelation

OrderRelation getOrderRelation()
Overrides:
getOrderRelation in class DatatypeBase

isLessThan

public boolean isLessThan(Object obj1,
                          Object obj2)
Specified by:
isLessThan in interface OrderRelation

computeDays

private static BigInteger computeDays(BigInteger months,
                                      int refYear,
                                      int refMonth)
Returns the number of days spanned by a period of months starting with a particular reference year and month.


daysInMonth

private static int daysInMonth(int year,
                               int month)

isLeapYear

private static boolean isLeapYear(int year)

daysPlusSeconds

private static BigDecimal daysPlusSeconds(BigInteger days,
                                          BigDecimal seconds)
Returns the total number of seconds from a specified number of days and seconds.


computeMonths

private static BigInteger computeMonths(DurationDatatype.Duration d)
Returns the total number of months specified by the year and month fields of the duration


computeSeconds

private static BigDecimal computeSeconds(DurationDatatype.Duration d)
Returns the total number of seconds specified by the days, hours, minuts and seconds fields of the duration.


main

public static void main(String[] args)