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 * Francois Chouinard - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.tmf
.core
.trace
;
15 import org
.eclipse
.linuxtools
.tmf
.core
.event
.TmfTimestamp
;
18 * <b><u>TmfCheckpoint</u></b>
20 * This class maps an event timestamp to a generic location.
22 @SuppressWarnings("rawtypes")
23 public class TmfCheckpoint
implements Comparable
<TmfCheckpoint
>, Cloneable
{
25 // ------------------------------------------------------------------------
27 // ------------------------------------------------------------------------
29 private TmfTimestamp fTimestamp
;
30 private ITmfLocation
<?
extends Comparable
> fLocation
;
32 // ------------------------------------------------------------------------
34 // ------------------------------------------------------------------------
36 @SuppressWarnings("unused")
37 private TmfCheckpoint() {
43 * @param ts the checkpoint timestamp
44 * @param location the corresponding trace location
46 public TmfCheckpoint(TmfTimestamp ts
, ITmfLocation
<?
extends Comparable
> location
) {
52 * Deep copy constructor
53 * @param other the other checkpoint
55 public TmfCheckpoint(TmfCheckpoint other
) {
57 throw new IllegalArgumentException();
58 fTimestamp
= (TmfTimestamp
) other
.fTimestamp
.clone();
59 fLocation
= other
.fLocation
.clone();
62 // ------------------------------------------------------------------------
64 // ------------------------------------------------------------------------
67 * @return the checkpoint timestamp
69 public TmfTimestamp
getTimestamp() {
74 * @return the checkpoint stream location
76 public ITmfLocation
<?
> getLocation() {
80 // ------------------------------------------------------------------------
82 // ------------------------------------------------------------------------
85 public TmfCheckpoint
clone() {
86 TmfCheckpoint result
= null;
88 result
= (TmfCheckpoint
) super.clone();
89 result
.fTimestamp
= new TmfTimestamp(fTimestamp
);
90 result
.fLocation
= fLocation
.clone();
92 } catch (CloneNotSupportedException e
) {
99 public int hashCode() {
100 return fTimestamp
.hashCode();
104 public boolean equals(Object other
) {
105 if (!(other
instanceof TmfCheckpoint
)) {
108 TmfCheckpoint o
= (TmfCheckpoint
) other
;
109 return fTimestamp
.equals(o
.fTimestamp
);
113 @SuppressWarnings("nls")
114 public String
toString() {
115 return "[TmfCheckpoint(" + fTimestamp
+ "," + fLocation
+ ")]";
118 // ------------------------------------------------------------------------
120 // ------------------------------------------------------------------------
122 @SuppressWarnings("unchecked")
124 public int compareTo(TmfCheckpoint other
) {
125 if (fTimestamp
== null || other
.fTimestamp
== null) {
126 return fLocation
.getLocation().compareTo(other
.fLocation
.getLocation());
128 return fTimestamp
.compareTo(other
.fTimestamp
, false);