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 *******************************************************************************/
11 package org
.eclipse
.linuxtools
.tmf
.core
.ctfadaptor
;
13 import java
.nio
.ByteBuffer
;
16 * The data object to go in a {@link CtfLocation}.
18 * @author Matthew Khouzam
21 public class CtfLocationInfo
implements Comparable
<CtfLocationInfo
> {
23 private final long timestamp
;
24 private final long index
;
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
46 public CtfLocationInfo(ByteBuffer bufferIn
) {
47 timestamp
= bufferIn
.getLong();
48 index
= bufferIn
.getLong();
52 * @return The timestamp
54 public long getTimestamp() {
59 * @return The index of the element
61 public long getIndex() {
65 // ------------------------------------------------------------------------
67 // ------------------------------------------------------------------------
70 public int hashCode() {
73 result
= (prime
* result
) + (int) (index ^
(index
>>> 32));
74 result
= (prime
* result
) + (int) (timestamp ^
(timestamp
>>> 32));
79 public boolean equals(Object obj
) {
86 if (!(obj
instanceof CtfLocationInfo
)) {
89 CtfLocationInfo other
= (CtfLocationInfo
) obj
;
90 if (index
!= other
.index
) {
93 if (timestamp
!= other
.timestamp
) {
100 public String
toString() {
101 return "Element [" + timestamp
+ '/' + index
+ ']'; //$NON-NLS-1$
104 // ------------------------------------------------------------------------
106 // ------------------------------------------------------------------------
109 public int compareTo(CtfLocationInfo other
) {
110 if (this.timestamp
> other
.getTimestamp()) {
113 if (this.timestamp
< other
.getTimestamp()) {
116 if (this.index
> other
.getIndex()) {
119 if (this.index
< other
.getIndex()) {
126 * Write the location to the ByteBuffer so that it can be saved to disk.
129 * the buffer to write to
133 public void serialize(ByteBuffer bufferOut
) {
134 bufferOut
.putLong(timestamp
);
135 bufferOut
.putLong(index
);
This page took 0.035102 seconds and 6 git commands to generate.