Remove the generic location (replace by Comparable)
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.core / src / org / eclipse / linuxtools / internal / tmf / core / trace / TmfLocationArray.java
index 8720caf6c091a79209ca3f82585ca09a94d2a0e8..2ec9ef1227b8b66db5338f8c9ad764e18c6b165c 100644 (file)
@@ -1,11 +1,11 @@
 /*******************************************************************************
  * Copyright (c) 2011, 2012 Ericsson
- * 
+ *
  * All rights reserved. This program and the accompanying materials are
  * made available under the terms of the Eclipse Public License v1.0 which
  * accompanies this distribution, and is available at
  * http://www.eclipse.org/legal/epl-v10.html
- * 
+ *
  * Contributors:
  * Patrick Tasse - Initial API and implementation
  * Francois Chouinard - Put in shape for 1.0
@@ -15,10 +15,12 @@ package org.eclipse.linuxtools.internal.tmf.core.trace;
 
 import java.util.Arrays;
 
+import org.eclipse.linuxtools.tmf.core.trace.ITmfLocation;
+
 /**
  * A convenience class to store trace location arrays. The main purpose is to
  * provide a Comparable implementation for TmfExperimentLocation.
- * 
+ *
  * @version 1.0
  * @author Patrick Tasse
  */
@@ -28,7 +30,7 @@ public class TmfLocationArray implements Comparable<TmfLocationArray>, Cloneable
     // Attributes
     // ------------------------------------------------------------------------
 
-    private TmfRankedLocation[] fLocations;
+    private final ITmfLocation[] fLocations;
 
     // ------------------------------------------------------------------------
     // Constructors
@@ -36,10 +38,10 @@ public class TmfLocationArray implements Comparable<TmfLocationArray>, Cloneable
 
     /**
      * The standard constructor
-     * 
+     *
      * @param locations the locations
      */
-    public TmfLocationArray(TmfRankedLocation[] locations) {
+    public TmfLocationArray(ITmfLocation[] locations) {
         fLocations = locations;
     }
 
@@ -48,11 +50,11 @@ public class TmfLocationArray implements Comparable<TmfLocationArray>, Cloneable
     // ------------------------------------------------------------------------
 
     /**
-     * The standard constructor
-     * 
-     * @param locations the locations
+     * Get the locations inside this array
+     *
+     * @return the locations
      */
-    public TmfRankedLocation[] getLocations() {
+    public ITmfLocation[] getLocations() {
         return fLocations;
     }
 
@@ -65,9 +67,9 @@ public class TmfLocationArray implements Comparable<TmfLocationArray>, Cloneable
      */
     @Override
     public TmfLocationArray clone() {
-        TmfRankedLocation[] clones = new TmfRankedLocation[fLocations.length];
+        ITmfLocation[] clones = new ITmfLocation[fLocations.length];
         for (int i = 0; i < fLocations.length; i++) {
-            TmfRankedLocation location = fLocations[i];
+            ITmfLocation location = fLocations[i];
             clones[i] = (location != null) ? location.clone() : null;
         }
         return new TmfLocationArray(clones);
@@ -78,10 +80,11 @@ public class TmfLocationArray implements Comparable<TmfLocationArray>, Cloneable
     // ------------------------------------------------------------------------
 
     @Override
+    @SuppressWarnings({ "unchecked", "rawtypes" })
     public int compareTo(TmfLocationArray o) {
         for (int i = 0; i < fLocations.length; i++) {
-            TmfRankedLocation l1 = fLocations[i];
-            TmfRankedLocation l2 = o.fLocations[i];
+            Comparable l1 = fLocations[i].getLocationData();
+            Comparable l2 = o.fLocations[i].getLocationData();
             int result = l1.compareTo(l2);
             if (result != 0) {
                 return result;
This page took 0.026526 seconds and 5 git commands to generate.