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
.ITmfTimestamp
;
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 ITmfTimestamp fTimestamp
;
30 private ITmfLocation
<?
extends Comparable
> fLocation
;
32 // ------------------------------------------------------------------------
34 // ------------------------------------------------------------------------
36 @SuppressWarnings("unused")
37 private TmfCheckpoint() {
41 * @param ts the checkpoint timestamp
42 * @param location the corresponding trace location
44 public TmfCheckpoint(final ITmfTimestamp ts
, final ITmfLocation
<?
extends Comparable
> location
) {
50 * Deep copy constructor
52 * @param other the other checkpoint
54 public TmfCheckpoint(final TmfCheckpoint other
) {
56 throw new IllegalArgumentException();
57 fTimestamp
= other
.fTimestamp
.clone();
58 fLocation
= other
.fLocation
.clone();
61 // ------------------------------------------------------------------------
63 // ------------------------------------------------------------------------
66 * @return the checkpoint timestamp
68 public ITmfTimestamp
getTimestamp() {
73 * @return the checkpoint stream location
75 public ITmfLocation
<?
> getLocation() {
79 // ------------------------------------------------------------------------
81 // ------------------------------------------------------------------------
84 public TmfCheckpoint
clone() {
85 TmfCheckpoint result
= null;
87 result
= (TmfCheckpoint
) super.clone();
88 result
.fTimestamp
= fTimestamp
.clone();
89 result
.fLocation
= fLocation
.clone();
91 } catch (final CloneNotSupportedException e
) {
98 public int hashCode() {
99 return fTimestamp
.hashCode();
103 public boolean equals(final Object other
) {
104 if (!(other
instanceof TmfCheckpoint
))
106 final TmfCheckpoint o
= (TmfCheckpoint
) other
;
107 return fTimestamp
.equals(o
.fTimestamp
);
111 @SuppressWarnings("nls")
112 public String
toString() {
113 return "[TmfCheckpoint(" + fTimestamp
+ "," + fLocation
+ ")]";
116 // ------------------------------------------------------------------------
118 // ------------------------------------------------------------------------
120 @SuppressWarnings("unchecked")
122 public int compareTo(final TmfCheckpoint other
) {
123 if (fTimestamp
== null || other
.fTimestamp
== null)
124 return fLocation
.getLocation().compareTo(other
.fLocation
.getLocation());
125 return fTimestamp
.compareTo(other
.fTimestamp
, false);