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:


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
 boolean equals(Object object)
           
 int hashCode()
           
 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.
 org.joda.time.DateTime toDateTime(TimeStamp timeStamp)
          Returns this as DateTime.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

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

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

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


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