tmf: Drop the use of TmfFixedArray for statistics
authorAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Mon, 15 Oct 2012 18:53:08 +0000 (14:53 -0400)
committerAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Mon, 22 Oct 2012 22:28:36 +0000 (18:28 -0400)
The same behaviour can be achieved by using straight [] arrays
and varargs methods. That way we don't need to instantiate new
wrapper objects all the time.

Unit tests were also updated.

Change-Id: I5f98ca2c08fd5bee5a1569c64466e63ef1e345d8
Signed-off-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
Reviewed-on: https://git.eclipse.org/r/8264
Tested-by: Hudson CI
Reviewed-by: Patrick Tasse <patrick.tasse@gmail.com>
IP-Clean: Patrick Tasse <patrick.tasse@gmail.com>
Tested-by: Patrick Tasse <patrick.tasse@gmail.com>
org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/util/AllTests.java
org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/util/TmfFixedArrayTest.java [deleted file]
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/util/TmfFixedArray.java [deleted file]
org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/statistics/TmfBaseColumnDataProviderTest.java
org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/statistics/TmfBaseColumnDataTest.java
org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/statistics/TmfBaseStatisticsDataTest.java
org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/statistics/TmfStatisticsTreeNodeTest.java
org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/statistics/TmfTreeContentProviderTest.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/model/AbsTmfStatisticsTree.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/model/TmfBaseStatisticsTree.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/model/TmfStatisticsTreeNode.java

index 25889bed4a0dffed32f14350e11bf5173a074ae9..3f49f21119fdf05361926e6e2f0355d77ea98890 100644 (file)
@@ -20,7 +20,6 @@ public class AllTests {
                TestSuite suite = new TestSuite("Test suite for " + Activator.PLUGIN_ID + ".util"); //$NON-NLS-1$);
                //$JUnit-BEGIN$
                suite.addTestSuite(PairTest.class);
-               suite.addTestSuite(TmfFixedArrayTest.class);
                //$JUnit-END$
                return suite;
        }
