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
1 /*******************************************************************************
2 * Copyright (c) 2009, 2010, 2012 Ericsson
3 *
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
8 *
9 * Contributors:
10 * Francois Chouinard - Initial API and implementation
11 * Francois Chouinard - Updated as per TMF Trace Model 1.0
12 *******************************************************************************/
13
14 package org.eclipse.linuxtools.internal.tmf.core.trace;
15
16 import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;
17
18
19 /**
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.
25 * <p>
26 * It is the responsibility of the user the individual trace locations are valid
27 * and that they are matched to the correct trace.
28 *
29 * @version 1.0
30 * @author Francois Chouinard
31 *
32 * @see TmfLocationArray
33 */
34 public final class TmfExperimentLocation implements ITmfLocation {
35
36 private final TmfLocationArray fLocation;
37
38 // ------------------------------------------------------------------------
39 // Constructors
40 // ------------------------------------------------------------------------
41
42 /**
43 * The standard constructor
44 *
45 * @param locations the set of trace locations
46 */
47 public TmfExperimentLocation(TmfLocationArray locations) {
48 fLocation = locations;
49 }
50
51 /**
52 * The copy constructor
53 *
54 * @param location the other experiment location
55 */
56 public TmfExperimentLocation(TmfExperimentLocation location) {
57 this(location.getLocationInfo());
58 }
59
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
67 */
68 public TmfExperimentLocation(TmfExperimentLocation exp_location, int index, ITmfLocation location) {
69 fLocation = new TmfLocationArray(exp_location.fLocation, index, location);
70 }
71
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");
83 int index = 0;
84 ITmfLocation location = getLocationInfo().getLocation(index);
85 while (location != null) {
86 result.append("[" + location + "]");
87 location = getLocationInfo().getLocation(++index);
88 }
89 result.append("]");
90 return result.toString();
91 }
92
93 /* (non-Javadoc)
94 * @see org.eclipse.linuxtools.tmf.core.trace.TmfLocation#hashCode()
95 */
96 @Override
97 public int hashCode() {
98 return super.hashCode();
99 }
100
101 /* (non-Javadoc)
102 * @see org.eclipse.linuxtools.tmf.core.trace.TmfLocation#equals(java.lang.Object)
103 */
104 @Override
105 public boolean equals(Object obj) {
106 if (this == obj) {
107 return true;
108 }
109 if (!super.equals(obj)) {
110 return false;
111 }
112 if (getClass() != obj.getClass()) {
113 return false;
114 }
115 return true;
116 }
117
118 /* (non-Javadoc)
119 * @see org.eclipse.linuxtools.tmf.core.trace.ITmfLocation#getLocationData()
120 */
121 @Override
122 public TmfLocationArray getLocationInfo() {
123 return fLocation;
124 }
125
126 }
This page took 0.033033 seconds and 5 git commands to generate.