1 /*******************************************************************************
2 * Copyright (c) 2009, 2010 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
;
16 * <b><u>TmfContext</u></b>
18 * Trace context structure. It ties a trace location to an event rank. The
19 * context should be enough to restore the trace state so the corresponding
22 public class TmfContext
implements ITmfContext
, Cloneable
{
24 private ITmfLocation
<?
extends Comparable
<?
>> fLocation
;
27 // ------------------------------------------------------------------------
29 // ------------------------------------------------------------------------
31 public TmfContext(ITmfLocation
<?
extends Comparable
<?
>> loc
, long rank
) {
36 public TmfContext(ITmfLocation
<?
extends Comparable
<?
>> location
) {
37 this(location
, UNKNOWN_RANK
);
40 public TmfContext(TmfContext other
) {
41 this(other
.fLocation
, other
.fRank
);
45 this(null, UNKNOWN_RANK
);
48 // ------------------------------------------------------------------------
50 // ------------------------------------------------------------------------
53 public void dispose() {
54 // override if necessary
58 public void setLocation(ITmfLocation
<?
extends Comparable
<?
>> location
) {
63 public ITmfLocation
<?
extends Comparable
<?
>> getLocation() {
68 public void setRank(long rank
) {
73 public long getRank() {
78 public void updateRank(int delta
) {
84 public boolean isValidRank() {
85 return fRank
!= UNKNOWN_RANK
;
88 // ------------------------------------------------------------------------
90 // ------------------------------------------------------------------------
93 public int hashCode() {
95 result
= 37 * result
+ fLocation
.hashCode();
96 result
= 37 * result
+ (int) (fRank ^
(fRank
>>> 32));
101 public boolean equals(Object other
) {
105 if (!(other
instanceof TmfContext
)) {
108 TmfContext o
= (TmfContext
) other
;
109 return fLocation
.equals(o
.fLocation
) && (fRank
== o
.fRank
);
113 @SuppressWarnings("nls")
114 public String
toString() {
115 return "[TmfContext(" + fLocation
.toString() + "," + fRank
+ ")]";
119 public TmfContext
clone() {
120 TmfContext clone
= null;
122 clone
= (TmfContext
) super.clone();
123 clone
.fLocation
= fLocation
.clone();
125 } catch (CloneNotSupportedException e
) {