org.openpermis.basic
Class PartialTime

java.lang.Object
  extended by org.openpermis.basic.PartialTime

public final class PartialTime
extends Object

A PartialTime may represent a specific instant in time or a not yet fully specified instance in time. That means every part (year, days, time zone ...) is optional.

Comparison of two PartialTime's are only supported if at least one instance is fully specified.
Comparison simply ignores positions with an asterix.
A comparison is always relative to a given TimeStamp. This is due the fact that an PartialTime may be specified in local time.

Time: (*|YYYY)-(*|MM)-(*|DD)T(*|hh):(*|mm):(*|ss). Zone: Z|([+-]hh:ss).

Examples:


Field Summary
private  int dayOfMonth
           
private  org.joda.time.DateTimeZone defaultZone
           
(package private)  boolean hasZone
           
private  int hourOfDay
           
private  boolean isYearAsterix
           
private  int minuteOfHour
           
private  int monthOfYear
           
private  int secondOfMinute
           
private  int year
           
private  int[] zone
           
 
Constructor Summary
PartialTime(boolean isYearAsterix, int year, int monthOfYear, int dayOfMonth, int hourOfDay, int minuteOfHour, int secondOfMinute, boolean hasZone, int offsetHours, int offsetMinutes, org.joda.time.DateTimeZone defaultZone, boolean allowWildcards)
          Creates a new PartialTime with a default time zone.
PartialTime(Date date)
          Creates an PartialTime from a Date.
PartialTime(String string, org.joda.time.DateTimeZone defaultZone, boolean allowWildcards)
          Creates a new PartialTime from a string with a default time zone.
 
Method Summary
private  void checkTimeAndOffset()
           
private  int compareTo(PartialTime other, TimeStamp timeStamp)
           
 boolean equals(Object object)
           
 int hashCode()
           
private  boolean inLocalZone()
          Returns true if this time is defined in local time zone.
 boolean inSameTimeZone(PartialTime other)
          Returns true if this time is in the same time zone as other.
 boolean isAfter(PartialTime other, TimeStamp timeStamp)
          Return true if this time is after other time.
 boolean isBefore(PartialTime other, TimeStamp timeStamp)
          Return true if this time is before other time.
 boolean isComparableWith(PartialTime other)
          Returns true if this and other are comparable.
 boolean isComplete()
          Returns true if this time is complete defined and contains no asterix's.
 boolean isEqual(PartialTime other, TimeStamp timeStamp)
          Return true if this time is equal other time.
private  void parse(String string)
           
private  void parseDateAndTime(String y, String mo, String d, String h, String mi, String s)
           
private static int[] parseZone(String utc, String sign, String hours, String minutes)
           
 org.joda.time.DateTime toDateTime(TimeStamp timeStamp)
          Returns this as DateTime.
private  org.joda.time.DateTimeZone toDateTimeZone(TimeStamp timeStamp)
           
 String toString()
           
private  String writePart(int i)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

year

private int year

isYearAsterix

private boolean isYearAsterix

monthOfYear

private int monthOfYear

dayOfMonth

private int dayOfMonth

hourOfDay

private int hourOfDay

minuteOfHour

private int minuteOfHour

secondOfMinute

private int secondOfMinute

zone

private int[] zone

hasZone

boolean hasZone

defaultZone

private org.joda.time.DateTimeZone defaultZone
Constructor Detail

PartialTime

public PartialTime(Date date)
Creates an PartialTime from a Date.

Parameters:
date - a Date.

PartialTime

public PartialTime(String string,
                   org.joda.time.DateTimeZone defaultZone,
                   boolean allowWildcards)
            throws NumberFormatException
Creates a new PartialTime from a string with a default time zone. The default zone may be null and therefore the local time zone at evaluation time is taken.

Parameters:
string - see PartialTime class description.
defaultZone - a default DateTimeZone.
Throws:
NumberFormatException
Since:
0.3.0

PartialTime

public PartialTime(boolean isYearAsterix,
                   int year,
                   int monthOfYear,
                   int dayOfMonth,
                   int hourOfDay,
                   int minuteOfHour,
                   int secondOfMinute,
                   boolean hasZone,
                   int offsetHours,
                   int offsetMinutes,
                   org.joda.time.DateTimeZone defaultZone,
                   boolean allowWildcards)
Creates a new PartialTime with a default time zone. The default zone may be null and therefore the local time zone at evaluation time is used.

Parameters:
year - the year.
monthOfYear - the month of year.
dayOfMonth - the day of month.
hourOfDay - the hour of date.
minuteOfHour - the minute of hour.
secondOfMinute - the second of minute.
defaultZone - a default DateTimeZone.
Since:
0.3.0
Method Detail

isComplete

public boolean isComplete()
Returns true if this time is complete defined and contains no asterix's.

Returns:
true if this time is complete defined and contains no asterix's.
Since:
0.3.0

inLocalZone

private boolean inLocalZone()
Returns true if this time is defined in local time zone.

Returns:
true if this time is defined in local time zone.
Since:
0.3.0

inSameTimeZone

public boolean inSameTimeZone(PartialTime other)
Returns true if this time is in the same time zone as other.

Returns:
true if this time is in the same time zone as other.
Since:
0.3.0

toDateTime

public org.joda.time.DateTime toDateTime(TimeStamp timeStamp)
Returns this as DateTime.

Parameters:
timeStamp - a TimeStamp.
Returns:
a DateTime.
Since:
0.3.0

isComparableWith

public boolean isComparableWith(PartialTime other)
Returns true if this and other are comparable. Two times are not comparable if they both contains asterix's.

Parameters:
other - an PartialTime.
Returns:
true if this and other are comparable.
Since:
0.3.0

isAfter

public boolean isAfter(PartialTime other,
                       TimeStamp timeStamp)
Return true if this time is after other time.

Parameters:
other - an PartialTime.
timeStamp - evaluation time.
Since:
0.3.0

isBefore

public boolean isBefore(PartialTime other,
                        TimeStamp timeStamp)
Return true if this time is before other time.

Parameters:
other - an PartialTime.
timeStamp - evaluation time.
Since:
0.3.0

isEqual

public boolean isEqual(PartialTime other,
                       TimeStamp timeStamp)
Return true if this time is equal other time.

Parameters:
other - an PartialTime.
timeStamp - evaluation time.
Since:
0.3.0

compareTo

private int compareTo(PartialTime other,
                      TimeStamp timeStamp)
Since:
0.3.0

parse

private void parse(String string)
Since:
0.3.0

parseDateAndTime

private void parseDateAndTime(String y,
                              String mo,
                              String d,
                              String h,
                              String mi,
                              String s)
Since:
0.3.0

checkTimeAndOffset

private void checkTimeAndOffset()
Since:
0.3.0

parseZone

private static int[] parseZone(String utc,
                               String sign,
                               String hours,
                               String minutes)
Since:
0.3.0

equals

public boolean equals(Object object)
Overrides:
equals in class Object
Since:
0.3.0

hashCode

public int hashCode()
Overrides:
hashCode in class Object
Since:
0.3.0

toString

public String toString()
Overrides:
toString in class Object
Since:
0.3.0

writePart

private String writePart(int i)
Since:
0.3.0

toDateTimeZone

private org.joda.time.DateTimeZone toDateTimeZone(TimeStamp timeStamp)
Since:
0.3.0


PERMIS Role Based Access Control 0.3.0 (Build 14)
2009/05/08 09:06:22
Copyright (c) 2002-2007 Ergon Informatik AG