Fix Statistics JUnit test
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.core / src / org / eclipse / linuxtools / tmf / core / ctfadaptor / CtfLocation.java
CommitLineData
b1baa808
MK
1/*******************************************************************************
2 * Copyright (c) 2012 Ericsson
3 *
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
8 *
9 * Contributors: Matthew Khouzam - Initial API and implementation
10 *******************************************************************************/
a3fc8213
AM
11package org.eclipse.linuxtools.tmf.core.ctfadaptor;
12
13import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp;
14import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;
15
b1baa808 16/**
d09f973b
FC
17 * The nugget of information that is unique to a location in a CTF trace.
18 *
19 * It can be copied and used to restore a position in a given trace.
20 *
21 * @version 1.0
22 * @author Matthew Khouzam
b1baa808 23 */
0879b6b9 24public class CtfLocation implements ITmfLocation<Long>, Cloneable {
a3fc8213 25
9ac2eb62
MK
26 /**
27 * An invalid location
28 */
57c073c5
MK
29 public static final Long INVALID_LOCATION = -1L;
30
b1baa808
MK
31 /**
32 * Constructor for CtfLocation.
33 * @param location Long
34 */
a3fc8213
AM
35 public CtfLocation(Long location) {
36 setLocation(location);
37 }
ce2388e0 38
b1baa808
MK
39 /**
40 * Constructor for CtfLocation.
41 * @param timestamp ITmfTimestamp
42 */
a3fc8213
AM
43 public CtfLocation(ITmfTimestamp timestamp) {
44 setLocation(timestamp.getValue());
45 }
46
47 private Long fTimestamp;
48
b1baa808
MK
49 /**
50 * Method setLocation.
51 * @param location Long
52 */
a3fc8213
AM
53 public void setLocation(Long location) {
54 this.fTimestamp = location;
55 }
56
b1baa808
MK
57 /**
58 * Method getLocation.
59 * @return Long
60 * @see org.eclipse.linuxtools.tmf.core.trace.ITmfLocation#getLocation()
61 */
a3fc8213
AM
62 @Override
63 public Long getLocation() {
64 return this.fTimestamp;
65 }
66
b1baa808
MK
67 /**
68 * Method clone.
69 * @return CtfLocation
70 * @see org.eclipse.linuxtools.tmf.core.trace.ITmfLocation#clone()
71 */
a3fc8213
AM
72 @Override
73 public CtfLocation clone() {
408e65d2 74 return new CtfLocation(getLocation().longValue());
a3fc8213
AM
75 }
76
81c8e6f7
MK
77 /* (non-Javadoc)
78 * @see java.lang.Object#hashCode()
79 */
80 @Override
81 public int hashCode() {
82 final int prime = 31;
83 int result = 1;
84 result = (prime * result)
85 + ((fTimestamp == null) ? 0 : fTimestamp.hashCode());
86 return result;
87 }
88
89 /* (non-Javadoc)
90 * @see java.lang.Object#equals(java.lang.Object)
91 */
92 @Override
93 public boolean equals(Object obj) {
94 if (this == obj) {
95 return true;
96 }
97 if (obj == null) {
98 return false;
99 }
100 if (!(obj instanceof CtfLocation)) {
101 return false;
102 }
103 CtfLocation other = (CtfLocation) obj;
104 if (fTimestamp == null) {
105 if (other.fTimestamp != null) {
106 return false;
107 }
108 } else if (!fTimestamp.equals(other.fTimestamp)) {
109 return false;
110 }
111 return true;
112 }
113
eea58fe7
MK
114 /* (non-Javadoc)
115 * @see java.lang.Object#toString()
116 */
117 @Override
118 public String toString() {
119 if( this.getLocation().equals(CtfLocation.INVALID_LOCATION )) {
120 return "CtfLocation: INVALID"; //$NON-NLS-1$
121 }
122 return "CtfLocation: " + getLocation().toString(); //$NON-NLS-1$
123 }
124
a3fc8213 125}
This page took 0.037226 seconds and 5 git commands to generate.