1 /*******************************************************************************
2 * Copyright (c) 2012, 2013 Ericsson
4 * All rights reserved. This program and the accompanying materials are made
5 * 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
9 * Contributors: Matthew Khouzam - Initial API and implementation
10 *******************************************************************************/
12 package org
.eclipse
.tracecompass
.tmf
.ctf
.core
.context
;
14 import java
.nio
.ByteBuffer
;
17 * The data object to go in a {@link CtfLocation}.
19 * @author Matthew Khouzam
22 public class CtfLocationInfo
implements Comparable
<CtfLocationInfo
> {
24 private final long fTimestamp
;
25 private final long fIndex
;
31 * Index of this event (if there are N elements with the same
32 * timestamp, which one is it.)
34 public CtfLocationInfo(long ts
, long index
) {
40 * Construct the location from the ByteBuffer.
43 * the buffer to read from
47 public CtfLocationInfo(ByteBuffer bufferIn
) {
48 fTimestamp
= bufferIn
.getLong();
49 fIndex
= bufferIn
.getLong();
53 * @return The timestamp
55 public long getTimestamp() {
60 * @return The index of the element
62 public long getIndex() {
66 // ------------------------------------------------------------------------
68 // ------------------------------------------------------------------------
71 public int hashCode() {
74 result
= (prime
* result
) + (int) (fIndex ^
(fIndex
>>> 32));
75 result
= (prime
* result
) + (int) (fTimestamp ^
(fTimestamp
>>> 32));
80 public boolean equals(Object obj
) {
87 if (!(obj
instanceof CtfLocationInfo
)) {
90 CtfLocationInfo other
= (CtfLocationInfo
) obj
;
91 if (fIndex
!= other
.fIndex
) {
94 if (fTimestamp
!= other
.fTimestamp
) {
101 public String
toString() {
102 return "Element [" + fTimestamp
+ '/' + fIndex
+ ']'; //$NON-NLS-1$
105 // ------------------------------------------------------------------------
107 // ------------------------------------------------------------------------
110 public int compareTo(CtfLocationInfo other
) {
111 if (fTimestamp
> other
.getTimestamp()) {
114 if (fTimestamp
< other
.getTimestamp()) {
117 if (fIndex
> other
.getIndex()) {
120 if (fIndex
< other
.getIndex()) {
127 * Write the location to the ByteBuffer so that it can be saved to disk.
130 * the buffer to write to
134 public void serialize(ByteBuffer bufferOut
) {
135 bufferOut
.putLong(fTimestamp
);
136 bufferOut
.putLong(fIndex
);
This page took 0.035052 seconds and 5 git commands to generate.