(no commit message)
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf / src / org / eclipse / linuxtools / tmf / trace / TmfCheckpoint.java
1 /*******************************************************************************
2 * Copyright (c) 2009 Ericsson
3 *
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
8 *
9 * Contributors:
10 * Francois Chouinard - Initial API and implementation
11 *******************************************************************************/
12
13 package org.eclipse.linuxtools.tmf.trace;
14
15 import org.eclipse.linuxtools.tmf.event.TmfTimestamp;
16
17 /**
18 * <b><u>TmfCheckpoint</u></b>
19 * <p>
20 * This class maps an event timestamp to a generic location.
21 */
22 public class TmfCheckpoint implements Comparable<TmfCheckpoint> {
23
24 // ------------------------------------------------------------------------
25 // Attributes
26 // ------------------------------------------------------------------------
27
28 private final TmfTimestamp fTimestamp;
29 private final ITmfLocation<?> fLocation;
30
31 // ------------------------------------------------------------------------
32 // Constructors
33 // ------------------------------------------------------------------------
34
35 @SuppressWarnings("unused")
36 private TmfCheckpoint() {
37 fTimestamp = null;
38 fLocation = null;
39 }
40
41 /**
42 * @param ts the checkpoint timestamp
43 * @param location the corresponding trace location
44 */
45 public TmfCheckpoint(TmfTimestamp ts, ITmfLocation<?> location) {
46 fTimestamp = ts;
47 fLocation = location;
48 }
49
50 /**
51 * Deep copy constructor
52 * @param other the other checkpoint
53 */
54 public TmfCheckpoint(TmfCheckpoint other) {
55 if (other == null)
56 throw new IllegalArgumentException();
57 fTimestamp = (TmfTimestamp) other.fTimestamp.clone();
58 fLocation = other.fLocation.clone();
59 }
60
61 // ------------------------------------------------------------------------
62 // Accessors
63 // ------------------------------------------------------------------------
64
65 /**
66 * @return the checkpoint timestamp
67 */
68 public TmfTimestamp getTimestamp() {
69 return fTimestamp;
70 }
71
72 /**
73 * @return the checkpoint stream location
74 */
75 public ITmfLocation<?> getLocation() {
76 return fLocation;
77 }
78
79 // ------------------------------------------------------------------------
80 // Object
81 // ------------------------------------------------------------------------
82
83 @Override
84 public int hashCode() {
85 return fTimestamp.hashCode();
86 }
87
88 @Override
89 public boolean equals(Object other) {
90 if (!(other instanceof TmfCheckpoint)) {
91 return false;
92 }
93 TmfCheckpoint o = (TmfCheckpoint) other;
94 return fTimestamp.equals(o.fTimestamp);
95 }
96
97 @Override
98 public String toString() {
99 return "[TmfCheckpoint(" + fTimestamp + "," + fLocation + ")]";
100 }
101
102 // ------------------------------------------------------------------------
103 // Comparable
104 // ------------------------------------------------------------------------
105
106 public int compareTo(TmfCheckpoint other) {
107 return fTimestamp.compareTo(other.fTimestamp, false);
108 }
109
110 }
This page took 0.03202 seconds and 5 git commands to generate.