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
.indexer
.checkpoint
;
17 import org
.eclipse
.linuxtools
.tmf
.core
.timestamp
.ITmfTimestamp
;
18 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.location
.ITmfLocation
;
21 * A basic implementation of ITmfCheckpoint. It simply maps an event timestamp
22 * to a generic location.
27 * @author Francois Chouinard
30 public class TmfCheckpoint
implements ITmfCheckpoint
{
32 // ------------------------------------------------------------------------
34 // ------------------------------------------------------------------------
36 // The checkpoint location
37 private final ITmfLocation fLocation
;
39 // The checkpoint timestamp
40 private final ITmfTimestamp fTimestamp
;
42 // ------------------------------------------------------------------------
44 // ------------------------------------------------------------------------
49 * @param timestamp the checkpoint timestamp
50 * @param location the corresponding trace location
53 public TmfCheckpoint(final ITmfTimestamp timestamp
, final ITmfLocation location
) {
54 fTimestamp
= timestamp
;
61 * @param other the other checkpoint
63 public TmfCheckpoint(final TmfCheckpoint other
) {
65 throw new IllegalArgumentException();
67 fTimestamp
= other
.fTimestamp
;
68 fLocation
= other
.fLocation
;
71 // ------------------------------------------------------------------------
73 // ------------------------------------------------------------------------
79 public ITmfTimestamp
getTimestamp() {
84 public ITmfLocation
getLocation() {
88 // ------------------------------------------------------------------------
90 // ------------------------------------------------------------------------
93 @SuppressWarnings({ "unchecked", "rawtypes" })
94 public int compareTo(final ITmfCheckpoint other
) {
96 if ((fTimestamp
!= null) && (other
.getTimestamp() != null)) {
97 comp
= fTimestamp
.compareTo(other
.getTimestamp(), false);
101 // compare locations if timestamps are the same
104 if ((fLocation
== null) && (other
.getLocation() == null)) {
108 // treat location of other as null location which is before any location
109 if ((fLocation
!= null) && (other
.getLocation() == null)) {
113 // treat this as null location which is before any other locations
114 if ((fLocation
== null) && (other
.getLocation() != null)) {
119 final Comparable location1
= getLocation().getLocationInfo();
120 final Comparable location2
= other
.getLocation().getLocationInfo();
121 return location1
.compareTo(location2
);
124 // ------------------------------------------------------------------------
126 // ------------------------------------------------------------------------
129 public int hashCode() {
130 final int prime
= 31;
132 result
= prime
* result
+ ((fLocation
== null) ?
0 : fLocation
.hashCode());
133 result
= prime
* result
+ ((fTimestamp
== null) ?
0 : fTimestamp
.hashCode());
138 public boolean equals(final Object obj
) {
145 if (!(obj
instanceof TmfCheckpoint
)) {
148 final TmfCheckpoint other
= (TmfCheckpoint
) obj
;
149 if (fLocation
== null) {
150 if (other
.fLocation
!= null) {
153 } else if (!fLocation
.equals(other
.fLocation
)) {
156 if (fTimestamp
== null) {
157 if (other
.fTimestamp
!= null) {
160 } else if (!fTimestamp
.equals(other
.fTimestamp
)) {
167 @SuppressWarnings("nls")
168 public String
toString() {
169 return getClass().getSimpleName() + " [fLocation=" + fLocation
+ ", fTimestamp=" + fTimestamp
+ "]";
This page took 0.038677 seconds and 6 git commands to generate.