OpenSplice Java 5 DCPS  v6.x
OpenSplice Java 5 OpenSplice Data Distribution Service Data-Centric Publish-Subscribe API
org.omg.dds.core.Duration Class Referenceabstract

A span of elapsed time expressed with nanosecond precision. More...

Inheritance diagram for org.omg.dds.core.Duration:
Inheritance graph
Collaboration diagram for org.omg.dds.core.Duration:
Collaboration graph

Public Member Functions

abstract Duration add (Duration duration)
 
abstract Duration add (long duration, TimeUnit unit)
 
abstract long getDuration (TimeUnit inThisUnit)
 Truncate this duration to a whole-number quantity of the given time unit. More...
 
ServiceEnvironment getEnvironment ()
 
abstract long getRemainder (TimeUnit primaryUnit, 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. More...
 
abstract boolean isInfinite ()
 Report whether this duration lasts forever. More...
 
abstract boolean isZero ()
 Report whether this duration lasts no time at all. More...
 
abstract Duration subtract (Duration duration)
 
abstract Duration subtract (long duration, TimeUnit unit)
 

Static Public Member Functions

static Duration infiniteDuration (ServiceEnvironment env)
 
static Duration newDuration (long duration, TimeUnit unit, ServiceEnvironment env)
 Construct a time duration of the given magnitude. More...
 
static Duration zeroDuration (ServiceEnvironment env)
 

Detailed Description

A span of elapsed time expressed with nanosecond precision.

Instances of this type are immutable.

Definition at line 35 of file Duration.java.

Member Function Documentation

◆ add() [1/2]

abstract Duration org.omg.dds.core.Duration.add ( Duration  duration)
abstract
Returns
a new Duration that is the sum of this Duration and the given Duration.

◆ add() [2/2]

abstract Duration org.omg.dds.core.Duration.add ( long  duration,
TimeUnit  unit 
)
abstract
Returns
a new Duration that is the sum of this Duration and the given duration.

◆ getDuration()

abstract long org.omg.dds.core.Duration.getDuration ( TimeUnit  inThisUnit)
abstract

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
inThisUnitThe time unit in which the return result will be measured.
See also
getRemainder(TimeUnit, TimeUnit)
Long::MAX_VALUE
TimeUnit

◆ getEnvironment()

ServiceEnvironment org.omg.dds.core.DDSObject.getEnvironment ( )
inherited
Returns
the org.omg.dds.core.ServiceEnvironment object that directly or indirectly was used to create this object.

Implemented in org.omg.dds.core.ServiceEnvironment, org.opensplice.dds.sub.ReflectionDataReader< TYPE, OUT_TYPE >, org.opensplice.dds.core.ModifiableTimeImpl, org.opensplice.dds.pub.ReflectionDataWriter< TYPE >, org.opensplice.dds.core.DurationImpl, org.opensplice.dds.topic.ContentFilteredTopicImpl< TYPE >, org.opensplice.dds.sub.ReadConditionImpl< TYPE >, org.opensplice.dds.core.EntityQosImpl< T extends QosPolicy >, org.opensplice.dds.type.TypeSupportImpl< TYPE >, org.opensplice.dds.topic.PublicationBuiltinTopicDataImpl, org.opensplice.dds.topic.SubscriptionBuiltinTopicDataImpl, org.opensplice.dds.topic.TopicBuiltinTopicDataImpl, org.opensplice.dds.domain.DomainParticipantFactoryImpl, org.opensplice.dds.core.QosProviderImpl, org.opensplice.dds.core.status.OfferedIncompatibleQosStatusImpl, org.opensplice.dds.core.status.RequestedIncompatibleQosStatusImpl, org.opensplice.dds.core.InstanceHandleImpl, org.opensplice.dds.core.StatusConditionImpl< T extends Entity<?, ?>, org.opensplice.dds.core.status.LivelinessChangedStatusImpl, org.opensplice.dds.core.status.PublicationMatchedStatusImpl, org.opensplice.dds.core.status.SubscriptionMatchedStatusImpl, org.opensplice.dds.sub.SampleImpl< TYPE >, org.opensplice.dds.core.policy.ShareImpl, org.opensplice.dds.core.status.OfferedDeadlineMissedStatusImpl, org.opensplice.dds.core.status.SampleRejectedStatusImpl, org.opensplice.dds.core.WaitSetImpl, org.opensplice.dds.topic.ParticipantBuiltinTopicDataImpl, org.opensplice.dds.core.status.RequestedDeadlineMissedStatusImpl, org.opensplice.dds.topic.BuiltinTopicKeyImpl, org.opensplice.dds.core.GuardConditionImpl, org.opensplice.dds.core.event.AllDataDisposedEventImpl< TYPE >, org.opensplice.dds.core.policy.QosPolicyCountImpl, org.opensplice.dds.core.status.InconsistentTopicStatusImpl, org.opensplice.dds.core.status.LivelinessLostStatusImpl, org.opensplice.dds.core.status.SampleLostStatusImpl, org.opensplice.dds.core.policy.QosPolicyImpl, org.opensplice.dds.core.status.AllDataDisposedStatusImpl, org.opensplice.dds.core.IllegalArgumentExceptionImpl, org.opensplice.dds.core.InconsistentPolicyExceptionImpl, org.opensplice.dds.core.policy.PolicyFactoryImpl, org.opensplice.dds.core.policy.TypeConsistencyEnforcementImpl, org.opensplice.dds.core.PreconditionNotMetExceptionImpl, org.opensplice.dds.core.AlreadyClosedExceptionImpl, org.opensplice.dds.core.IllegalOperationExceptionImpl, org.opensplice.dds.core.ImmutablePolicyExceptionImpl, org.opensplice.dds.core.NotEnabledExceptionImpl, org.opensplice.dds.core.OutOfResourcesExceptionImpl, org.opensplice.dds.core.DDSExceptionImpl, org.opensplice.dds.core.status.DataAvailableStatusImpl, and org.opensplice.dds.core.status.DataOnReadersStatusImpl.

◆ getRemainder()

abstract long org.omg.dds.core.Duration.getRemainder ( TimeUnit  primaryUnit,
TimeUnit  remainderUnit 
)
abstract

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#MILLISECONDS 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
remainderUnitThe time unit in which the return result will be measured.
See also
getDuration(TimeUnit)
Long::MAX_VALUE
TimeUnit

◆ infiniteDuration()

static Duration org.omg.dds.core.Duration.infiniteDuration ( ServiceEnvironment  env)
static
Parameters
envIdentifies the Service instance to which the object will belong.
Returns
An unmodifiable org.omg.dds.core.Duration of infinite length.

Definition at line 81 of file Duration.java.

◆ isInfinite()

abstract boolean org.omg.dds.core.Duration.isInfinite ( )
abstract

Report whether this duration lasts forever.

If this duration is infinite, the following relationship shall be true:

this.equals(infiniteDuration(this.getEnvironment()))

See also
infiniteDuration(ServiceEnvironment)

◆ isZero()

abstract boolean org.omg.dds.core.Duration.isZero ( )
abstract

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)

◆ newDuration()

static Duration org.omg.dds.core.Duration.newDuration ( long  duration,
TimeUnit  unit,
ServiceEnvironment  env 
)
static

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
envIdentifies the Service instance to which the new object will belong.
See also
isInfinite()
infiniteDuration(ServiceEnvironment)

Definition at line 62 of file Duration.java.

◆ subtract() [1/2]

abstract Duration org.omg.dds.core.Duration.subtract ( Duration  duration)
abstract
Returns
a new Duration that is the difference after subtracting the given Duration.

◆ subtract() [2/2]

abstract Duration org.omg.dds.core.Duration.subtract ( long  duration,
TimeUnit  unit 
)
abstract
Returns
a new Duration that is the difference after subtracting the given Duration.

◆ zeroDuration()

static Duration org.omg.dds.core.Duration.zeroDuration ( ServiceEnvironment  env)
static
Parameters
envIdentifies the Service instance to which the object will belong.
Returns
A org.omg.dds.core.Duration of zero length.

Definition at line 97 of file Duration.java.


The documentation for this class was generated from the following file: