com.waveset.util
Class Util.TimePeriod

java.lang.Object
  extended by com.waveset.util.AbstractXmlObject
      extended by com.waveset.util.Util.TimePeriod
All Implemented Interfaces:
XmlObject, java.lang.Cloneable, javax.naming.Referenceable
Enclosing class:
Util

public static class Util.TimePeriod
extends AbstractXmlObject
implements java.lang.Cloneable

Used to represent a time period, such as number of days, weeks or months, relative to an arbitrary day.


Field Summary
static java.lang.String ELEMENT
          Name of the serialized XML element.
 
Fields inherited from class com.waveset.util.AbstractXmlObject
code_id
 
Constructor Summary
Util.TimePeriod()
          Build a default time period, zero days.
Util.TimePeriod(org.w3c.dom.Element e)
          Construct a time period by parsing its DOM representation.
Util.TimePeriod(Util.TimeUnit unit, int count)
          Build a time unit specifying the unit and count.
 
Method Summary
 java.util.Date add(java.util.Date start)
          Add the time period to a date, and return the relative date.
 java.lang.Object clone()
          Clone the TimePeriod.
 Util.TimePeriod copy()
          A more convenient clone.
 int getCount()
          Get the time unit count.
 java.lang.String getElementName()
          Return the element name.
 Util.TimeUnit getUnit()
          Get the time unit.
 void setCount(int c)
          Set the time unit count.
 void setUnit(Util.TimeUnit u)
          Set the time unit.
 java.util.Date subtract(java.util.Date start)
          Subtract the time period from a date, and return the relative date.
 Util.TimePeriod subtract(Util.TimePeriod p)
          Subtract the specified time period from this time period and return a time period jsl - can't we use the Calendar class for much of this?
 void toXml(java.lang.StringBuffer b, int indent)
          Serialize the time period to an XML buffer.
 
Methods inherited from class com.waveset.util.AbstractXmlObject
addXmlHeader, cloneObject, dump, dumpFile, getReference, setTrace, toIdentityString, toVerboseString, toVerboseString, toXml, toXml, toXml
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ELEMENT

public static final java.lang.String ELEMENT
Name of the serialized XML element.

See Also:
Constant Field Values
Constructor Detail

Util.TimePeriod

public Util.TimePeriod()
Build a default time period, zero days.


Util.TimePeriod

public Util.TimePeriod(org.w3c.dom.Element e)
Construct a time period by parsing its DOM representation.


Util.TimePeriod

public Util.TimePeriod(Util.TimeUnit unit,
                       int count)
Build a time unit specifying the unit and count.

Method Detail

add

public java.util.Date add(java.util.Date start)
Add the time period to a date, and return the relative date.


clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Clone the TimePeriod.

Overrides:
clone in class java.lang.Object
Throws:
java.lang.CloneNotSupportedException

copy

public Util.TimePeriod copy()
A more convenient clone.


getCount

public int getCount()
Get the time unit count.


getElementName

public java.lang.String getElementName()
Description copied from class: AbstractXmlObject
Return the element name.

Specified by:
getElementName in interface XmlObject
Specified by:
getElementName in class AbstractXmlObject
Returns:
the element name

getUnit

public Util.TimeUnit getUnit()
Get the time unit.


setCount

public void setCount(int c)
Set the time unit count.


setUnit

public void setUnit(Util.TimeUnit u)
Set the time unit.


subtract

public java.util.Date subtract(java.util.Date start)
Subtract the time period from a date, and return the relative date.


subtract

public Util.TimePeriod subtract(Util.TimePeriod p)
Subtract the specified time period from this time period and return a time period jsl - can't we use the Calendar class for much of this?


toXml

public void toXml(java.lang.StringBuffer b,
                  int indent)
Serialize the time period to an XML buffer.

Specified by:
toXml in interface XmlObject
Specified by:
toXml in class AbstractXmlObject
Parameters:
b - StringBuffer in which to write the generated xml
indent - Number of spaces to indent the generated xml block