1 /*******************************************************************************
2 * Copyright (c) 2009, 2013 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 * Francois Chouinard - Updated as per TMF Trace Model 1.0
12 * Patrick Tasse - Updated for location in checkpoint
13 ******************************************************************************/
15 package org
.eclipse
.linuxtools
.tmf
.core
.trace
;
17 import org
.eclipse
.linuxtools
.tmf
.core
.timestamp
.ITmfTimestamp
;
20 * A basic implementation of ITmfCheckpoint. It simply maps an event timestamp
21 * to a generic location.
24 * @author Francois Chouinard
29 public class TmfCheckpoint
implements ITmfCheckpoint
{
31 // ------------------------------------------------------------------------
33 // ------------------------------------------------------------------------
35 // The checkpoint location
36 private final ITmfLocation fLocation
;
38 // The checkpoint timestamp
39 private final ITmfTimestamp fTimestamp
;
41 // ------------------------------------------------------------------------
43 // ------------------------------------------------------------------------
48 * @param timestamp the checkpoint timestamp
49 * @param location the corresponding trace location
52 public TmfCheckpoint(final ITmfTimestamp timestamp
, final ITmfLocation location
) {
53 fTimestamp
= timestamp
;
60 * @param other the other checkpoint
62 public TmfCheckpoint(final TmfCheckpoint other
) {
64 throw new IllegalArgumentException();
66 fTimestamp
= other
.fTimestamp
;
67 fLocation
= other
.fLocation
;
70 // ------------------------------------------------------------------------
72 // ------------------------------------------------------------------------
78 public ITmfTimestamp
getTimestamp() {
83 public ITmfLocation
getLocation() {
87 // ------------------------------------------------------------------------
89 // ------------------------------------------------------------------------
92 @SuppressWarnings({ "unchecked", "rawtypes" })
93 public int compareTo(final ITmfCheckpoint other
) {
95 if ((fTimestamp
!= null) && (other
.getTimestamp() != null)) {
96 comp
= fTimestamp
.compareTo(other
.getTimestamp(), false);
100 // compare locations if timestamps are the same
103 if ((fLocation
== null) && (other
.getLocation() == null)) {
107 // treat location of other as null location which is before any location
108 if ((fLocation
!= null) && (other
.getLocation() == null)) {
112 // treat this as null location which is before any other locations
113 if ((fLocation
== null) && (other
.getLocation() != null)) {
118 final Comparable location1
= getLocation().getLocationInfo();
119 final Comparable location2
= other
.getLocation().getLocationInfo();
120 return location1
.compareTo(location2
);
123 // ------------------------------------------------------------------------
125 // ------------------------------------------------------------------------
128 public int hashCode() {
129 final int prime
= 31;
131 result
= prime
* result
+ ((fLocation
== null) ?
0 : fLocation
.hashCode());
132 result
= prime
* result
+ ((fTimestamp
== null) ?
0 : fTimestamp
.hashCode());
137 public boolean equals(final Object obj
) {
144 if (!(obj
instanceof TmfCheckpoint
)) {
147 final TmfCheckpoint other
= (TmfCheckpoint
) obj
;
148 if (fLocation
== null) {
149 if (other
.fLocation
!= null) {
152 } else if (!fLocation
.equals(other
.fLocation
)) {
155 if (fTimestamp
== null) {
156 if (other
.fTimestamp
!= null) {
159 } else if (!fTimestamp
.equals(other
.fTimestamp
)) {
166 @SuppressWarnings("nls")
167 public String
toString() {
168 return getClass().getSimpleName() + " [fLocation=" + fLocation
+ ", fTimestamp=" + fTimestamp
+ "]";
This page took 0.131434 seconds and 5 git commands to generate.