Remove all existing @since annotations
[deliverable/tracecompass.git] / org.eclipse.tracecompass.tmf.ctf.core / src / org / eclipse / tracecompass / tmf / ctf / core / context / CtfLocation.java
1 /*******************************************************************************
2 * Copyright (c) 2012, 2014 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:
10 * Matthew Khouzam - Initial API and implementation
11 * Alexandre Montplaisir - Extends TmfLocation
12 *******************************************************************************/
13
14 package org.eclipse.tracecompass.tmf.ctf.core.context;
15
16 import java.nio.ByteBuffer;
17
18 import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
19 import org.eclipse.tracecompass.tmf.core.trace.location.TmfLocation;
20
21 /**
22 * The nugget of information that is unique to a location in a CTF trace.
23 *
24 * It can be copied and used to restore a position in a given trace.
25 *
26 * @author Matthew Khouzam
27 */
28 public final class CtfLocation extends TmfLocation {
29
30 // ------------------------------------------------------------------------
31 // Attributes
32 // ------------------------------------------------------------------------
33
34 /**
35 * An invalid location
36 */
37 public static final CtfLocationInfo INVALID_LOCATION = new CtfLocationInfo(-1, -1);
38
39 // ------------------------------------------------------------------------
40 // Constructors
41 // ------------------------------------------------------------------------
42
43 /**
44 * Basic constructor for CtfLocation. Uses a default index of 0.
45 *
46 * @param timestamp
47 * The timestamp of this location
48 */
49 public CtfLocation(final ITmfTimestamp timestamp) {
50 this(timestamp.getValue(), 0);
51 }
52
53 /**
54 * Constructor using timestamp object and index
55 *
56 * @param timestamp
57 * The timestamp of this location
58 * @param index
59 * The index of this location for this timestamp
60 */
61 public CtfLocation(final ITmfTimestamp timestamp, long index) {
62 this(timestamp.getValue(), index);
63 }
64
65 /**
66 * Constructor using a long value for the timestamp, and an index
67 *
68 * @param timestampValue
69 * The new timestamp
70 * @param index
71 * The new index
72 */
73 public CtfLocation(final long timestampValue, final long index) {
74 super(new CtfLocationInfo(timestampValue, index));
75 }
76
77 /**
78 * Constructor using a pre-made locationInfo object
79 *
80 * @param locationInfo
81 * The locationInfo object to use
82 */
83 public CtfLocation(CtfLocationInfo locationInfo) {
84 super(locationInfo);
85 }
86
87 /**
88 * Copy constructor
89 *
90 * @param location
91 * Other location to copy
92 */
93 public CtfLocation(final CtfLocation location) {
94 super(location);
95 }
96
97 // ------------------------------------------------------------------------
98 // TmfLocation
99 // ------------------------------------------------------------------------
100
101 /**
102 * Construct the location from the ByteBuffer.
103 *
104 * @param bufferIn
105 * the buffer to read from
106 */
107 public CtfLocation(ByteBuffer bufferIn) {
108 super(new CtfLocationInfo(bufferIn));
109 }
110
111 @Override
112 public CtfLocationInfo getLocationInfo() {
113 return (CtfLocationInfo) super.getLocationInfo();
114 }
115
116 // ------------------------------------------------------------------------
117 // Object
118 // ------------------------------------------------------------------------
119
120 @Override
121 public String toString() {
122 if (getLocationInfo().equals(CtfLocation.INVALID_LOCATION )) {
123 return getClass().getSimpleName() + " [INVALID]"; //$NON-NLS-1$
124 }
125 return super.toString();
126 }
127
128 /**
129 * Constructs the location from the ByteBuffer. This typically happens when reading from disk.
130 */
131 @Override
132 public void serialize(ByteBuffer bufferOut) {
133 getLocationInfo().serialize(bufferOut);
134 }
135 }
This page took 0.033847 seconds and 5 git commands to generate.