Make the TmfLocation final and get rid of clone()
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.core / src / org / eclipse / linuxtools / internal / tmf / core / trace / TmfExperimentLocation.java
CommitLineData
8c8bf09f 1/*******************************************************************************
0316808c 2 * Copyright (c) 2009, 2010, 2012 Ericsson
9b749023 3 *
8c8bf09f
ASL
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
9b749023 8 *
8c8bf09f 9 * Contributors:
0316808c
FC
10 * Francois Chouinard - Initial API and implementation
11 * Francois Chouinard - Updated as per TMF Trace Model 1.0
8c8bf09f
ASL
12 *******************************************************************************/
13
9e0640dc 14package org.eclipse.linuxtools.internal.tmf.core.trace;
8c8bf09f 15
5cc97265 16import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;
8c8bf09f 17
d62bb185 18
8c8bf09f 19/**
0316808c
FC
20 * The experiment location in TMF.
21 * <p>
22 * An experiment location is actually the set of locations of the traces it
23 * contains. By setting the individual traces to their corresponding locations,
24 * the experiment can be positioned to read the next chronological event.
8c8bf09f 25 * <p>
0316808c
FC
26 * It is the responsibility of the user the individual trace locations are valid
27 * and that they are matched to the correct trace.
9b749023 28 *
0316808c
FC
29 * @version 1.0
30 * @author Francois Chouinard
9b749023 31 *
0316808c 32 * @see TmfLocationArray
8c8bf09f 33 */
d62bb185 34public final class TmfExperimentLocation implements ITmfLocation {
cb8c854e 35
d62bb185 36 private final TmfLocationArray fLocation;
8c8bf09f 37
0316808c
FC
38 // ------------------------------------------------------------------------
39 // Constructors
40 // ------------------------------------------------------------------------
8f50c396 41
0316808c
FC
42 /**
43 * The standard constructor
9b749023 44 *
0316808c
FC
45 * @param locations the set of trace locations
46 */
47 public TmfExperimentLocation(TmfLocationArray locations) {
cb8c854e 48 fLocation = locations;
0316808c 49 }
8c8bf09f 50
0316808c
FC
51 /**
52 * The copy constructor
9b749023 53 *
0316808c
FC
54 * @param location the other experiment location
55 */
56 public TmfExperimentLocation(TmfExperimentLocation location) {
5976d44a 57 this(location.getLocationInfo());
0316808c 58 }
8c8bf09f 59
d62bb185
FC
60 /**
61 * The "update" constructor. Copies the array of locations and updates
62 * a single entry.
63 *
64 * @param exp_location the experiment location
65 * @param index the entry to modify
66 * @param location the new entry
0316808c 67 */
d62bb185
FC
68 public TmfExperimentLocation(TmfExperimentLocation exp_location, int index, ITmfLocation location) {
69 fLocation = new TmfLocationArray(exp_location.fLocation, index, location);
8f50c396 70 }
6e85c58d 71
0316808c
FC
72 // ------------------------------------------------------------------------
73 // Object
74 // ------------------------------------------------------------------------
75
76 /* (non-Javadoc)
77 * @see org.eclipse.linuxtools.tmf.core.trace.TmfLocation#toString()
78 */
79 @Override
80 @SuppressWarnings("nls")
81 public String toString() {
82 StringBuilder result = new StringBuilder("[TmfExperimentLocation");
d62bb185
FC
83 int index = 0;
84 ITmfLocation location = getLocationInfo().getLocation(index);
85 while (location != null) {
3bd44ac8 86 result.append("[" + location + "]");
d62bb185 87 location = getLocationInfo().getLocation(++index);
0316808c
FC
88 }
89 result.append("]");
90 return result.toString();
91 }
92
93 /* (non-Javadoc)
94 * @see org.eclipse.linuxtools.tmf.core.trace.TmfLocation#hashCode()
95 */
6e85c58d
FC
96 @Override
97 public int hashCode() {
0316808c 98 return super.hashCode();
6e85c58d
FC
99 }
100
0316808c
FC
101 /* (non-Javadoc)
102 * @see org.eclipse.linuxtools.tmf.core.trace.TmfLocation#equals(java.lang.Object)
103 */
6e85c58d
FC
104 @Override
105 public boolean equals(Object obj) {
0316808c 106 if (this == obj) {
6e85c58d 107 return true;
0316808c
FC
108 }
109 if (!super.equals(obj)) {
6e85c58d 110 return false;
0316808c
FC
111 }
112 if (getClass() != obj.getClass()) {
6e85c58d 113 return false;
0316808c 114 }
6e85c58d
FC
115 return true;
116 }
117
cb8c854e
FC
118 /* (non-Javadoc)
119 * @see org.eclipse.linuxtools.tmf.core.trace.ITmfLocation#getLocationData()
120 */
121 @Override
5976d44a 122 public TmfLocationArray getLocationInfo() {
cb8c854e
FC
123 return fLocation;
124 }
125
8c8bf09f 126}
This page took 0.06041 seconds and 5 git commands to generate.