fce69dbd2edd12d8eeb02fc06f797b1662ad1296
1 /*******************************************************************************
2 * Copyright (c) 2012, 2014 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
21 public class CtfLocationInfo
implements Comparable
<CtfLocationInfo
> {
23 private final long fTimestamp
;
24 private final long fIndex
;
30 * Index of this event (if there are N elements with the same
31 * timestamp, which one is it.)
33 public CtfLocationInfo(long ts
, long index
) {
39 * Construct the location from the ByteBuffer.
42 * the buffer to read from
44 public CtfLocationInfo(ByteBuffer bufferIn
) {
45 fTimestamp
= bufferIn
.getLong();
46 fIndex
= bufferIn
.getLong();
50 * @return The timestamp
52 public long getTimestamp() {
57 * @return The index of the element
59 public long getIndex() {
63 // ------------------------------------------------------------------------
65 // ------------------------------------------------------------------------
68 public int hashCode() {
71 result
= (prime
* result
) + (int) (fIndex ^
(fIndex
>>> 32));
72 result
= (prime
* result
) + (int) (fTimestamp ^
(fTimestamp
>>> 32));
77 public boolean equals(Object obj
) {
84 if (!(obj
instanceof CtfLocationInfo
)) {
87 CtfLocationInfo other
= (CtfLocationInfo
) obj
;
88 if (fIndex
!= other
.fIndex
) {
91 if (fTimestamp
!= other
.fTimestamp
) {
98 public String
toString() {
99 return "Element [" + fTimestamp
+ '/' + fIndex
+ ']'; //$NON-NLS-1$
102 // ------------------------------------------------------------------------
104 // ------------------------------------------------------------------------
107 public int compareTo(CtfLocationInfo other
) {
108 if (fTimestamp
> other
.getTimestamp()) {
111 if (fTimestamp
< other
.getTimestamp()) {
114 if (fIndex
> other
.getIndex()) {
117 if (fIndex
< other
.getIndex()) {
124 * Write the location to the ByteBuffer so that it can be saved to disk.
127 * the buffer to write to
129 public void serialize(ByteBuffer bufferOut
) {
130 bufferOut
.putLong(fTimestamp
);
131 bufferOut
.putLong(fIndex
);
This page took 0.033541 seconds and 4 git commands to generate.