diff --git a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/util/TmfFixedArrayTest.java b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/util/TmfFixedArrayTest.java
deleted file mode 100755 (executable)
index 5a6961d..0000000
+++ /dev/null
@@ -1,268 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 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:
- *   Mathieu Denis <mathieu.denis@polymtl.ca> - Initial design and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests.util;
-
-import java.util.Arrays;
-
-import junit.framework.TestCase;
-
-import org.eclipse.linuxtools.tmf.core.util.TmfFixedArray;
-
-/**
- * <b><u>TmfFixedArrayTest</u></b>
- *
- * Implement me. Please.
- */
-@SuppressWarnings({ "nls", "javadoc" })
-public class TmfFixedArrayTest extends TestCase {
-
-    // ------------------------------------------------------------------------
-    // Field(s)
-    // ------------------------------------------------------------------------
-    TmfFixedArray<String> fFixedArray1 = null;
-    TmfFixedArray<String> fFixedArray2 = null;
-    String fString1, fString2, fString3, fString4, fString5;
-
-    // ------------------------------------------------------------------------
-    // Housekeeping
-    // ------------------------------------------------------------------------
-
-    public TmfFixedArrayTest() {
-        fString1 = "First String";
-        fString2 = "Second String";
-        fString3 = "Third String";
-        fString4 = "Fourth String";
-        fString5 = "Fifth String";
-        fFixedArray1 = new TmfFixedArray<String>(fString1, fString2, fString3);
-        // Empty array at the beginning
-        fFixedArray2 = new TmfFixedArray<String>();
-    }
-
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
-    }
-
-    @Override
-    protected void tearDown() throws Exception {
-        super.tearDown();
-    }
-
-    // ------------------------------------------------------------------------
-    // Get
-    // ------------------------------------------------------------------------
-
-    public void testGet() {
-        assertTrue("get", fString1.equals(fFixedArray1.get(0)));
-        assertTrue("get", fString2.equals(fFixedArray1.get(1)));
-        assertTrue("get", fString3.equals(fFixedArray1.get(2)));
-
-        try {
-            fFixedArray2.get(0);
-            fail();
-        } catch (ArrayIndexOutOfBoundsException e) {
-            // Success
-        }
-    }
-
-    public void testGetArray() {
-        String[] stringArray = fFixedArray1.getArray();
-        assertNotNull("getArray", stringArray);
-        assertTrue("getArray", fString1.equals(stringArray[0]));
-        assertTrue("getArray", fString2.equals(stringArray[1]));
-        assertTrue("getArray", fString3.equals(stringArray[2]));
-    }
-
-    // ------------------------------------------------------------------------
-    // Equals
-    // ------------------------------------------------------------------------
-
-    public void testEqualsReflexivity() {
-        assertTrue("equals", fFixedArray1.equals(fFixedArray1));
-        assertTrue("equals", fFixedArray2.equals(fFixedArray2));
-
-        assertTrue("equals", !fFixedArray1.equals(fFixedArray2));
-        assertTrue("equals", !fFixedArray2.equals(fFixedArray1));
-    }
-
-    public void testEqualsSymmetry() {
-        TmfFixedArray<String> fixedArray1 = (TmfFixedArray<String>) fFixedArray1.clone();
-        TmfFixedArray<String> fixedArray2 = (TmfFixedArray<String>) fFixedArray2.clone();
-
-        assertTrue("equals", fixedArray1.equals(fFixedArray1));
-        assertTrue("equals", fFixedArray1.equals(fixedArray1));
-
-        assertTrue("equals", fixedArray2.equals(fFixedArray2));
-        assertTrue("equals", fFixedArray2.equals(fixedArray2));
-    }
-
-    public void testEqualsTransivity() {
-        TmfFixedArray<String> fixedArray1 = (TmfFixedArray<String>) fFixedArray1.clone();
-        TmfFixedArray<String> fixedArray2 = (TmfFixedArray<String>) fFixedArray1.clone();
-        TmfFixedArray<String> fixedArray3 = (TmfFixedArray<String>) fFixedArray1.clone();
-
-        assertTrue("equals", fixedArray1.equals(fixedArray2));
-        assertTrue("equals", fixedArray2.equals(fixedArray3));
-        assertTrue("equals", fixedArray1.equals(fixedArray3));
-    }
-
-    public void testEqualsNull() {
-        assertTrue("equals", !fFixedArray1.equals(null));
-        assertTrue("equals", !fFixedArray2.equals(null));
-    }
-
-    // ------------------------------------------------------------------------
-    // Append
-    // ------------------------------------------------------------------------
-
-    public void testAppend() {
-        TmfFixedArray<String> fixedArray = new TmfFixedArray<String>();
-
-        fixedArray = fixedArray.append(fString1, fString2, fString3);
-        assertEquals("append", 3, fixedArray.size());
-        assertTrue("append", fString1.equals(fixedArray.get(0)));
-        assertTrue("append", fString2.equals(fixedArray.get(1)));
-        assertTrue("append", fString3.equals(fixedArray.get(2)));
-
-        fixedArray = fixedArray.append(fString4);
-        assertEquals("append", 4, fixedArray.size());
-        assertTrue("append", fString4.equals(fixedArray.get(3)));
-    }
-
-    @SuppressWarnings("unchecked")
-    public void testAppendFixedArray() {
-        TmfFixedArray<String> fixedArrayToAppend1 = new TmfFixedArray<String>(fString4);
-        TmfFixedArray<String> fixedArrayToAppend2 = new TmfFixedArray<String>(fString5);
-        TmfFixedArray<String> fixedArray          = new TmfFixedArray<String>();
-
-        fixedArray = fixedArray.append(fFixedArray1, fixedArrayToAppend1);
-        assertEquals("append", 4, fixedArray.size());
-        assertTrue("append", fString1.equals(fixedArray.get(0)));
-        assertTrue("append", fString2.equals(fixedArray.get(1)));
-        assertTrue("append", fString3.equals(fixedArray.get(2)));
-        assertTrue("append", fString4.equals(fixedArray.get(3)));
-
-        fixedArray = fixedArray.append(fixedArrayToAppend2);
-        assertEquals("append", 5, fixedArray.size());
-        assertTrue("append", fString5.equals(fixedArray.get(4)));
-    }
-
-    // ------------------------------------------------------------------------
-    // hashCode
-    // ------------------------------------------------------------------------
-
-    public void testHashCode() {
-        TmfFixedArray<String> fixedArray1 = (TmfFixedArray<String>) fFixedArray1.clone();
-        TmfFixedArray<String> fixedArray2 = (TmfFixedArray<String>) fFixedArray2.clone();
-
-        assertTrue("hashCode", fixedArray1.hashCode() == fFixedArray1.hashCode());
-        assertTrue("hashCode", fFixedArray2.hashCode() == fixedArray2.hashCode());
-
-        assertTrue("hashCode", fFixedArray1.hashCode() != fixedArray2.hashCode());
-        assertTrue("hashCode", fFixedArray2.hashCode() != fixedArray1.hashCode());
-    }
-
-    // ------------------------------------------------------------------------
-    // toArray
-    // ------------------------------------------------------------------------
-
-    public void testToArray() {
-        String[] expected1 = { fString1, fString2, fString3 };
-        assertTrue("toArray", Arrays.equals(expected1, fFixedArray1.toArray()));
-
-        String[] expected2 = {};
-        assertTrue("toArray", Arrays.equals(expected2, fFixedArray2.toArray()));
-    }
-
-    public void testToArrayArg() {
-        String[] stringArray = new String[3];
-        fFixedArray1.toArray(stringArray);
-        assertTrue("toArrayArg", stringArray[0].equals(fFixedArray1.get(0)));
-        assertTrue("toArrayArg", stringArray[1].equals(fFixedArray1.get(1)));
-        assertTrue("toArrayArg", stringArray[2].equals(fFixedArray1.get(2)));
-
-        String[] stringBigArray = new String[10];
-        fFixedArray1.toArray(stringBigArray);
-        assertNull("toArrayArg", stringBigArray[3]);
-
-        TmfFixedArray<Object> fFixedArrayObject = new TmfFixedArray<Object>(fString1);
-        stringArray = fFixedArrayObject.toArray(new String[0]);
-        assertTrue("toArrayArg", stringArray[0].equals(fString1));
-    }
-
-    // ------------------------------------------------------------------------
-    // Size
-    // ------------------------------------------------------------------------
-
-    public void testSize() {
-        assertEquals("toArray", 3, fFixedArray1.size());
-
-        assertEquals("toArray", 0, fFixedArray2.size());
-    }
-
-    // ------------------------------------------------------------------------
-    // SubArray
-    // ------------------------------------------------------------------------
-
-    public void testSubArray() {
-        TmfFixedArray<String> subArray = fFixedArray1.subArray(1);
-
-        assertEquals("SubArray", 2, subArray.size());
-        assertTrue("SubArray", fString2.equals(subArray.get(0)));
-        assertTrue("SubArray", fString3.equals(subArray.get(1)));
-    }
-
-    public void testSubArray2() {
-        TmfFixedArray<String> subArray = fFixedArray1.subArray(1, 2);
-
-        assertEquals("SubArray", 2, subArray.size());
-        assertTrue("SubArray", fString2.equals(subArray.get(0)));
-        assertTrue("SubArray", fString3.equals(subArray.get(1)));
-    }
-
-    // ------------------------------------------------------------------------
-    // Set
-    // ------------------------------------------------------------------------
-
-    public void testSet() {
-        String[] newString = {"new FirstString", "new SecondString", "new ThirdString"};
-
-        fFixedArray1.set(0, newString[0]);
-        assertTrue("getArray", newString[0].equals(newString[0]));
-
-        fFixedArray1.set(1, newString[1]);
-        assertTrue("getArray", newString[1].equals(newString[1]));
-
-        fFixedArray1.set(2, newString[2]);
-        assertTrue("getArray", newString[2].equals(newString[2]));
-
-        try {
-            fFixedArray2.set(0, "newString");
-            fail();
-        } catch (Exception e) {
-            // Success
-        }
-    }
-
-    // ------------------------------------------------------------------------
-    // toString
-    // ------------------------------------------------------------------------
-
-    public void testToString() {
-        String expected1 = Arrays.asList(fString1, fString2, fString3).toString();
-        assertEquals("toString", expected1, fFixedArray1.toString());
-
-        String expected2 = Arrays.asList().toString();
-        assertEquals("toString", expected2, fFixedArray2.toString());
-    }
-}
diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/util/TmfFixedArray.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/util/TmfFixedArray.java
deleted file mode 100755 (executable)
index 1144ba8..0000000
+++ /dev/null
@@ -1,319 +0,0 @@
-/*******************************************************************************
- * 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:
- *   Francois Godin <copelnug@gmail.com> - Initial design and implementation
- *   Mathieu Denis <mathieu.denis@polymtl.ca> - Correction and refactoring
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.util;
-
-import java.lang.reflect.Array;
-import java.util.AbstractList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.RandomAccess;
-
-/**
- * Allow to create a List object that contain an already existing array. Works
- * like {@link java.util.Arrays#asList} but contains more functions :
- * <ul>
- * <li>{@link #hashCode()}</li>
- * <li>{@link #equals(Object)}</li>
- * </ul>
- * Those functions allow to use the FixedArray as the key of a
- * {@link java.util.HashMap}.
- *
- * @version 1.0
- * @author Francois Godin
- *
- * @param <T>
- *            Type of the array content.
- */
-public final class TmfFixedArray<T> extends AbstractList<T> implements RandomAccess, Cloneable {
-    /**
-     * Replace {@link java.util.Arrays#copyOf(Object[], int)} that do not exist
-     * in java 5.
-     *
-     * @param <E>
-     *            Content of the array.
-     * @param array
-     *            Original array to copy from.
-     * @param newLength
-     *            Length of the copy to be returned.
-     * @return A new array consisting of the elements specified.
-     */
-    private static <E> E[] copyOf(final E[] array, int newLength) {
-        // FIXME Is it useful to use newInstance?
-        E[] result = (E[]) Array.newInstance(array.getClass().getComponentType(), newLength);
-        System.arraycopy(array, 0, result, 0, Math.min(array.length, newLength));
-        return result;
-    }
-
-    /**
-     * Replace {@link java.util.Arrays#copyOf(Object[], int, Class)} that do not
-     * exist in java 5.
-     *
-     * @param <E>
-     *            Content of the array.
-     * @param array
-     *            Original array to copy from.
-     * @param newLength
-     *            Length of the copy to be returned.
-     * @param newType
-     *            Type of the array to be returned.
-     * @return A new array consisting of the elements specified.
-     */
-    private static <E, U> E[] copyOf(final U[] array, int newLength, Class<? extends E[]> newType) {
-        E[] result = (E[])Array.newInstance(newType.getComponentType(), newLength);
-        System.arraycopy(array, 0, result, 0, Math.min(array.length, newLength));
-        return result;
-    }
-
-    /**
-     * Replace {@link java.util.Arrays#copyOfRange(Object[], int, int)} that do
-     * not exist in java 5.
-     *
-     * @param <E>
-     *            Content of the array.
-     * @param array
-     *            Original array to copy from.
-     * @param start
-     *            Starting position of the range, inclusive.
-     * @param end
-     *            Ending position of the range, exclusive.
-     * @return A new array consisting of the elements specified. The length of
-     *         the new array is equal to end-start
-     */
-    private static <E> E[] copyOfRange(final E[] array, int start, int end) {
-        E[] result = (E[])Array.newInstance(array.getClass().getComponentType(), end - start);
-        System.arraycopy(array, start, result, 0, end - start);
-        return result;
-    }
-
-    /**
-     * The array.
-     */
-    private final T[] fArray;
-
-    /**
-     * Constructor.
-     *
-     * @param array
-     *            Array to use. WILL NOT BE COPIED.
-     */
-    public TmfFixedArray(final T... array) {
-        fArray = array;
-    }
-
-    /**
-     * Append a FixedArray to this FixedArray.
-     *
-     * @param value
-     *            The FixedArray to append.
-     * @return A new FixedArray with the elements of the two FixedArray.
-     */
-    public TmfFixedArray<T> append(final TmfFixedArray<T> value) {
-        TmfFixedArray<T> result = new TmfFixedArray<T>(copyOf(fArray, fArray.length + value.size()));
-        System.arraycopy(value.fArray, 0, result.fArray, fArray.length, value.fArray.length);
-        return result;
-    }
-
-    /**
-     * Append in order many FixedArray to this FixedArray.
-     *
-     * @param values
-     *            The FixedArrays to append.
-     * @return A new FixedArray with the element of all the FixedArray.
-     */
-    public TmfFixedArray<T> append(final TmfFixedArray<T>... values) {
-        int newLength = 0;
-        for (TmfFixedArray<T> value : values) {
-            newLength += value.size();
-        }
-                TmfFixedArray<T> result = new TmfFixedArray<T>(copyOf(fArray, fArray.length + newLength));
-        newLength = fArray.length;
-        for (TmfFixedArray<T> value : values) {
-            System.arraycopy(value.fArray, 0, result.fArray, newLength, value.fArray.length);
-            newLength += value.fArray.length;
-        }
-        return result;
-    }
-
-    /**
-     * Append an element to the array.
-     *
-     * @param value
-     *            Element to append.
-     * @return A new FixedArray with the element appended.
-     */
-    public TmfFixedArray<T> append(final T value) {
-        TmfFixedArray<T> result = new TmfFixedArray<T>(copyOf(fArray, fArray.length + 1));
-        result.set(fArray.length, value);
-        return result;
-    }
-
-    /**
-     * Append an array of element to the array.
-     *
-     * @param values
-     *            Elements array to append.
-     * @return A new FixedArray with the elements appended.
-     */
-    public TmfFixedArray<T> append(final T... values) {
-        TmfFixedArray<T> result = new TmfFixedArray<T>(copyOf(fArray, fArray.length + values.length));
-        for (int i = 0; i < values.length; ++i) {
-            result.set(fArray.length + i, values[i]);
-        }
-        return result;
-    }
-
-    /*
-     * (non-Javadoc)
-     *
-     * @see java.lang.Object#clone()
-     */
-    @Override
-    public Object clone() {
-        return new TmfFixedArray<T>(copyOf(fArray, fArray.length));
-    }
-
-    /*
-     * (non-Javadoc)
-     *
-     * @see java.util.AbstractList#equals(java.lang.Object)
-     */
-    @Override
-    public boolean equals(Object o) {
-        if (o instanceof TmfFixedArray<?>) {
-            return Arrays.equals(fArray, ((TmfFixedArray<?>) o).fArray);
-        }
-        if (!(o instanceof List)) {
-            return false;
-        }
-        for (int i = 0; i < fArray.length; ++i) {
-            if (!fArray[i].equals(o)) {
-                return false;
-            }
-        }
-        return true;
-    }
-
-    /*
-     * (non-Javadoc)
-     *
-     * @see java.util.AbstractList#get(int)
-     */
-    @Override
-    public T get(int index) {
-        return fArray[index];
-    }
-
-    /**
-     * Get the array reference.
-     *
-     * @return The array reference.
-     * @see #toArray FixedArray.toArray() to get a copy of the array.
-     */
-    public T[] getArray() {
-        return fArray;
-    }
-
-    /*
-     * (non-Javadoc)
-     *
-     * @see java.util.AbstractList#hashCode()
-     */
-    @Override
-    public int hashCode() {
-        return Arrays.hashCode(fArray);
-    }
-
-    /*
-     * (non-Javadoc)
-     *
-     * @see java.util.AbstractList#set(int, java.lang.Object)
-     */
-    @Override
-    public T set(int index, T element) {
-        T temp = fArray[index];
-        fArray[index] = element;
-        return temp;
-    }
-
-    /*
-     * (non-Javadoc)
-     *
-     * @see java.util.AbstractCollection#size()
-     */
-    @Override
-    public int size() {
-        return fArray.length;
-    }
-
-    /**
-     * Get a array covering only a part of the array.
-     *
-     * @param start
-     *            Starting position of the new array.
-     * @return A new array covering the elements specified.
-     */
-    public TmfFixedArray<T> subArray(int start) {
-        return new TmfFixedArray<T>(copyOfRange(fArray, start, fArray.length));
-    }
-
-    /**
-     * Get a array covering only a part of the array.
-     *
-     * @param start
-     *            Starting position of the new array.
-     * @param length
-     *            Number of element to include in the new array.
-     * @return A new array covering the elements specified.
-     */
-    public TmfFixedArray<T> subArray(int start, int length) {
-        return new TmfFixedArray<T>(copyOfRange(fArray, start, length + start));
-    }
-
-    /*
-     * (non-Javadoc)
-     *
-     * @see java.util.AbstractCollection#toArray()
-     */
-    @Override
-    public T[] toArray() {
-        return copyOf(fArray, fArray.length);
-    }
-
-    /*
-     * (non-Javadoc)
-     *
-     * @see java.util.AbstractCollection#toArray(T[])
-     */
-    @Override
-    public <E> E[] toArray(E[] array) {
-        if (array.length < fArray.length) {
-            return copyOf(fArray, fArray.length, (Class<? extends E[]>) array.getClass());
-        }
-        System.arraycopy(fArray, 0, array, 0, fArray.length);
-        if (array.length > fArray.length) {
-            array[fArray.length] = null;
-        }
-        return array;
-    }
-
-    /*
-     * (non-Javadoc)
-     *
-     * @see java.util.AbstractCollection#toString()
-     */
-    @Override
-    public String toString() {
-        return Arrays.toString(fArray);
-    }
-}
index bf51b9a8fb671ac600e153c902ac85cb0a55e23a..aafe246f24159f084857e70c9c1644fc4ea1a3d2 100644 (file)
@@ -23,7 +23,6 @@ import org.eclipse.linuxtools.tmf.core.event.TmfEvent;
 import org.eclipse.linuxtools.tmf.core.event.TmfEventField;
 import org.eclipse.linuxtools.tmf.core.event.TmfEventType;
 import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
