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 * @see org.eclipse.linuxtools.tmf.core.trace.ITmfContext#getLocation()
92 public ITmfLocation
getLocation() {
97 * @see org.eclipse.linuxtools.tmf.core.trace.ITmfContext#setLocation(org.eclipse.linuxtools.tmf.core.trace.ITmfLocation)
100 public void setLocation(final ITmfLocation location
) {
101 fLocation
= location
;
105 * @see org.eclipse.linuxtools.tmf.core.trace.ITmfContext#getRank()
108 public long getRank() {
113 * @see org.eclipse.linuxtools.tmf.core.trace.ITmfContext#setRank(long)
116 public void setRank(final long rank
) {
121 * @see org.eclipse.linuxtools.tmf.core.trace.ITmfContext#increaseRank()
124 public void increaseRank() {
125 if (hasValidRank()) {
131 * @see org.eclipse.linuxtools.tmf.core.trace.ITmfContext#hasValidRank()
134 public boolean hasValidRank() {
135 return fRank
!= UNKNOWN_RANK
;
139 * @see org.eclipse.linuxtools.tmf.core.trace.ITmfContext#dispose()
142 public void dispose() {
145 // ------------------------------------------------------------------------
147 // ------------------------------------------------------------------------
150 * @see java.lang.Object#hashCode()
153 public int hashCode() {
154 final int prime
= 31;
156 result
= prime
* result
+ ((fLocation
== null) ?
0 : fLocation
.hashCode());
157 result
= prime
* result
+ (int) (fRank ^
(fRank
>>> 32));
162 * @see java.lang.Object#equals(java.lang.Object)
165 public boolean equals(final Object obj
) {
172 if (getClass() != obj
.getClass()) {
175 final TmfContext other
= (TmfContext
) obj
;
176 if (fLocation
== null) {
177 if (other
.fLocation
!= null) {
180 } else if (!fLocation
.equals(other
.fLocation
)) {
183 if (fRank
!= other
.fRank
) {
190 * @see java.lang.Object#toString()
193 @SuppressWarnings("nls")
194 public String
toString() {
195 return "TmfContext [fLocation=" + fLocation
+ ", fRank=" + fRank
+ "]";
This page took 0.034795 seconds and 5 git commands to generate.