org.omg.dds.core
Class Duration

java.lang.Object
  extended by org.omg.dds.core.Duration
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, DDSObject, Value<Duration,ModifiableDuration>
Direct Known Subclasses:
ModifiableDuration

@Extensibility(value=FINAL_EXTENSIBILITY)
@Nested
public abstract class Duration
extends java.lang.Object
implements Value<Duration,ModifiableDuration>

A span of elapsed time expressed with nanosecond precision.

See Also:
Serialized Form

Constructor Summary
Duration()
           
 
Method Summary
abstract  Duration clone()
          Extends the concept of "cloneable" defined in java.lang by providing an explicit public Value.clone() method.
abstract  long getDuration(java.util.concurrent.TimeUnit inThisUnit)
          Truncate this duration to a whole-number quantity of the given time unit.
abstract  long getRemainder(java.util.concurrent.TimeUnit primaryUnit, java.util.concurrent.TimeUnit remainderUnit)
          If getting the magnitude of this duration in the given primaryUnit would cause truncation with respect to the given remainderUnit, return the magnitude of the truncation in the latter (presumably finer-grained) unit.
static Duration infiniteDuration(Bootstrap bootstrap)
           
abstract  boolean isInfinite()
          Report whether this duration lasts forever.
abstract  boolean isZero()
          Report whether this duration lasts no time at all.
static ModifiableDuration newDuration(long duration, java.util.concurrent.TimeUnit unit, Bootstrap bootstrap)
          Construct a time duration of the given magnitude.
static Duration zeroDuration(Bootstrap bootstrap)
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.omg.dds.core.Value
equals, hashCode, modify
 
Methods inherited from interface org.omg.dds.core.DDSObject
getBootstrap
 

Constructor Detail

Duration

public Duration()
Method Detail

newDuration

public static ModifiableDuration newDuration(long duration,
                                             java.util.concurrent.TimeUnit unit,
                                             Bootstrap bootstrap)
Construct a time duration of the given magnitude. A duration of magnitude Long.MAX_VALUE indicates an infinite duration, regardless of the units specified.

Parameters:
bootstrap - Identifies the Service instance to which the new object will belong.
See Also:
isInfinite(), infiniteDuration(Bootstrap)

infiniteDuration

public static Duration infiniteDuration(Bootstrap bootstrap)
Parameters:
bootstrap - Identifies the Service instance to which the object will belong.
Returns:
An unmodifiable Duration of infinite length.

zeroDuration

public static Duration zeroDuration(Bootstrap bootstrap)
Parameters:
bootstrap - Identifies the Service instance to which the object will belong.
Returns:
A Duration of zero length.

getDuration

public abstract long getDuration(java.util.concurrent.TimeUnit inThisUnit)
Truncate this duration to a whole-number quantity of the given time unit. For example, if this duration is equal to one second plus 100 nanoseconds, calling this method with an argument of TimeUnit.SECONDS will result in the value 1. If this duration is infinite, this method shall return Long.MAX_VALUE, regardless of the units given. If this duration cannot be expressed in the given units without overflowing, this method shall return Long.MAX_VALUE. In such a case, the caller may wish to use this method in combination with getRemainder(TimeUnit, TimeUnit) to obtain the full duration without lack of precision.

Parameters:
inThisUnit - The time unit in which the return result will be measured.
See Also:
getRemainder(TimeUnit, TimeUnit), Long.MAX_VALUE, TimeUnit

getRemainder

public abstract long getRemainder(java.util.concurrent.TimeUnit primaryUnit,
                                  java.util.concurrent.TimeUnit remainderUnit)
If getting the magnitude of this duration in the given primaryUnit would cause truncation with respect to the given remainderUnit, return the magnitude of the truncation in the latter (presumably finer-grained) unit. For example, if this duration is equal to one second plus 100 nanoseconds, calling this method with arguments of TimeUnit.SECONDS and TimeUnit.NANOSECONDS respectively will result in the value 100. This method is equivalent to the following pseudo-code: (this - getDuration(primaryUnit)).getDuration(remainderUnit) If remainderUnit is represents a coarser granularity than primaryUnit (for example, the former is TimeUnit.HOURS but the latter is TimeUnit.SECONDS), this method shall return 0. If the resulting duration cannot be expressed in the given units without overflowing, this method shall return Long.MAX_VALUE.

Parameters:
primaryUnit -
remainderUnit - The time unit in which the return result will be measured.
See Also:
getDuration(TimeUnit), Long.MAX_VALUE, TimeUnit

isZero

public abstract boolean isZero()
Report whether this duration lasts no time at all. The result of this method is equivalent to the following: this.getDuration(TimeUnit.NANOSECONDS) == 0;

See Also:
getDuration(TimeUnit)

isInfinite

public abstract boolean isInfinite()
Report whether this duration lasts forever. If this duration is infinite, the following relationship shall be true: this.equals(infiniteDuration(this.getBootstrap()))

See Also:
infiniteDuration(Bootstrap)

clone

public abstract Duration clone()
Description copied from interface: Value
Extends the concept of "cloneable" defined in java.lang by providing an explicit public Value.clone() method.

Specified by:
clone in interface Value<Duration,ModifiableDuration>
Overrides:
clone in class java.lang.Object
Returns:
a new object that with state identical to that of this object.


Copyright © 2010 Real-Time Innovations, Inc. (RTI)
Copyright © 2010 PrismTech, Ltd.
Copyright © 2010 Object Management Group, Inc. (OMG)
All Rights Reserved.