OpenSplice Java 5 DCPS  v6.x
OpenSplice Java 5 OpenSplice Data Distribution Service Data-Centric Publish-Subscribe API
Time.java
Go to the documentation of this file.
1 /* Copyright 2010, Object Management Group, Inc.
2  * Copyright 2010, PrismTech, Inc.
3  * Copyright 2010, Real-Time Innovations, Inc.
4  * All rights reserved.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18 
19 package org.omg.dds.core;
20 
21 import java.io.Serializable;
22 import java.util.concurrent.TimeUnit;
23 
25 import org.omg.dds.type.Nested;
26 
27 
32 @Extensibility(Extensibility.Kind.FINAL_EXTENSIBILITY)
33 @Nested
34 public abstract class Time
35 implements Comparable<Time>, Serializable, DDSObject
36 {
37  // -----------------------------------------------------------------------
38  // Private Constants
39  // -----------------------------------------------------------------------
40 
41  private static final long serialVersionUID = -132361141453190372L;
42 
43 
44 
45  // -----------------------------------------------------------------------
46  // Factory Methods
47  // -----------------------------------------------------------------------
48 
62  public static ModifiableTime newTime(
63  long time,
64  TimeUnit units,
66  {
67  if (env == null) {
68  throw new IllegalArgumentException(
69  "Invalid ServiceEnvironment (null) provided.");
70  }
71  return env.getSPI().newTime(time, units);
72  }
73 
74 
81  public static Time invalidTime(ServiceEnvironment env)
82  {
83  if (env == null) {
84  throw new IllegalArgumentException(
85  "Invalid ServiceEnvironment (null) provided.");
86  }
87  return env.getSPI().invalidTime();
88  }
89 
90 
91 
92  // -----------------------------------------------------------------------
93  // Instance Methods
94  // -----------------------------------------------------------------------
95 
96  // --- Data access: ------------------------------------------------------
97 
121  public abstract long getTime(TimeUnit inThisUnit);
122 
153  public abstract long getRemainder(
154  TimeUnit primaryUnit, TimeUnit remainderUnit);
155 
156 
157  // --- Query: ------------------------------------------------------------
158 
162  public abstract boolean isValid();
163 
164 
165  // --- Modification: -----------------------------------------------------
166 
170  public abstract ModifiableTime modifiableCopy();
171 }
abstract long getTime(TimeUnit inThisUnit)
Truncate this time to a whole-number quantity of the given time unit.
abstract long getRemainder(TimeUnit primaryUnit, TimeUnit remainderUnit)
If getting the magnitude of this time in the given primaryUnit would cause truncation with respect to...
static ModifiableTime newTime(long time, TimeUnit units, ServiceEnvironment env)
Construct a specific instant in time.
Definition: Time.java:62
abstract boolean isValid()
ModifiableTime newTime(long time, TimeUnit units)
Construct a specific instant in time.
abstract ServiceProviderInterface getSPI()
This method is not intended for use by applications.
A supertype of all DDS classes and interfaces.
Definition: DDSObject.java:25
static Time invalidTime(ServiceEnvironment env)
Definition: Time.java:81
abstract ModifiableTime modifiableCopy()
DDS implementations are rooted in this class, a concrete subclass of which can be instantiated based ...
A moment in time expressed with nanosecond precision (though not necessarily nanosecond accuracy)...
Definition: Time.java:34