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
;
18 * A basic implementation of ITmfContext.
20 * It ties a trace location to an event rank. The context should be enough to
21 * restore the trace state so the corresponding event can be read.
24 * @author Francois Chouinard
28 public class TmfContext
implements ITmfContext
{
30 // ------------------------------------------------------------------------
32 // ------------------------------------------------------------------------
35 private ITmfLocation fLocation
;
40 // ------------------------------------------------------------------------
42 // ------------------------------------------------------------------------
48 this(null, UNKNOWN_RANK
);
52 * Simple constructor (unknown rank)
54 * @param location the event location
56 public TmfContext(final ITmfLocation location
) {
57 this(location
, UNKNOWN_RANK
);
63 * @param location the event location
64 * @param rank the event rank
66 public TmfContext(final ITmfLocation location
, final long rank
) {
74 * @param context the other context
76 public TmfContext(final TmfContext context
) {
77 if (context
== null) {
78 throw new IllegalArgumentException();
80 fLocation
= context
.fLocation
;
81 fRank
= context
.fRank
;
84 // ------------------------------------------------------------------------
86 // ------------------------------------------------------------------------
89 public ITmfLocation
getLocation() {
94 public void setLocation(final ITmfLocation location
) {
99 public long getRank() {
104 public void setRank(final long rank
) {
109 public void increaseRank() {
110 if (hasValidRank()) {
116 public boolean hasValidRank() {
117 return fRank
!= UNKNOWN_RANK
;
121 public void dispose() {
124 // ------------------------------------------------------------------------
126 // ------------------------------------------------------------------------
129 public int hashCode() {
130 final int prime
= 31;
132 result
= prime
* result
+ ((fLocation
== null) ?
0 : fLocation
.hashCode());
133 result
= prime
* result
+ (int) (fRank ^
(fRank
>>> 32));
138 public boolean equals(final Object obj
) {
145 if (getClass() != obj
.getClass()) {
148 final TmfContext other
= (TmfContext
) obj
;
149 if (fLocation
== null) {
150 if (other
.fLocation
!= null) {
153 } else if (!fLocation
.equals(other
.fLocation
)) {
156 if (fRank
!= other
.fRank
) {
163 @SuppressWarnings("nls")
164 public String
toString() {
165 return "TmfContext [fLocation=" + fLocation
+ ", fRank=" + fRank
+ "]";
This page took 0.034148 seconds and 5 git commands to generate.