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 removal of context clone
13 *******************************************************************************/
15 package org
.eclipse
.linuxtools
.tmf
.core
.trace
;
17 import org
.eclipse
.linuxtools
.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.
26 * @author Francois Chouinard
30 public class TmfContext
implements ITmfContext
{
32 // ------------------------------------------------------------------------
34 // ------------------------------------------------------------------------
37 private ITmfLocation fLocation
;
42 // ------------------------------------------------------------------------
44 // ------------------------------------------------------------------------
50 this(null, UNKNOWN_RANK
);
54 * Simple constructor (unknown rank)
56 * @param location the event location
59 public TmfContext(final ITmfLocation location
) {
60 this(location
, UNKNOWN_RANK
);
66 * @param location the event location
67 * @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 // ------------------------------------------------------------------------
96 public ITmfLocation
getLocation() {
104 public void setLocation(final ITmfLocation location
) {
105 fLocation
= location
;
109 public long getRank() {
114 public void setRank(final long rank
) {
119 public void increaseRank() {
120 if (hasValidRank()) {
126 public boolean hasValidRank() {
127 return fRank
!= UNKNOWN_RANK
;
131 public void dispose() {
134 // ------------------------------------------------------------------------
136 // ------------------------------------------------------------------------
139 public int hashCode() {
140 final int prime
= 31;
142 result
= prime
* result
+ ((fLocation
== null) ?
0 : fLocation
.hashCode());
143 result
= prime
* result
+ (int) (fRank ^
(fRank
>>> 32));
148 public boolean equals(final Object obj
) {
155 if (getClass() != obj
.getClass()) {
158 final TmfContext other
= (TmfContext
) obj
;
159 if (fLocation
== null) {
160 if (other
.fLocation
!= null) {
163 } else if (!fLocation
.equals(other
.fLocation
)) {
166 if (fRank
!= other
.fRank
) {
173 @SuppressWarnings("nls")
174 public String
toString() {
175 return "TmfContext [fLocation=" + fLocation
+ ", fRank=" + fRank
+ "]";
This page took 0.035277 seconds and 6 git commands to generate.