1 /*******************************************************************************
2 * Copyright (c) 2012 Ericsson
4 * All rights reserved. This program and the accompanying materials are made
5 * 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
9 * Contributors: Matthew Khouzam - Initial API and implementation
10 *******************************************************************************/
11 package org
.eclipse
.linuxtools
.tmf
.core
.ctfadaptor
;
13 import org
.eclipse
.linuxtools
.tmf
.core
.event
.ITmfTimestamp
;
14 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.ITmfLocation
;
17 * The nugget of information that is unique to a location in a CTF trace.
19 * It can be copied and used to restore a position in a given trace.
22 * @author Matthew Khouzam
24 public final class CtfLocation
implements ITmfLocation
{
26 private final CtfLocationData fLocation
;
31 public static final CtfLocationData INVALID_LOCATION
= new CtfLocationData(-1, -1);
34 * Constructor for CtfLocation. Uses a default index of 0.
37 * The timestamp of this location
39 public CtfLocation(final ITmfTimestamp timestamp
) {
40 this(timestamp
.getValue(), 0);
44 * Standard constructor
47 * The timestamp of this location
49 * The index of this location for this timestamp
52 public CtfLocation(final ITmfTimestamp timestamp
, long index
) {
53 this(timestamp
.getValue(), index
);
57 * Change this location's timestamp and index values.
59 * @param timestampValue
65 public CtfLocation(final long timestampValue
, final long index
) {
66 this(new CtfLocationData(timestampValue
, index
));
73 * Other location to copy
76 public CtfLocation(final CtfLocationData location
) {
81 * Get the Location Data of this location
83 * @return The CtfLocationData
84 * @see org.eclipse.linuxtools.tmf.core.trace.ITmfLocation#getLocationInfo()
88 public CtfLocationData
getLocationInfo() {
93 public CtfLocation
clone() {
94 return new CtfLocation(new CtfLocationData(fLocation
.getTimestamp(), fLocation
.getIndex()));
99 * @see java.lang.Object#hashCode()
102 public int hashCode() {
103 final int prime
= 31;
105 result
= (prime
* result
)
106 + ((fLocation
== null) ?
0 : fLocation
.hashCode());
111 * @see java.lang.Object#equals(java.lang.Object)
114 public boolean equals(Object obj
) {
121 if (!(obj
instanceof CtfLocation
)) {
124 CtfLocation other
= (CtfLocation
) obj
;
125 if (fLocation
== null) {
126 if (other
.fLocation
!= null) {
129 } else if (!fLocation
.equals(other
.fLocation
)) {
136 * @see java.lang.Object#toString()
139 public String
toString() {
140 if( this.getLocationInfo().equals(CtfLocation
.INVALID_LOCATION
)) {
141 return "CtfLocation: INVALID"; //$NON-NLS-1$
143 return "CtfLocation: " + getLocationInfo().toString(); //$NON-NLS-1$