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 java
.util
.Objects
;
19 import org
.eclipse
.jdt
.annotation
.Nullable
;
20 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.location
.ITmfLocation
;
23 * A basic implementation of ITmfContext.
25 * It ties a trace location to an event rank. The context should be enough to
26 * restore the trace state so the corresponding event can be read.
28 * @author Francois Chouinard
32 public class TmfContext
implements ITmfContext
{
34 // ------------------------------------------------------------------------
36 // ------------------------------------------------------------------------
39 private @Nullable ITmfLocation fLocation
;
44 // ------------------------------------------------------------------------
46 // ------------------------------------------------------------------------
52 this(null, UNKNOWN_RANK
);
56 * Simple constructor (unknown rank)
58 * @param location the event location
60 public TmfContext(final ITmfLocation location
) {
61 this(location
, UNKNOWN_RANK
);
67 * @param location the event location
68 * @param rank the event rank
70 public TmfContext(final ITmfLocation location
, final long rank
) {
78 * @param context the other context
80 public TmfContext(final TmfContext context
) {
81 if (context
== null) {
82 throw new IllegalArgumentException();
84 fLocation
= context
.fLocation
;
85 fRank
= context
.fRank
;
88 // ------------------------------------------------------------------------
90 // ------------------------------------------------------------------------
93 public @Nullable ITmfLocation
getLocation() {
98 public void setLocation(final ITmfLocation location
) {
103 public long getRank() {
108 public void setRank(final long rank
) {
113 public void increaseRank() {
114 if (hasValidRank()) {
120 public boolean hasValidRank() {
121 return fRank
!= UNKNOWN_RANK
;
125 public void dispose() {
128 // ------------------------------------------------------------------------
130 // ------------------------------------------------------------------------
133 public int hashCode() {
134 return Objects
.hash(fRank
, fLocation
);
138 public boolean equals(final Object obj
) {
145 if (getClass() != obj
.getClass()) {
148 final TmfContext other
= (TmfContext
) obj
;
149 if (fRank
!= other
.fRank
) {
152 if (!Objects
.equals(fLocation
, other
.fLocation
)) {
159 @SuppressWarnings("nls")
160 public String
toString() {
161 return "TmfContext [fLocation=" + fLocation
+ ", fRank=" + fRank
+ "]";
This page took 0.044953 seconds and 5 git commands to generate.