© 2005 BEA Systems, Inc.

com.bea.p13n.xml.schema
Class TimePeriod

java.lang.Object
  extended bycom.bea.p13n.xml.schema.TimePeriod
All Implemented Interfaces:
Cloneable, Comparable, Serializable

public class TimePeriod
extends Object
implements Serializable, Cloneable, Comparable

This class provides the Java biding for the XML schema type timePeriod as specified in Section 3.3.26 of XML Schema Part 2: Datatypes.

timePeriod represents a specific period of time with a given start and end.

The value of an instance of timePeriod specifies the start of the time period, while the value of dudation should be specified in the schema.

Example: 09:00:00.000Z.

Instance of this type can be constructed from instances of TimeInstant and TimePeriod.

NOTE:

This is special case where a facet (the duration facet) should be specified while creating an instance of TimePeriod. Without this information, an instance of TimePeriod would be meaningless.

See Also:
Serialized Form

Constructor Summary
protected TimePeriod()
          Constructs a new TimePeriod instance with "P0Y" as the duration and period at the current point in time.
 
Method Summary
 Object clone()
          Returns a copy of this TimeDuration.
 int compareTo(Object anotherObject)
          Compares this TimePeriod with another object.
 int compareTo(TimePeriod anotherTimePeriod)
          Compares this TimePeriod to another TimePeriod object (represented in the same time zone) in their canonical representation.
static TimePeriod createTimePeriod()
          Returns a TimePeriod instance for the current time at the local time zone with zero duration.
static TimePeriod createTimePeriod(String start, String duration)
          Given the start time instant and duration, returns a TimePeriod instance.
static TimePeriod createTimePeriod(TimeInstant start, TimeDuration duration)
          Given the start time instant and duration, returns a TimePeriod instance.
 TimeDuration getDuration()
          Returns the duration for this TimePeriod.
 TimeInstant getEnd()
          Returns the end of this duration based on the current values of start time instannt and duration.
 TimeInstant getStart()
          Returns the instant at which this TimePeriod starts.
 void setDuration(TimeDuration duration)
          Sets the duration for this TimePeriod.
 void setStart(TimeInstant start)
          Sets the instant at which this TimePeriod starts.
 String toString()
          Returns a XML schema compliant timePeriod string.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TimePeriod

protected TimePeriod()
Constructs a new TimePeriod instance with "P0Y" as the duration and period at the current point in time.

Method Detail

clone

public Object clone()
Returns a copy of this TimeDuration.

Returns:
copy

compareTo

public int compareTo(Object anotherObject)
Compares this TimePeriod with another object. If the other object is a TimePeriod, this method behaves like compareTo(TimePeriod). Otherwise, it throws a ClassCastException.

Specified by:
compareTo in interface Comparable
Returns:
the value 0 if the argument TimePeriod is equal to this TimePeriod; a value less than 0 if this TimePeriod is before the TimePeriod argument; and a value greater than 0 if this TimePeriod is after the TimePeriod argument.
Throws:
ClassCastException - thrown if the argument is not an instance of TimePeriod.

compareTo

public int compareTo(TimePeriod anotherTimePeriod)

Compares this TimePeriod to another TimePeriod object (represented in the same time zone) in their canonical representation. Two time periods are considered to be equal if both the start time instant and duration are equal.

Two instances of time periods can be compared only when both time periods start at the same time instant.

Parameters:
anotherTimePeriod - another TimePeriod object to be compared.
Returns:
the value 0 if the argument TimePeriod is equal to this TimePeriod; a value less than 0 if this TimePeriod is before the TimePeriod argument; and a value greater than 0 if this TimePeriod is after the TimePeriod argument.
Throws:
IllegalArgumentException - thrown when the argument starts at a different time instant from the current time period.

createTimePeriod

public static TimePeriod createTimePeriod()
Returns a TimePeriod instance for the current time at the local time zone with zero duration.

Returns:
instance of TimeDuratio

createTimePeriod

public static TimePeriod createTimePeriod(String start,
                                          String duration)
                                   throws ParseException
Given the start time instant and duration, returns a TimePeriod instance.

Parameters:
start - start time instant
duration - duration
Returns:
instance of TimePeriod
Throws:
ParseException - thrown due to illegal string argument

createTimePeriod

public static TimePeriod createTimePeriod(TimeInstant start,
                                          TimeDuration duration)
Given the start time instant and duration, returns a TimePeriod instance.

Parameters:
start - start time instant
duration - duration
Returns:
instance of TimePeriod

getDuration

public TimeDuration getDuration()
Returns the duration for this TimePeriod.

Returns:
duration of this time period

getEnd

public TimeInstant getEnd()
Returns the end of this duration based on the current values of start time instannt and duration.

Returns:
end time instant for this time period

getStart

public TimeInstant getStart()
Returns the instant at which this TimePeriod starts.

Returns:
start of this time period

setDuration

public void setDuration(TimeDuration duration)
Sets the duration for this TimePeriod.

Parameters:
duration - duration

setStart

public void setStart(TimeInstant start)
Sets the instant at which this TimePeriod starts.

Parameters:
start - starting instant

toString

public String toString()

Returns a XML schema compliant timePeriod string.

Returns:
string value

© 2005 BEA Systems, Inc.

Copyright © 2005 BEA Systems, Inc. All Rights Reserved