amwebarsentitlementservice
Class TimeInterval

java.lang.Object
  |
  +--amwebarsentitlementservice.TimeInterval

public class TimeInterval
extends java.lang.Object

This class is an abstract time interval. It's based on the Date format. All time values are GMT. A null as not_before or not_after value will denote +/- infinity. Therefore TimeInterval(null, null) describes a forever valid interval.


Field Summary
static java.lang.String DATE_FORMAT
           
static java.lang.String DATE_FORMAT_HUMAN
           
static long INFTY
           
static long NEG_INFTY
           
static java.lang.String TIMEINTERVAL_XML_NAME
           
 
Constructor Summary
TimeInterval(java.util.Date not_before, java.util.Date not_after)
           
TimeInterval(org.jdom.Element xml_interval)
           
TimeInterval(long not_before, long not_after)
           
 
Method Summary
 java.lang.Object clone()
           
 boolean equals(java.lang.Object other_object)
          Tests whether this TimeInterval is equal to another.
 long getNotAfter()
          Gets the not_after.
 java.util.Date getNotAfterDate()
          Gets the not_after.
 long getNotBefore()
          Gets the not_before.
 java.util.Date getNotBeforeDate()
          Gets the not_before.
 boolean isInside(java.util.Date date)
          Tests whether a given Date is inside the TimeInterval.
 boolean isInside(long date)
           
 void setNotAfter(long not_after)
          Sets the not_after.
 void setNotAfterDate(java.util.Date not_after)
          Sets the not_after.
 void setNotBefore(long not_before)
          Sets the not_before.
 void setNotBeforeDate(java.util.Date not_before)
          Sets the not_before.
 java.lang.String toString()
           
 org.jdom.Element toXML()
          Translates the TimeInterval to XML
 org.jdom.Element toXML(org.jdom.Namespace ns)
          Translates the TimeInterval to XML
 org.jdom.Element toXML(java.lang.String element_name)
          Translates the TimeInterval to XML
 org.jdom.Element toXML(java.lang.String element_name, org.jdom.Namespace ns)
          Translates the TimeInterval to XML
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TIMEINTERVAL_XML_NAME

public static final java.lang.String TIMEINTERVAL_XML_NAME

DATE_FORMAT_HUMAN

public static final java.lang.String DATE_FORMAT_HUMAN

DATE_FORMAT

public static final java.lang.String DATE_FORMAT

INFTY

public static final long INFTY

NEG_INFTY

public static final long NEG_INFTY
Constructor Detail

TimeInterval

public TimeInterval(java.util.Date not_before,
                    java.util.Date not_after)

TimeInterval

public TimeInterval(long not_before,
                    long not_after)

TimeInterval

public TimeInterval(org.jdom.Element xml_interval)
             throws sun.io.MalformedInputException
Method Detail

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Overrides:
clone in class java.lang.Object

getNotBeforeDate

public java.util.Date getNotBeforeDate()
Gets the not_before.
Returns:
Returns a Date

setNotBeforeDate

public void setNotBeforeDate(java.util.Date not_before)
Sets the not_before.
Parameters:
not_before - The not_before to set

getNotAfterDate

public java.util.Date getNotAfterDate()
Gets the not_after.
Returns:
Returns a Date

setNotAfterDate

public void setNotAfterDate(java.util.Date not_after)
Sets the not_after.
Parameters:
not_after - The not_after to set

getNotBefore

public long getNotBefore()
Gets the not_before.
Returns:
Returns a Date

setNotBefore

public void setNotBefore(long not_before)
Sets the not_before.
Parameters:
not_before - The not_before to set

getNotAfter

public long getNotAfter()
Gets the not_after.
Returns:
Returns a Date

setNotAfter

public void setNotAfter(long not_after)
Sets the not_after.
Parameters:
not_after - The not_after to set

isInside

public boolean isInside(java.util.Date date)
Tests whether a given Date is inside the TimeInterval.
Parameters:
date - Date that will be tested.
Returns:
boolean true, if the value is inside the interval [not_before, not_after]

isInside

public boolean isInside(long date)

equals

public boolean equals(java.lang.Object other_object)
Tests whether this TimeInterval is equal to another.
Overrides:
equals in class java.lang.Object
Returns:
boolean true if both obj are the same.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

toXML

public org.jdom.Element toXML()
Translates the TimeInterval to XML
Returns:
XML Element of the TimeInterval

toXML

public org.jdom.Element toXML(java.lang.String element_name)
Translates the TimeInterval to XML
Returns:
XML Element of the TimeInterval

toXML

public org.jdom.Element toXML(org.jdom.Namespace ns)
Translates the TimeInterval to XML
Returns:
XML Element of the TimeInterval

toXML

public org.jdom.Element toXML(java.lang.String element_name,
                              org.jdom.Namespace ns)
Translates the TimeInterval to XML
Returns:
XML Element of the TimeInterval