-import org.eclipse.linuxtools.tmf.core.util.TmfFixedArray;
 import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.Messages;
 import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.TmfBaseColumnData;
 import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.TmfBaseColumnData.ITmfColumnPercentageProvider;
@@ -103,7 +102,7 @@ public class TmfBaseColumnDataProviderTest extends TestCase {
 
         fStatsData = new TmfBaseStatisticsTree();
 
-        fStatsData.getOrCreate(new TmfFixedArray<String>(fTestName, Messages.TmfStatisticsData_EventTypes));
+        fStatsData.getOrCreate(fTestName, Messages.TmfStatisticsData_EventTypes);
 
         fStatsData.setTotal(fTestName, true, 3);
         fStatsData.setTypeCount(fTestName, fEvent1.getType().getName(), true, 1);
@@ -124,9 +123,9 @@ public class TmfBaseColumnDataProviderTest extends TestCase {
         assertNotNull("getColumnData", columnsData);
         assertEquals("getColumnData", 3, columnsData.size());
 
-        TmfStatisticsTreeNode parentNode = fStatsData.get(new TmfFixedArray<String>(fTestName));
-        TmfStatisticsTreeNode treeNode1  = fStatsData.get(new TmfFixedArray<String>(fTestName, Messages.TmfStatisticsData_EventTypes, fEvent1.getType().getName()));
-        TmfStatisticsTreeNode treeNode2  = fStatsData.get(new TmfFixedArray<String>(fTestName, Messages.TmfStatisticsData_EventTypes, fEvent3.getType().getName()));
+        TmfStatisticsTreeNode parentNode = fStatsData.get(fTestName);
+        TmfStatisticsTreeNode treeNode1  = fStatsData.get(fTestName, Messages.TmfStatisticsData_EventTypes, fEvent1.getType().getName());
+        TmfStatisticsTreeNode treeNode2  = fStatsData.get(fTestName, Messages.TmfStatisticsData_EventTypes, fEvent3.getType().getName());
         ViewerComparator vComp = null;
         for (TmfBaseColumnData columnData : columnsData) {
             assertNotNull("getColumnData", columnData);
index c253face7a210e33873249e6ce25c26a6e750b05..c154ecde9bbf963f1f02da79b66f6425a4a4fbcb 100755 (executable)
@@ -17,7 +17,6 @@ import junit.framework.TestCase;
 import org.eclipse.jface.viewers.ColumnLabelProvider;
 import org.eclipse.jface.viewers.Viewer;
 import org.eclipse.jface.viewers.ViewerComparator;
-import org.eclipse.linuxtools.tmf.core.util.TmfFixedArray;
 import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.TmfBaseColumnData;
 import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.TmfBaseColumnData.ITmfColumnPercentageProvider;
 import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.TmfBaseStatisticsTree;
@@ -94,7 +93,7 @@ public class TmfBaseColumnDataTest extends TestCase {
 
         TmfBaseStatisticsTree baseData = new TmfBaseStatisticsTree();
         fTraceName = "trace1";
-        fTreeNode = new TmfStatisticsTreeNode(new TmfFixedArray<String>(fTraceName), baseData);
+        fTreeNode = new TmfStatisticsTreeNode(baseData, fTraceName);
 
         fBaseColumnData = new TmfBaseColumnData(fHeader, fWidth, fAlignment, fToolTip, fLabelProvider, fComparator, fPercentageProvider);
     }
index ef2c5b578a39d06a6a2cfc2b2c340887c5390831..a25c70c0ca7eb11f2a6a738c3c3e974f833487ab 100755 (executable)
@@ -24,7 +24,6 @@ import org.eclipse.linuxtools.tmf.core.event.TmfEvent;
 import org.eclipse.linuxtools.tmf.core.event.TmfEventField;
 import org.eclipse.linuxtools.tmf.core.event.TmfEventType;
 import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
-import org.eclipse.linuxtools.tmf.core.util.TmfFixedArray;
 import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.AbsTmfStatisticsTree;
 import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.Messages;
 import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.TmfBaseStatisticsTree;
@@ -117,7 +116,7 @@ public class TmfBaseStatisticsDataTest extends TestCase {
         assertEquals("getChildren", fTestName, treeNode.getKey());
 
         // Getting children of the trace
-        childrenTreeNode = fStatsData.getChildren(new TmfFixedArray<String>(fTestName));
+        childrenTreeNode = fStatsData.getChildren(fTestName);
         assertEquals("getChildren", 1, childrenTreeNode.size());
         treeNode = childrenTreeNode.iterator().next();
         assertEquals("getChildren", Messages.TmfStatisticsData_EventTypes, treeNode.getKey());
@@ -161,7 +160,7 @@ public class TmfBaseStatisticsDataTest extends TestCase {
         assertEquals("getChildren", fTestName, treeNode.getKey());
 
         // Getting children of the trace
-        childrenTreeNode = fStatsData.getAllChildren(new TmfFixedArray<String>(fTestName));
+        childrenTreeNode = fStatsData.getAllChildren(fTestName);
         assertEquals("getChildren", 1, childrenTreeNode.size());
         treeNode = childrenTreeNode.iterator().next();
         assertEquals("getChildren", Messages.TmfStatisticsData_EventTypes, treeNode.getKey());
@@ -173,7 +172,7 @@ public class TmfBaseStatisticsDataTest extends TestCase {
          * It should return the eventType even though the number of events
          * equals 0
          */
-        fStatsData.get(new TmfFixedArray<String>(fTestName, Messages.TmfStatisticsData_EventTypes, fEvent1.getType().getName())).reset();
+        fStatsData.get(fTestName, Messages.TmfStatisticsData_EventTypes, fEvent1.getType().getName()).reset();
         // Getting children of a category
         childrenTreeNode = fStatsData.get(treeNode.getPath()).getAllChildren();
         assertEquals("getChildren", 2, childrenTreeNode.size());
@@ -203,10 +202,10 @@ public class TmfBaseStatisticsDataTest extends TestCase {
      * Test registering of events.
      */
     public void testRegisterEvent() {
-        TmfStatisticsTreeNode trace = fStatsData.get(new TmfFixedArray<String>(fTestName));
+        TmfStatisticsTreeNode trace = fStatsData.get(fTestName);
         assertEquals("registerEvent", 3, trace.getValues().getTotal());
 
-        Collection<TmfStatisticsTreeNode> childrenTreeNode = fStatsData.getChildren(new TmfFixedArray<String>(fTestName, Messages.TmfStatisticsData_EventTypes));
+        Collection<TmfStatisticsTreeNode> childrenTreeNode = fStatsData.getChildren(fTestName, Messages.TmfStatisticsData_EventTypes);
         for (TmfStatisticsTreeNode child : childrenTreeNode) {
             if (child.getKey().compareTo(fEvent1.getType().getName()) == 0) {
                 assertEquals("registerEvent", 1, child.getValues().getTotal());
@@ -224,9 +223,9 @@ public class TmfBaseStatisticsDataTest extends TestCase {
      * Test getter.
      */
     public void testGet() {
-        TmfStatisticsTreeNode traceRoot = fStatsData.get(new TmfFixedArray<String>(fTestName));
+        TmfStatisticsTreeNode traceRoot = fStatsData.get(fTestName);
         assertNotNull("get", traceRoot);
-        assertEquals("get", 0, traceRoot.getPath().toString().compareTo("[" + fTestName + "]"));
+        assertEquals("get", 0, traceRoot.getPath()[0].compareTo(fTestName));
         assertEquals("get", 3, traceRoot.getValues().getTotal());
         assertEquals("get", 1, traceRoot.getNbChildren());
     }
@@ -239,7 +238,7 @@ public class TmfBaseStatisticsDataTest extends TestCase {
      * Test getting or creating of node entries.
      */
     public void testGetOrCreate() {
-        TmfFixedArray<String> newEventType = new TmfFixedArray<String>(fTestName, Messages.TmfStatisticsData_EventTypes, "Fancy Type");
+        String[] newEventType = new String[] { fTestName, Messages.TmfStatisticsData_EventTypes, "Fancy Type" };
         TmfStatisticsTreeNode newEventTypeNode;
 
         // newEventType is not in the tree
@@ -271,22 +270,22 @@ public class TmfBaseStatisticsDataTest extends TestCase {
         TmfStatisticsTreeNode parentNode = fStatsData.getParent(AbsTmfStatisticsTree.ROOT);
         assertNull("getParent", parentNode);
 
-        parentNode = fStatsData.getParent(new TmfFixedArray<String>("TreeRootNode that should not exist"));
+        parentNode = fStatsData.getParent("TreeRootNode that should not exist");
         assertNotNull("getParent", parentNode);
         assertEquals("getParent", 0, parentNode.getKey().compareTo(fStatsData.get(AbsTmfStatisticsTree.ROOT).getKey().toString()));
 
-        parentNode = fStatsData.getParent(new TmfFixedArray<String>("TreeNode", Messages.TmfStatisticsData_EventTypes, "TreeNode that should not exist"));
+        parentNode = fStatsData.getParent("TreeNode", Messages.TmfStatisticsData_EventTypes, "TreeNode that should not exist");
         assertNull("getParent", parentNode);
-        parentNode = fStatsData.getParent(new TmfFixedArray<String>(fTestName, Messages.TmfStatisticsData_EventTypes, fEvent1.getType().getName()));
+        parentNode = fStatsData.getParent(fTestName, Messages.TmfStatisticsData_EventTypes, fEvent1.getType().getName());
         assertNull("getParent", parentNode);
 
-        parentNode = fStatsData.getParent(new TmfFixedArray<String>(fTestName));
+        parentNode = fStatsData.getParent(fTestName);
         assertNotNull("getParent", parentNode);
         assertEquals("getParent", 0, parentNode.getPath().toString().compareTo(AbsTmfStatisticsTree.ROOT.toString()));
 
-        parentNode = fStatsData.getParent(new TmfFixedArray<String>(fTestName, Messages.TmfStatisticsData_EventTypes));
+        parentNode = fStatsData.getParent(fTestName, Messages.TmfStatisticsData_EventTypes);
         assertNotNull("getParent", parentNode);
-        assertEquals("getParent", 0, parentNode.getPath().toString().compareTo(fStatsData.get(new TmfFixedArray<String>(fTestName)).getPath().toString()));
+        assertEquals("getParent", 0, parentNode.getPath().toString().compareTo(fStatsData.get(fTestName).getPath().toString()));
     }
 
     // ------------------------------------------------------------------------
@@ -297,15 +296,15 @@ public class TmfBaseStatisticsDataTest extends TestCase {
      * Test reset method
      */
     public void testReset() {
-        fStatsData.reset(new TmfFixedArray<String>(fTestName, Messages.TmfStatisticsData_EventTypes));
+        fStatsData.reset(fTestName, Messages.TmfStatisticsData_EventTypes);
 
-        assertEquals("reset", 0, fStatsData.getChildren(new TmfFixedArray<String>(fTestName, Messages.TmfStatisticsData_EventTypes)).size());
-        assertNull("reset", fStatsData.get(new TmfFixedArray<String>(fTestName, Messages.TmfStatisticsData_EventTypes, fType1.getName())));
-        assertNull("reset", fStatsData.get(new TmfFixedArray<String>(fTestName, Messages.TmfStatisticsData_EventTypes, fType3.getName())));
+        assertEquals("reset", 0, fStatsData.getChildren(fTestName, Messages.TmfStatisticsData_EventTypes).size());
+        assertNull("reset", fStatsData.get(fTestName, Messages.TmfStatisticsData_EventTypes, fType1.getName()));
+        assertNull("reset", fStatsData.get(fTestName, Messages.TmfStatisticsData_EventTypes, fType3.getName()));
 
-        fStatsData.reset(new TmfFixedArray<String>(fTestName));
+        fStatsData.reset(fTestName);
 
-        // A rootz should always have at least one child that is eventType
-        assertEquals("reset", 1, fStatsData.getChildren(new TmfFixedArray<String>(fTestName)).size());
+        // A root should always have at least one child that is eventType
+        assertEquals("reset", 1, fStatsData.getChildren(fTestName).size());
     }
 }
index f9593f40dcc3edcb0fef7b3b47e551e111d59fc6..aaeeebbde1d555dc1d1ac0a18e080e78c11eee9e 100755 (executable)
@@ -24,7 +24,6 @@ import org.eclipse.linuxtools.tmf.core.event.TmfEvent;
 import org.eclipse.linuxtools.tmf.core.event.TmfEventField;
 import org.eclipse.linuxtools.tmf.core.event.TmfEventType;
 import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
-import org.eclipse.linuxtools.tmf.core.util.TmfFixedArray;
 import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.AbsTmfStatisticsTree;
 import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.Messages;
 import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.TmfBaseStatisticsTree;
@@ -117,7 +116,7 @@ public class TmfStatisticsTreeNodeTest extends TestCase {
      */
     public void testContainsChild() {
         TmfStatisticsTreeNode rootNode  = fStatsData.get(AbsTmfStatisticsTree.ROOT);
-        TmfStatisticsTreeNode traceNode = fStatsData.get(new TmfFixedArray<String>(fTestName));
+        TmfStatisticsTreeNode traceNode = fStatsData.get(fTestName);
         // Creates a category from the key already created
         TmfStatisticsTreeNode catNode = traceNode.getChildren().iterator().next();
 
@@ -143,13 +142,13 @@ public class TmfStatisticsTreeNodeTest extends TestCase {
      */
     public void testGetChildren() {
         // Getting children of the ROOT
-        Collection<TmfStatisticsTreeNode> childrenTreeNode = fStatsData.get(AbsTmfStatisticsTree.ROOT).getChildren();
+        Collection<TmfStatisticsTreeNode> childrenTreeNode = fStatsData.get(AbsTmfStatisticsTree.ROOT[0]).getChildren();
         assertEquals("getChildren", 1, childrenTreeNode.size());
         TmfStatisticsTreeNode treeNode = childrenTreeNode.iterator().next();
         assertEquals("getChildren", fTestName, treeNode.getKey());
 
         // Getting children of the trace
-        childrenTreeNode = fStatsData.get(new TmfFixedArray<String>(fTestName)).getChildren();
+        childrenTreeNode = fStatsData.get(fTestName).getChildren();
         assertEquals("getChildren", 1, childrenTreeNode.size());
         treeNode = childrenTreeNode.iterator().next();
         assertEquals("getChildren", Messages.TmfStatisticsData_EventTypes, treeNode.getKey());
@@ -192,7 +191,7 @@ public class TmfStatisticsTreeNodeTest extends TestCase {
         assertEquals("getChildren", fTestName, treeNode.getKey());
 
         // Getting children of the trace
-        childrenTreeNode = fStatsData.get(new TmfFixedArray<String>(fTestName)).getAllChildren();
+        childrenTreeNode = fStatsData.get(fTestName).getAllChildren();
         assertEquals("getChildren", 1, childrenTreeNode.size());
         treeNode = childrenTreeNode.iterator().next();
         assertEquals("getChildren", Messages.TmfStatisticsData_EventTypes, treeNode.getKey());
@@ -204,7 +203,7 @@ public class TmfStatisticsTreeNodeTest extends TestCase {
          * It should return the eventType even though the number of events
          * equals 0
          */
-        fStatsData.get(new TmfFixedArray<String>(fTestName, Messages.TmfStatisticsData_EventTypes, fType1.getName())).reset();
+        fStatsData.get(fTestName, Messages.TmfStatisticsData_EventTypes, fType1.getName()).reset();
         // Getting children of a category
         childrenTreeNode = treeNode.getAllChildren();
         assertEquals("getChildren", 2, childrenTreeNode.size());
@@ -234,9 +233,9 @@ public class TmfStatisticsTreeNodeTest extends TestCase {
      */
     public void testGetNbChildren() {
         TmfStatisticsTreeNode rootNode    = fStatsData.get(AbsTmfStatisticsTree.ROOT);
-        TmfStatisticsTreeNode traceNode   = fStatsData.get(new TmfFixedArray<String>(fTestName));
+        TmfStatisticsTreeNode traceNode   = fStatsData.get(fTestName);
         TmfStatisticsTreeNode catNode     = traceNode.getChildren().iterator().next();
-        TmfStatisticsTreeNode elementNode = fStatsData.get(new TmfFixedArray<String>(fTestName, Messages.TmfStatisticsData_EventTypes, fType1.getName()));
+        TmfStatisticsTreeNode elementNode = fStatsData.get(fTestName, Messages.TmfStatisticsData_EventTypes, fType1.getName());
 
         assertEquals("getNbChildren", 1, rootNode.getNbChildren());
         assertEquals("getNbChildren", 1, traceNode.getNbChildren());
@@ -253,9 +252,9 @@ public class TmfStatisticsTreeNodeTest extends TestCase {
      */
     public void testHasChildren() {
         TmfStatisticsTreeNode rootNode    = fStatsData.get(AbsTmfStatisticsTree.ROOT);
-        TmfStatisticsTreeNode traceNode   = fStatsData.get(new TmfFixedArray<String>(fTestName));
+        TmfStatisticsTreeNode traceNode   = fStatsData.get(fTestName);
         TmfStatisticsTreeNode catNode     = traceNode.getChildren().iterator().next();
-        TmfStatisticsTreeNode elementNode = fStatsData.get(new TmfFixedArray<String>(fTestName, Messages.TmfStatisticsData_EventTypes, fType1.getName()));
+        TmfStatisticsTreeNode elementNode = fStatsData.get(fTestName, Messages.TmfStatisticsData_EventTypes, fType1.getName());
 
         assertTrue("hasChildren", rootNode.hasChildren());
         assertTrue("hasChildren", traceNode.hasChildren());
@@ -275,32 +274,32 @@ public class TmfStatisticsTreeNodeTest extends TestCase {
         TmfStatisticsTreeNode parentNode = rootNode.getParent();
         assertNull("getParent", parentNode);
 
-        TmfStatisticsTreeNode newTraceNode = new TmfStatisticsTreeNode(new TmfFixedArray<String>("newly created trace node"), fStatsData);
+        TmfStatisticsTreeNode newTraceNode = new TmfStatisticsTreeNode(fStatsData, "newly created trace node");
         parentNode = newTraceNode.getParent();
         assertNotNull("getParent", parentNode);
         assertEquals("getParent", 0, parentNode.getKey().compareTo(fStatsData.get(AbsTmfStatisticsTree.ROOT).getKey().toString()));
 
-        TmfStatisticsTreeNode traceNode = fStatsData.get(new TmfFixedArray<String>(fTestName));
+        TmfStatisticsTreeNode traceNode = fStatsData.get(fTestName);
         parentNode = traceNode.getParent();
         assertNotNull("getParent", parentNode);
         assertEquals("getParent", 0, parentNode.getPath().toString().compareTo(AbsTmfStatisticsTree.ROOT.toString()));
 
-        TmfStatisticsTreeNode newNode = new TmfStatisticsTreeNode(new TmfFixedArray<String>("TreeNode", Messages.TmfStatisticsData_EventTypes, "TreeNode that should not exist"), fStatsData);
+        TmfStatisticsTreeNode newNode = new TmfStatisticsTreeNode(fStatsData, "TreeNode", Messages.TmfStatisticsData_EventTypes, "TreeNode that should not exist");
         parentNode = newNode.getParent();
         assertNull("getParent", parentNode);
 
-        TmfStatisticsTreeNode elementNode = fStatsData.get(new TmfFixedArray<String>(fTestName, Messages.TmfStatisticsData_EventTypes, fType1.getName()));
+        TmfStatisticsTreeNode elementNode = fStatsData.get(fTestName, Messages.TmfStatisticsData_EventTypes, fType1.getName());
         parentNode = elementNode.getParent();
         assertNull("getParent", parentNode);
 
         TmfStatisticsTreeNode catNode = traceNode.getChildren().iterator().next();
         parentNode = catNode.getParent();
         assertNotNull("getParent", parentNode);
-        assertEquals("getParent", 0, parentNode.getPath().toString().compareTo(fStatsData.get(new TmfFixedArray<String>(fTestName)).getPath().toString()));
+        assertEquals("getParent", 0, parentNode.getPath().toString().compareTo(fStatsData.get(fTestName).getPath().toString()));
 
         parentNode = elementNode.getParent();
         assertNotNull("getParent", parentNode);
-        assertTrue("getParent", parentNode.getPath().equals(new TmfFixedArray<String>(fTestName, Messages.TmfStatisticsData_EventTypes)));
+        assertTrue(arraysEqual(parentNode.getPath(), fTestName, Messages.TmfStatisticsData_EventTypes));
     }
 
     // ------------------------------------------------------------------------
@@ -312,11 +311,11 @@ public class TmfStatisticsTreeNodeTest extends TestCase {
      */
     public void testGetKey() {
         TmfStatisticsTreeNode rootNode    = fStatsData.get(AbsTmfStatisticsTree.ROOT);
-        TmfStatisticsTreeNode traceNode   = fStatsData.get(new TmfFixedArray<String>(fTestName));
+        TmfStatisticsTreeNode traceNode   = fStatsData.get(fTestName);
         TmfStatisticsTreeNode catNode     = traceNode.getChildren().iterator().next();
-        TmfStatisticsTreeNode elementNode = fStatsData.get(new TmfFixedArray<String>(fTestName, Messages.TmfStatisticsData_EventTypes, fType1.getName()));
+        TmfStatisticsTreeNode elementNode = fStatsData.get(fTestName, Messages.TmfStatisticsData_EventTypes, fType1.getName());
 
-        assertEquals("getKey", 0, rootNode.getKey().compareTo(AbsTmfStatisticsTree.ROOT.get(0)));
+        assertEquals("getKey", 0, rootNode.getKey().compareTo(AbsTmfStatisticsTree.ROOT[0]));
         assertEquals("getKey", 0, traceNode.getKey().compareTo(fTestName));
         assertEquals("getKey", 0, catNode.getKey().compareTo(Messages.TmfStatisticsData_EventTypes));
         assertEquals("getKey", 0, elementNode.getKey().compareTo(fType1.getName()));
@@ -331,14 +330,16 @@ public class TmfStatisticsTreeNodeTest extends TestCase {
      */
     public void testGetPath() {
         TmfStatisticsTreeNode rootNode    = fStatsData.get(AbsTmfStatisticsTree.ROOT);
-        TmfStatisticsTreeNode traceNode   = fStatsData.get(new TmfFixedArray<String>(fTestName));
+        TmfStatisticsTreeNode traceNode   = fStatsData.get(fTestName);
         TmfStatisticsTreeNode catNode     = traceNode.getChildren().iterator().next();
-        TmfStatisticsTreeNode elementNode = fStatsData.get(new TmfFixedArray<String>(fTestName, Messages.TmfStatisticsData_EventTypes, fType1.getName()));
-
-        assertTrue("getPath", rootNode.getPath().equals(AbsTmfStatisticsTree.ROOT));
-        assertTrue("getPath", traceNode.getPath().equals(new TmfFixedArray<String>(fTestName)));
-        assertTrue("getPath", catNode.getPath().equals(new TmfFixedArray<String>(fTestName, Messages.TmfStatisticsData_EventTypes)));
-        assertTrue("getPath", elementNode.getPath().equals(new TmfFixedArray<String>(fTestName, Messages.TmfStatisticsData_EventTypes, fType1.getName())));
+        TmfStatisticsTreeNode elementNode = fStatsData.get(fTestName, Messages.TmfStatisticsData_EventTypes, fType1.getName());
+
+        assertTrue("getPath", arraysEqual(rootNode.getPath(), AbsTmfStatisticsTree.ROOT));
+        assertTrue("getPath", arraysEqual(traceNode.getPath(), fTestName));
+        assertTrue("getPath", arraysEqual(catNode.getPath(),
+                fTestName, Messages.TmfStatisticsData_EventTypes));
+        assertTrue("getPath", arraysEqual(elementNode.getPath(),
+                fTestName, Messages.TmfStatisticsData_EventTypes, fType1.getName()));
     }
 
     // ------------------------------------------------------------------------
@@ -350,10 +351,10 @@ public class TmfStatisticsTreeNodeTest extends TestCase {
      */
     public void testGetValue() {
         TmfStatisticsTreeNode rootNode     = fStatsData.get(AbsTmfStatisticsTree.ROOT);
-        TmfStatisticsTreeNode traceNode    = fStatsData.get(new TmfFixedArray<String>(fTestName));
+        TmfStatisticsTreeNode traceNode    = fStatsData.get(fTestName);
         TmfStatisticsTreeNode catNode      = traceNode.getChildren().iterator().next();
-        TmfStatisticsTreeNode elementNode1 = fStatsData.get(new TmfFixedArray<String>(fTestName, Messages.TmfStatisticsData_EventTypes, fType1.getName()));
-        TmfStatisticsTreeNode elementNode3 = fStatsData.get(new TmfFixedArray<String>(fTestName, Messages.TmfStatisticsData_EventTypes, fType2.getName()));
+        TmfStatisticsTreeNode elementNode1 = fStatsData.get(fTestName, Messages.TmfStatisticsData_EventTypes, fType1.getName());
+        TmfStatisticsTreeNode elementNode3 = fStatsData.get(fTestName, Messages.TmfStatisticsData_EventTypes, fType2.getName());
 
         assertEquals("getValue", 0, rootNode.getValues().getTotal());
         assertEquals("getValue", 9, traceNode.getValues().getTotal());
@@ -377,9 +378,9 @@ public class TmfStatisticsTreeNodeTest extends TestCase {
      */
     public void testReset() {
         TmfStatisticsTreeNode rootNode    = fStatsData.get(AbsTmfStatisticsTree.ROOT);
-        TmfStatisticsTreeNode traceNode   = fStatsData.get(new TmfFixedArray<String>(fTestName));
+        TmfStatisticsTreeNode traceNode   = fStatsData.get(fTestName);
         TmfStatisticsTreeNode catNode     = traceNode.getChildren().iterator().next();
-        TmfStatisticsTreeNode elementNode = fStatsData.get(new TmfFixedArray<String>(fTestName, Messages.TmfStatisticsData_EventTypes, fType1.getName()));
+        TmfStatisticsTreeNode elementNode = fStatsData.get(fTestName, Messages.TmfStatisticsData_EventTypes, fType1.getName());
 
         elementNode.reset();
         assertEquals("reset", 0, elementNode.getValues().getTotal());
@@ -389,7 +390,7 @@ public class TmfStatisticsTreeNodeTest extends TestCase {
         assertEquals("reset", 0, catNode.getValues().getTotal());
         assertEquals("reset", 0, catNode.getValues().getPartial());
         assertEquals("reset", 0, catNode.getNbChildren());
-        assertNull("reset", fStatsData.get(new TmfFixedArray<String>(fTestName, Messages.TmfStatisticsData_EventTypes, fType1.getName())));
+        assertNull("reset", fStatsData.get(fTestName, Messages.TmfStatisticsData_EventTypes, fType1.getName()));
 
         traceNode.reset();
         assertEquals("reset", 0, traceNode.getValues().getTotal());
@@ -409,10 +410,10 @@ public class TmfStatisticsTreeNodeTest extends TestCase {
      */
     public void testResetGlobalValue() {
         TmfStatisticsTreeNode rootNode    = fStatsData.get(AbsTmfStatisticsTree.ROOT);
-        TmfStatisticsTreeNode traceNode   = fStatsData.get(new TmfFixedArray<String>(fTestName));
+        TmfStatisticsTreeNode traceNode   = fStatsData.get(fTestName);
         TmfStatisticsTreeNode catNode     = traceNode.getChildren().iterator().next();
-        TmfStatisticsTreeNode eventTypeNode1 = fStatsData.get(new TmfFixedArray<String>(fTestName, Messages.TmfStatisticsData_EventTypes, fType1.getName()));
-        TmfStatisticsTreeNode eventTypeNode2 = fStatsData.get(new TmfFixedArray<String>(fTestName, Messages.TmfStatisticsData_EventTypes, fType2.getName()));
+        TmfStatisticsTreeNode eventTypeNode1 = fStatsData.get(fTestName, Messages.TmfStatisticsData_EventTypes, fType1.getName());
+        TmfStatisticsTreeNode eventTypeNode2 = fStatsData.get(fTestName, Messages.TmfStatisticsData_EventTypes, fType2.getName());
 
         rootNode.resetGlobalValue();
 
@@ -443,10 +444,10 @@ public class TmfStatisticsTreeNodeTest extends TestCase {
      */
     public void testResetTimeRangeValue() {
         TmfStatisticsTreeNode rootNode    = fStatsData.get(AbsTmfStatisticsTree.ROOT);
-        TmfStatisticsTreeNode traceNode   = fStatsData.get(new TmfFixedArray<String>(fTestName));
+        TmfStatisticsTreeNode traceNode   = fStatsData.get(fTestName);
         TmfStatisticsTreeNode catNode     = traceNode.getChildren().iterator().next();
-        TmfStatisticsTreeNode eventTypeNode1 = fStatsData.get(new TmfFixedArray<String>(fTestName, Messages.TmfStatisticsData_EventTypes, fType1.getName()));
-        TmfStatisticsTreeNode eventTypeNode2 = fStatsData.get(new TmfFixedArray<String>(fTestName, Messages.TmfStatisticsData_EventTypes, fType2.getName()));
+        TmfStatisticsTreeNode eventTypeNode1 = fStatsData.get(fTestName, Messages.TmfStatisticsData_EventTypes, fType1.getName());
+        TmfStatisticsTreeNode eventTypeNode2 = fStatsData.get(fTestName, Messages.TmfStatisticsData_EventTypes, fType2.getName());
 
         rootNode.resetTimeRangeValue();
 
@@ -470,4 +471,19 @@ public class TmfStatisticsTreeNodeTest extends TestCase {
         assertTrue(catChildren.contains(eventTypeNode1));
         assertTrue(catChildren.contains(eventTypeNode2));
     }
+
+    /**
+     * Check if two String arrays are equals, by comparing their contents.
+     */
+    private static boolean arraysEqual(String[] array1, String... array2) {
+        if (array1.length != array2.length) {
+            return false;
+        }
+        for (int i = 0; i < array1.length; i++) {
+            if (!array1[i].equals(array2[i])) {
+                return false;
+            }
+        }
+        return true;
+    }
 }
index b61d7de43525fe22b97cfb5cdc30af3ae6a8fa75..8febe76fcdb4b82e06752f1f766df648dc465b18 100755 (executable)
@@ -14,8 +14,6 @@
 package org.eclipse.linuxtools.tmf.ui.tests.statistics;
 
 import java.util.Arrays;
-import java.util.Collection;
-import java.util.Vector;
 
 import junit.framework.TestCase;
 
@@ -24,7 +22,6 @@ import org.eclipse.linuxtools.tmf.core.event.TmfEvent;
 import org.eclipse.linuxtools.tmf.core.event.TmfEventField;
 import org.eclipse.linuxtools.tmf.core.event.TmfEventType;
 import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
-import org.eclipse.linuxtools.tmf.core.util.TmfFixedArray;
 import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.AbsTmfStatisticsTree;
 import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.Messages;
 import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.TmfBaseStatisticsTree;
@@ -105,26 +102,48 @@ public class TmfTreeContentProviderTest extends TestCase {
 
     /**
      * Test getting of children.
+     * FIXME this test was quickly adapted when we removed the TmfFixedArray,
+     * but it could be rewritten to be much more simple...
      */
     public void testGetChildren() {
-        Object[] objectArray = treeProvider.getChildren(fStatsData.getOrCreate(new TmfFixedArray<String>(fTestName, Messages.TmfStatisticsData_EventTypes)));
+        Object[] objectArray = treeProvider.getChildren(fStatsData.getOrCreate(fTestName, Messages.TmfStatisticsData_EventTypes));
         TmfStatisticsTreeNode[] childrenNode = Arrays.asList(objectArray).toArray(new TmfStatisticsTreeNode[0]);
 
-        Collection<TmfFixedArray<String>> childrenExpected = new Vector<TmfFixedArray<String>>();
-        childrenExpected.add(new TmfFixedArray<String>(fTestName, Messages.TmfStatisticsData_EventTypes, fEvent1.getType().getName()));
-        childrenExpected.add(new TmfFixedArray<String>(fTestName, Messages.TmfStatisticsData_EventTypes, fEvent2.getType().getName()));
+        String[][] childrenExpected = new String[][] {
+                new String[] { fTestName, Messages.TmfStatisticsData_EventTypes, fEvent1.getType().getName() },
+                new String[] { fTestName, Messages.TmfStatisticsData_EventTypes, fEvent2.getType().getName() }
+        };
 
-        assertEquals("getChildren", childrenExpected.size(), childrenNode.length);
+        assertEquals("getChildren", childrenExpected.length, childrenNode.length);
         // assertTrue("getChildren", childrenPath.equals(childrenExpected));
         for (TmfStatisticsTreeNode childNode : childrenNode) {
-            if (childrenExpected.contains(childNode.getPath())) {
-                childrenExpected.remove(childNode.getPath());
-            } else {
+            if (!arrayOfArraysContains(childrenExpected, childNode.getPath())) {
                 fail();
             }
         }
     }
 
+    private static boolean arrayOfArraysContains(String[][] arrayOfArrays, String[] array) {
+        for (String[] curArray : arrayOfArrays) {
+            if (arraysEqual(curArray, array)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    private static boolean arraysEqual(String[] array1, String[] array2) {
+        if (array1.length != array2.length) {
+            return false;
+        }
+        for (int i = 0; i < array1.length; i++) {
+            if (!array1[i].equals(array2[i])) {
+                return false;
+            }
+        }
+        return true;
+    }
+
     // ------------------------------------------------------------------------
     // GetParent
     // ------------------------------------------------------------------------
@@ -133,7 +152,7 @@ public class TmfTreeContentProviderTest extends TestCase {
      * Test getting of parent.
      */
     public void testGetParent() {
-        TmfStatisticsTreeNode parent = (TmfStatisticsTreeNode) treeProvider.getParent(fStatsData.get(new TmfFixedArray<String>(fTestName)));
+        TmfStatisticsTreeNode parent = (TmfStatisticsTreeNode) treeProvider.getParent(fStatsData.get(fTestName));
 
         assertNotNull("getParent", parent);
         assertTrue("getParent", parent.getPath().equals(AbsTmfStatisticsTree.ROOT));
@@ -149,13 +168,13 @@ public class TmfTreeContentProviderTest extends TestCase {
         Boolean hasChildren = treeProvider.hasChildren(fStatsData.getOrCreate(AbsTmfStatisticsTree.ROOT));
         assertTrue("hasChildren", hasChildren);
 
-        hasChildren = treeProvider.hasChildren(fStatsData.getOrCreate(new TmfFixedArray<String>(fTestName)));
+        hasChildren = treeProvider.hasChildren(fStatsData.getOrCreate(fTestName));
         assertTrue("hasChildren", hasChildren);
 
-        hasChildren = treeProvider.hasChildren(fStatsData.getOrCreate(new TmfFixedArray<String>(fTestName, Messages.TmfStatisticsData_EventTypes)));
+        hasChildren = treeProvider.hasChildren(fStatsData.getOrCreate(fTestName, Messages.TmfStatisticsData_EventTypes));
         assertTrue("hasChildren", hasChildren);
 
-        hasChildren = treeProvider.hasChildren(fStatsData.getOrCreate(new TmfFixedArray<String>(fTestName, Messages.TmfStatisticsData_EventTypes, fEvent1.getType().getName())));
+        hasChildren = treeProvider.hasChildren(fStatsData.getOrCreate(fTestName, Messages.TmfStatisticsData_EventTypes, fEvent1.getType().getName()));
         assertFalse("hasChildren", hasChildren);
     }
 
@@ -170,6 +189,6 @@ public class TmfTreeContentProviderTest extends TestCase {
         Object[] objectElements = treeProvider.getElements(fStatsData.get(AbsTmfStatisticsTree.ROOT));
         TmfStatisticsTreeNode[] nodeElements = Arrays.asList(objectElements).toArray(new TmfStatisticsTreeNode[0]);
         assertEquals("getElements", 1, nodeElements.length);
-        assertTrue("getElements", nodeElements[0].getPath().equals(new TmfFixedArray<String>(fTestName)));
+        assertTrue("getElements", nodeElements[0].getPath()[0].equals(fTestName));
     }
 }
index 7ac48e731fe68156aec856adf9c0710b8204e5c0..17ffaaa8c9264d6e51f62231097d53c76eac9b3f 100755 (executable)
 
 package org.eclipse.linuxtools.tmf.ui.viewers.statistics.model;
 
+import java.util.Arrays;
 import java.util.Collection;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
-import org.eclipse.linuxtools.tmf.core.util.TmfFixedArray;
-
 /**
  * Base class for the statistics storage. It allow to implement a tree structure
  * while avoiding the need to run through the tree each time you need to add a
@@ -39,7 +39,7 @@ public abstract class AbsTmfStatisticsTree {
     /**
      * Identification of the root.
      */
-    public static final TmfFixedArray<String> ROOT = new TmfFixedArray<String>("root"); //$NON-NLS-1$
+    public static final String[] ROOT = new String[] { "root" }; //$NON-NLS-1$
 
     /**
      * Function to merge many string more efficiently.
@@ -65,13 +65,13 @@ public abstract class AbsTmfStatisticsTree {
     /**
      * The nodes in the tree.
      */
-    protected HashMap<TmfFixedArray<String>, TmfStatisticsTreeNode> fNodes;
+    protected Map<List<String>, TmfStatisticsTreeNode> fNodes;
 
     /**
      * Constructor.
      */
     public AbsTmfStatisticsTree() {
-        fNodes = new HashMap<TmfFixedArray<String>, TmfStatisticsTreeNode>();
+        fNodes = new HashMap<List<String>, TmfStatisticsTreeNode>();
         fKeys = new HashMap<String, Set<String>>();
     }
 
@@ -82,8 +82,9 @@ public abstract class AbsTmfStatisticsTree {
      *            Path to the node.
      * @return The node or null.
      */
-    public TmfStatisticsTreeNode get(final TmfFixedArray<String> path) {
-        return fNodes.get(path);
+    public TmfStatisticsTreeNode get(String... path) {
+        List<String> pathAsList = Arrays.asList(path);
+        return fNodes.get(pathAsList);
     }
 
     /**
@@ -93,7 +94,7 @@ public abstract class AbsTmfStatisticsTree {
      *            Path to the node.
      * @return Collection containing the children.
      */
-    public abstract Collection<TmfStatisticsTreeNode> getChildren(final TmfFixedArray<String> path);
+    public abstract Collection<TmfStatisticsTreeNode> getChildren(final String... path);
 
     /**
      * Get every children of a node, even if it doesn't have any registered
@@ -103,7 +104,7 @@ public abstract class AbsTmfStatisticsTree {
      *            Path to the node.
      * @return Collection containing all the children.
      */
-    public abstract Collection<TmfStatisticsTreeNode> getAllChildren(final TmfFixedArray<String> path);
+    public abstract Collection<TmfStatisticsTreeNode> getAllChildren(final String... path);
 
     /**
      * Get the map of existing elements of path classified by parent.
@@ -121,12 +122,14 @@ public abstract class AbsTmfStatisticsTree {
      *            Path to the node.
      * @return The node.
      */
-    public TmfStatisticsTreeNode getOrCreate(final TmfFixedArray<String> path) {
-        TmfStatisticsTreeNode current = fNodes.get(path);
+    public TmfStatisticsTreeNode getOrCreate(String... path) {
+        List<String> pathAsList = Arrays.asList(path);
+        TmfStatisticsTreeNode current = fNodes.get(pathAsList);
+
         if (current == null) {
             registerName(path);
-            current = new TmfStatisticsTreeNode(path, this);
-            fNodes.put(path, current);
+            current = new TmfStatisticsTreeNode(this, path);
+            fNodes.put(pathAsList, current);
         }
         return current;
     }
@@ -138,14 +141,17 @@ public abstract class AbsTmfStatisticsTree {
      *            Path to the node.
      * @return Parent node or null.
      */
-    public TmfStatisticsTreeNode getParent(final TmfFixedArray<String> path) {
-        if (path.size() == 1) {
+    public TmfStatisticsTreeNode getParent(final String... path) {
+        if (path.length == 1) {
             if (path.equals(ROOT)) {
                 return null;
             }
             return get(ROOT);
         }
-        return get(path.subArray(0, path.size() - 1));
+
+        String[] parentPath = new String[path.length - 1];
+        System.arraycopy(path, 0, parentPath, 0, parentPath.length);
+        return get(parentPath);
     }
 
     /**
@@ -188,7 +194,7 @@ public abstract class AbsTmfStatisticsTree {
      * @param path
      *            Path of the new node.
      */
-    protected abstract void registerName(final TmfFixedArray<String> path);
+    protected abstract void registerName(final String... path);
 
     /**
      * Resets a node.
@@ -198,10 +204,11 @@ public abstract class AbsTmfStatisticsTree {
      * @param path
      *            Path to the node.
      */
-    public void reset(final TmfFixedArray<String> path) {
+    public void reset(final String... path) {
         for (TmfStatisticsTreeNode node : getAllChildren(path)) {
             reset(node.getPath());
-            fNodes.remove(node.getPath());
+            List<String> nodePathList = Arrays.asList(node.getPath());
+            fNodes.remove(nodePathList);
         }
     }
 
@@ -214,7 +221,7 @@ public abstract class AbsTmfStatisticsTree {
      *            Path to the node.
      * @since 2.0
      */
-    public void resetGlobalValue(final TmfFixedArray<String> path) {
+    public void resetGlobalValue(final String... path) {
         for (TmfStatisticsTreeNode node : getChildren(path)) {
             node.resetGlobalValue();
         }
@@ -229,7 +236,7 @@ public abstract class AbsTmfStatisticsTree {
      *            Path to the node.
      * @since 2.0
      */
-    public void resetTimeRangeValue(final TmfFixedArray<String> path) {
+    public void resetTimeRangeValue(final String... path) {
         for (TmfStatisticsTreeNode node : getChildren(path)) {
             node.resetTimeRangeValue();
         }
index 2e6ed762825af54d5d44b7157c7f2819f61bcf62..8790c39bf6e7dfd92abea24e64d3943ef0aa4aad 100755 (executable)
@@ -15,11 +15,10 @@ package org.eclipse.linuxtools.tmf.ui.viewers.statistics.model;
 import java.util.Collection;
 import java.util.HashSet;
 import java.util.LinkedList;
+import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
-import org.eclipse.linuxtools.tmf.core.util.TmfFixedArray;
-
 /**
  * Store information about base statistics data.
  *
@@ -49,7 +48,7 @@ public class TmfBaseStatisticsTree extends AbsTmfStatisticsTree {
     /**
      * Root node key.
      */
-    protected static final String ROOT_NODE_KEY = mergeString(ROOT.get(0), NODE);
+    protected static final String ROOT_NODE_KEY = mergeString(ROOT[0], NODE);
 
     /**
      * Default constructor. Creates base statistics tree for counting total
@@ -73,7 +72,7 @@ public class TmfBaseStatisticsTree extends AbsTmfStatisticsTree {
         keys.put(mergeString(HEADER_EVENT_TYPES, NODE), temp);
 
         // //////////// CREATE root
-        keys.put(ROOT.get(0), new HashSet<String>(2)); // 1 trace at the time
+        keys.put(ROOT[0], new HashSet<String>(2)); // 1 trace at the time
         getOrCreate(ROOT);
     }
 
@@ -84,32 +83,34 @@ public class TmfBaseStatisticsTree extends AbsTmfStatisticsTree {
      * (org.eclipse.linuxtools.tmf.core.util.TmfFixedArray)
      */
     @Override
-    public Collection<TmfStatisticsTreeNode> getChildren(TmfFixedArray<String> path) {
-        LinkedList<TmfStatisticsTreeNode> result = new LinkedList<TmfStatisticsTreeNode>();
+    public List<TmfStatisticsTreeNode> getChildren(String... path) {
+        List<TmfStatisticsTreeNode> result = new LinkedList<TmfStatisticsTreeNode>();
 
-        if (path.size() % 2 == 0) { // if we are at a Category
+        if (path.length % 2 == 0) { // if we are at a Category
             TmfStatisticsTreeNode current = null;
-            for (String value : getKeys().get(path.get(path.size() - 1))) {
-                current = get(path.append(value));
-                if (current != null && current.getValues().getTotal() != 0) {
-                    result.add(current);
+            for (String value : getKeys().get(path[path.length - 1])) {
+                current = get(addToArray(path, value));
+                if (current != null) {
+                    if (current.getValues().getTotal() > 0 || current.getValues().getPartial() > 0) {
+                        result.add(current);
+                    }
                 }
             }
-        } else if (path.size() == 1) { // Special case.
+        } else if (path.length == 1) { // Special case.
             if (path.equals(ROOT)) {
-                for (String value : getKeys().get(ROOT.get(0))) {
-                    result.add(getOrCreate(new TmfFixedArray<String>(value)));
+                for (String value : getKeys().get(ROOT[0])) {
+                    result.add(getOrCreate(value));
                 }
             } else {
                 // Get value under the root
                 for (String value : getKeys().get(ROOT_NODE_KEY)) {
-                    result.add(getOrCreate(path.append(value)));
+                    result.add(getOrCreate(addToArray(path, value)));
                 }
             }
         } else {// If we are at a value
-            for (String value : getKeys().get(mergeString(path.get(path.size() - 2), NODE))) {
+            for (String value : getKeys().get(mergeString(path[path.length - 2], NODE))) {
                 // Search the parent name + NODE
-                result.add(getOrCreate(path.append(value)));
+                result.add(getOrCreate(addToArray(path, value)));
             }
         }
 
@@ -123,32 +124,32 @@ public class TmfBaseStatisticsTree extends AbsTmfStatisticsTree {
      * (org.eclipse.linuxtools.tmf.core.util.TmfFixedArray)
      */
     @Override
-    public Collection<TmfStatisticsTreeNode> getAllChildren(TmfFixedArray<String> path) {
+    public Collection<TmfStatisticsTreeNode> getAllChildren(String... path) {
         LinkedList<TmfStatisticsTreeNode> result = new LinkedList<TmfStatisticsTreeNode>();
 
-        if (path.size() % 2 == 0) { // if we are at a Category
+        if (path.length % 2 == 0) { // if we are at a Category
             TmfStatisticsTreeNode current = null;
-            for (String value : getKeys().get(path.get(path.size() - 1))) {
-                current = get(path.append(value));
+            for (String value : getKeys().get(path[path.length - 1])) {
+                current = get(addToArray(path, value));
                 if (current != null) {
                     result.add(current);
                 }
             }
-        } else if (path.size() == 1) { // Special case.
+        } else if (path.length == 1) { // Special case.
             if (path.equals(ROOT)) {
-                for (String value : getKeys().get(ROOT.get(0))) {
-                    result.add(getOrCreate(new TmfFixedArray<String>(value)));
+                for (String value : getKeys().get(ROOT[0])) {
+                    result.add(getOrCreate(value));
                 }
             } else {
                 // Get value under the root
                 for (String value : getKeys().get(ROOT_NODE_KEY)) {
-                    result.add(getOrCreate(path.append(value)));
+                    result.add(getOrCreate(addToArray(path, value)));
                 }
             }
         } else {// If we are at a value
-            for (String value : getKeys().get(mergeString(path.get(path.size() - 2), NODE))) {
+            for (String value : getKeys().get(mergeString(path[path.length - 2], NODE))) {
                 // Search the parent name + NODE
-                result.add(getOrCreate(path.append(value)));
+                result.add(getOrCreate(addToArray(path, value)));
             }
         }
         return result;
@@ -156,16 +157,16 @@ public class TmfBaseStatisticsTree extends AbsTmfStatisticsTree {
 
     @Override
     public void setTotal(String traceName, boolean isGlobal, long qty) {
-        TmfFixedArray<String>[] paths = getNormalPaths(traceName);
-        for (TmfFixedArray<String> path : paths) {
+        String[][] paths = getNormalPaths(traceName);
+        for (String path[] : paths) {
             getOrCreate(path).getValues().setValue(isGlobal, qty);
         }
     }
 
     @Override
     public void setTypeCount(String traceName, String type, boolean isGlobal,  long qty) {
-        TmfFixedArray<String>[] paths = getTypePaths(traceName, type);
-        for (TmfFixedArray<String> path : paths) {
+        String[][] paths = getTypePaths(traceName, type);
+        for (String[] path : paths) {
             getOrCreate(path).getValues().setValue(isGlobal, qty);
         }
     }
@@ -179,9 +180,8 @@ public class TmfBaseStatisticsTree extends AbsTmfStatisticsTree {
      *            Extra information to pass along with the event
      * @return Array of FixedArray representing the paths.
      */
-    @SuppressWarnings({ "rawtypes", "unchecked" })
-    protected TmfFixedArray<String>[] getTypePaths(String traceName, String type) {
-        TmfFixedArray[] paths = { new TmfFixedArray<String>(traceName, HEADER_EVENT_TYPES, type) };
+    protected String[][] getTypePaths(String traceName, String type) {
+        String[][] paths = { new String[] {traceName, HEADER_EVENT_TYPES, type } };
         return paths;
     }
 
@@ -194,9 +194,8 @@ public class TmfBaseStatisticsTree extends AbsTmfStatisticsTree {
      *            Extra information to pass along with the event
      * @return Array of FixedArray representing the paths.
      */
-    @SuppressWarnings({ "rawtypes", "unchecked" })
-    protected TmfFixedArray<String>[] getNormalPaths(String traceName) {
-        TmfFixedArray[] paths = { new TmfFixedArray<String>(traceName) };
+    protected String[][] getNormalPaths(String traceName) {
+        String[][] paths = { new String[] { traceName } };
         return paths;
     }
 
@@ -207,13 +206,24 @@ public class TmfBaseStatisticsTree extends AbsTmfStatisticsTree {
      * (org.eclipse.linuxtools.tmf.core.util.TmfFixedArray)
      */
     @Override
-    protected void registerName(TmfFixedArray<String> path) {
-        if (path.size() == 1) {
+    protected void registerName(String... path) {
+        if (path.length == 1) {
             if (!path.equals(ROOT)) {
-                getKeys().get(ROOT.get(0)).add(path.get(0));
+                getKeys().get(ROOT[0]).add(path[0]);
             }
-        } else if (path.size() % 2 != 0) {
-            getKeys().get(path.get(path.size() - 2)).add(path.get(path.size() - 1));
+        } else if (path.length % 2 != 0) {
+            getKeys().get(path[path.length - 2]).add(path[path.length - 1]);
         }
     }
+
+    /**
+     * Return a new array that's a copy of the old one, plus 'newElem' added at
+     * the end.
+     */
+    private static String[] addToArray(String[] array, String newElem) {
+        String[] newArray = new String[array.length + 1];
+        System.arraycopy(array, 0, newArray, 0, array.length);
+        newArray[array.length] = newElem;
+        return newArray;
+    }
 }
index 71873c12d3cb2914cbd67fc0991e57009c767b49..10616c32298a4d5c92e1e90a96bc58f64bf91c49 100755 (executable)
@@ -16,14 +16,12 @@ package org.eclipse.linuxtools.tmf.ui.viewers.statistics.model;
 
 import java.util.Collection;
 
-import org.eclipse.linuxtools.tmf.core.util.TmfFixedArray;
-
 /**
  * A tree where nodes can be accessed efficiently using paths.
  *
  * It works like file systems. Each node is identified by a key. A path is an
- * array ({@link TmfFixedArray}) of String. The elements of the array represent
- * the path from the root to this node.
+ * array of String. The elements of the array represent the path from the root
+ * to this node.
  *
  * @version 2.0
  * @since 2.0
@@ -39,7 +37,7 @@ public class TmfStatisticsTreeNode {
     /**
      * Path of the node.
      */
-    protected TmfFixedArray<String> fPath;
+    protected String[] fPath;
 
     /**
      * Corresponding StatisticsData.
@@ -54,8 +52,7 @@ public class TmfStatisticsTreeNode {
      * @param nodes
      *            Corresponding StatisticsData.
      */
-    public TmfStatisticsTreeNode(final TmfFixedArray<String> path,
-            AbsTmfStatisticsTree nodes) {
+    public TmfStatisticsTreeNode(AbsTmfStatisticsTree nodes, final String... path) {
         fPath = path;
         fNodes = nodes;
         fValues = new TmfStatisticsValues();
@@ -71,9 +68,13 @@ public class TmfStatisticsTreeNode {
      */
     public boolean containsChild(String key) {
         if (AbsTmfStatisticsTree.ROOT.equals(fPath)) {
-            return fNodes.get(new TmfFixedArray<String>(key)) != null;
+            return fNodes.get(key) != null;
         }
-        return (fNodes.get(fPath.append(key)) != null);
+
+        String[] childPath = new String[fPath.length + 1];
+        System.arraycopy(fPath, 0, childPath, 0, fPath.length);
+        childPath[fPath.length] = key;
+        return (fNodes.get(childPath) != null);
     }
 
     /**
@@ -100,7 +101,7 @@ public class TmfStatisticsTreeNode {
      * @return Key associated with this node.
      */
     public String getKey() {
-        return fPath.get(fPath.size() - 1);
+        return fPath[fPath.length - 1];
     }
 
     /**
@@ -126,7 +127,7 @@ public class TmfStatisticsTreeNode {
      *
      * @return The path of the node.
      */
-    public TmfFixedArray<String> getPath() {
+    public String[] getPath() {
         return fPath;
     }
 
This page took 0.053629 seconds and 5 git commands to generate.