1 /*******************************************************************************
2 * Copyright (c) 2009 Ericsson
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * William Bourque (wbourque@gmail.com) - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.lttng
.jni
;
16 * <b><u>JniTime</u></b>
18 * JniTime object linked to the LttTime C structure
20 public final class JniTime
extends Jni_C_Common
22 private long time
= 0;
25 * Default constructor.
35 * @param oldTime A reference to the JniTime you want to copy.
37 JniTime(JniTime oldTime
) {
38 time
= oldTime
.getTime();
42 * Constructor with parameters
44 * "Ltt style" constructor with Seconds et Nanoseconds
46 * @param newSec Seconds of the JniTime
47 * @param newNanoSec Nanoseconds of the JniTime
49 JniTime(long newSec
, long newNanoSec
) {
50 time
= (newSec
* NANO
) + newNanoSec
;
54 * Constructor with parameters
56 * Usual "nanosecond only" constructor
58 * @param newNanoSecTime JniTime in nanoseconds
60 public JniTime(long newNanoSecTime
) {
61 time
= newNanoSecTime
;
65 * Getter for the second of the time
67 * This only return seconds part, i.e. multiple of 1 000 000, of the stored time
69 * @return long Second of the time
71 public long getSeconds() {
76 * Getter for the nanosecond of the time
78 * This only nanosecondspart , i.e. modulo of 1 000 000, of the stored time
80 * @return long Nanoseconds of the time
82 public long getNanoSeconds() {
87 * Getter for the full time, in nanoseconds
89 * @return The complete time in nanoseconds
91 public long getTime() {
96 * Comparaison operator <=
98 * @param comparedTime The time we want to compare with this one
99 * @return boolean true if the compared time is smaller or equal, false otherwise
101 public boolean isGivenTimeSmallerOrEqual(JniTime comparedTime
) {
103 // NOTE : We check <= instead of just <
104 // This mean the RIGHT OPERAND (comparedTime) always prevails
105 if (comparedTime
.getTime() < this.getTime()) {
113 * Integer Comparaison operator
115 * @param comparedTime The time we want to compare with this one
116 * @return int Integer of value -1, 0 or 1, as the pased argument is bigger, equal or smaller than this time
118 public int compare(JniTime comparedTime
) {
119 if ( comparedTime
.getTime() < this.getTime() ) {
122 else if ( comparedTime
.getTime() > this.getTime() ) {
131 * Populate this time object
133 * Note: This function is called from C side.
135 * @param newTime The time we want to populate
137 @SuppressWarnings("unused")
138 private void setTimeFromC(long newTime
) {
143 * toString() method. <u>Intended to debug</u><br>
145 * NOTE : we output the time in the same format as LTT (seconds and nanosecond separatly)
147 * @return String Attributes of the object concatenated in String
149 public String
toString() {
150 String returnData
= "";
152 returnData
+= "seconds : " + this.getSeconds() + "\n";
153 returnData
+= "nanoSeconds : " + this.getNanoSeconds() + "\n";
This page took 0.038093 seconds and 5 git commands to generate.