Protégé-OWL 3.4

edu.stanford.smi.protegex.owl.swrl.bridge.builtins.temporal
Class DatetimeStringProcessor

java.lang.Object
  extended by edu.stanford.smi.protegex.owl.swrl.bridge.builtins.temporal.DatetimeStringProcessor
Direct Known Subclasses:
JDBCDatetimeStringProcessor, XSDDatetimeStringProcessor

public abstract class DatetimeStringProcessor
extends Object

A class supporting processing of datetime strings. This class will be specialized by subclasses to deal with different datetimes formats, e.g., XSD and JDBC datetimes.


Field Summary
protected  SimpleDateFormat dateFormat
           
protected  String[] datetimeRoundDownPadding
           
protected  String[] datetimeRoundUpPadding
           
protected  String delimiters
           
protected  int[] gTokenIndex
           
 
Constructor Summary
DatetimeStringProcessor(SimpleDateFormat dateFormat, String delimiters, int[] gTokenIndex, String[] datetimeRoundDownPadding, String[] datetimeRoundUpPadding)
           
 
Method Summary
 void checkDatetimeString(String datetimeString)
           
protected abstract  String constructDatetimeString(long milliseconds)
           
 String expressDatetimeStringAtGranularity(String datetimeString, int granularity)
           
 String expressDatetimeStringAtGranularity(String datetimeString, int granularity, boolean roundUp)
          Take a full-specification datetime string (which will have the granularity of milliseconds), discard any information that is finer than the supplied granularity, and return a full-specification datetime string, e.g., Converting the JDBC datetime '1988-02-03 10:10:11.433' to a granularity of MONTHS will produce '1988-02-01 00:00:00.000'.
 long getDays(String datetimeString)
           
 long getHours(String datetimeString)
           
 long getMilliseconds(String datetimeString)
           
 long getMinutes(String datetimeString)
           
 long getMonths(String datetimeString)
           
 long getSeconds(String datetimeString)
           
 long getYears(String datetimeString)
           
 String granuleCount2DatetimeString(long granuleCount, int granularity)
          Take a granule count (from the beginning of calendar time, i.e., January 1st 1 C.E) at any granularity and convert it to a datetime string.
 String normalizeDatetimeString(String datetime, int granularity)
           
 String normalizeDatetimeString(String datetimeString, int granularity, boolean roundUp)
          Take a possibly incomplete datetime string and cast it to a valid datetime string, discarding any information finer than the supplied granularity, and round up or down.
 String padDatetimeString(String datetimeString, boolean roundUp)
          Take a possibly incomplete datetime string and pad it to a full specification datetime string rounding up or down, e.g., the JDBC datetime '1988-10-10 12' becomes '1988-10-10 12:59:59:999' when rounded up and '1988-10-10 12:00:00.000' when rounded down.
 String stripDatetimeString(String datetimeString, int granularity)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dateFormat

protected SimpleDateFormat dateFormat

delimiters

protected String delimiters

gTokenIndex

protected int[] gTokenIndex

datetimeRoundDownPadding

protected String[] datetimeRoundDownPadding

datetimeRoundUpPadding

protected String[] datetimeRoundUpPadding
Constructor Detail

DatetimeStringProcessor

public DatetimeStringProcessor(SimpleDateFormat dateFormat,
                               String delimiters,
                               int[] gTokenIndex,
                               String[] datetimeRoundDownPadding,
                               String[] datetimeRoundUpPadding)
Method Detail

constructDatetimeString

protected abstract String constructDatetimeString(long milliseconds)
                                           throws TemporalException
Throws:
TemporalException

granuleCount2DatetimeString

public String granuleCount2DatetimeString(long granuleCount,
                                          int granularity)
                                   throws TemporalException
Take a granule count (from the beginning of calendar time, i.e., January 1st 1 C.E) at any granularity and convert it to a datetime string.

Throws:
TemporalException

expressDatetimeStringAtGranularity

public String expressDatetimeStringAtGranularity(String datetimeString,
                                                 int granularity,
                                                 boolean roundUp)
                                          throws TemporalException
Take a full-specification datetime string (which will have the granularity of milliseconds), discard any information that is finer than the supplied granularity, and return a full-specification datetime string, e.g., Converting the JDBC datetime '1988-02-03 10:10:11.433' to a granularity of MONTHS will produce '1988-02-01 00:00:00.000'.

Throws:
TemporalException

expressDatetimeStringAtGranularity

public String expressDatetimeStringAtGranularity(String datetimeString,
                                                 int granularity)
                                          throws TemporalException
Throws:
TemporalException

checkDatetimeString

public void checkDatetimeString(String datetimeString)
                         throws TemporalException
Throws:
TemporalException

normalizeDatetimeString

public String normalizeDatetimeString(String datetimeString,
                                      int granularity,
                                      boolean roundUp)
                               throws TemporalException
Take a possibly incomplete datetime string and cast it to a valid datetime string, discarding any information finer than the supplied granularity, and round up or down. e.g., '1988-02' is converted to the XSD datetime '1988-02-01T00:00:00.000' when rounded down at any granularity finer than 'days'; the JDBC datetime '1988-1-1 12:10' is converted to '1988-1-1 12:59:59.999' when rounded up at a granularity of hours.

Throws:
TemporalException

normalizeDatetimeString

public String normalizeDatetimeString(String datetime,
                                      int granularity)
                               throws TemporalException
Throws:
TemporalException

padDatetimeString

public String padDatetimeString(String datetimeString,
                                boolean roundUp)
                         throws TemporalException
Take a possibly incomplete datetime string and pad it to a full specification datetime string rounding up or down, e.g., the JDBC datetime '1988-10-10 12' becomes '1988-10-10 12:59:59:999' when rounded up and '1988-10-10 12:00:00.000' when rounded down.

Throws:
TemporalException

stripDatetimeString

public String stripDatetimeString(String datetimeString,
                                  int granularity)
                           throws TemporalException
Throws:
TemporalException

getYears

public long getYears(String datetimeString)
              throws TemporalException
Throws:
TemporalException

getMonths

public long getMonths(String datetimeString)
               throws TemporalException
Throws:
TemporalException

getDays

public long getDays(String datetimeString)
             throws TemporalException
Throws:
TemporalException

getHours

public long getHours(String datetimeString)
              throws TemporalException
Throws:
TemporalException

getMinutes

public long getMinutes(String datetimeString)
                throws TemporalException
Throws:
TemporalException

getSeconds

public long getSeconds(String datetimeString)
                throws TemporalException
Throws:
TemporalException

getMilliseconds

public long getMilliseconds(String datetimeString)
                     throws TemporalException
Throws:
TemporalException

Protégé-OWL 3.4

Submit a bug report or feature request
Copyright (c) 1998-2009 Stanford University.