1 /*******************************************************************************
2 * Copyright (c) 2009, 2014 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 removal of context clone
13 *******************************************************************************/
15 package org
.eclipse
.tracecompass
.tmf
.core
.trace
;
17 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.location
.ITmfLocation
;
20 * A basic implementation of ITmfContext.
22 * It ties a trace location to an event rank. The context should be enough to
23 * restore the trace state so the corresponding event can be read.
25 * @author Francois Chouinard
29 public class TmfContext
implements ITmfContext
{
31 // ------------------------------------------------------------------------
33 // ------------------------------------------------------------------------
36 private ITmfLocation fLocation
;
41 // ------------------------------------------------------------------------
43 // ------------------------------------------------------------------------
49 this(null, UNKNOWN_RANK
);
53 * Simple constructor (unknown rank)
55 * @param location the event location
57 public TmfContext(final ITmfLocation location
) {
58 this(location
, UNKNOWN_RANK
);
64 * @param location the event location
65 * @param rank the event rank
67 public TmfContext(final ITmfLocation location
, final long rank
) {
75 * @param context the other context
77 public TmfContext(final TmfContext context
) {
78 if (context
== null) {
79 throw new IllegalArgumentException();
81 fLocation
= context
.fLocation
;
82 fRank
= context
.fRank
;
85 // ------------------------------------------------------------------------
87 // ------------------------------------------------------------------------
90 public ITmfLocation
getLocation() {
95 public void setLocation(final ITmfLocation location
) {
100 public long getRank() {
105 public void setRank(final long rank
) {
110 public void increaseRank() {
111 if (hasValidRank()) {
117 public boolean hasValidRank() {
118 return fRank
!= UNKNOWN_RANK
;
122 public void dispose() {
125 // ------------------------------------------------------------------------
127 // ------------------------------------------------------------------------
130 public int hashCode() {
131 final int prime
= 31;
133 result
= prime
* result
+ ((fLocation
== null) ?
0 : fLocation
.hashCode());
134 result
= prime
* result
+ (int) (fRank ^
(fRank
>>> 32));
139 public boolean equals(final Object obj
) {
146 if (getClass() != obj
.getClass()) {
149 final TmfContext other
= (TmfContext
) obj
;
150 if (fLocation
== null) {
151 if (other
.fLocation
!= null) {
154 } else if (!fLocation
.equals(other
.fLocation
)) {
157 if (fRank
!= other
.fRank
) {
164 @SuppressWarnings("nls")
165 public String
toString() {
166 return "TmfContext [fLocation=" + fLocation
+ ", fRank=" + fRank
+ "]";
This page took 0.041513 seconds and 5 git commands to generate.