~ubuntu-branches/ubuntu/utopic/eclipse-linuxtools/utopic

« back to all changes in this revision

Viewing changes to systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui.tests/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/tests/MockDataSet.java

  • Committer: Package Import Robot
  • Author(s): Jakub Adam
  • Date: 2014-05-12 18:11:40 UTC
  • mfrom: (3.1.2 sid)
  • Revision ID: package-import@ubuntu.com-20140512181140-w237r3vsah1tmybz
Tags: 2.2.1-1
* New upstream release.
* Refreshed d/patches.
* Removed eclipse-cdt-valgrind-remote package, all its functionality
  is now provided by eclipse-cdt-profiling-framework-remote.
* Added remove-license-feature.patch.
* Bump Standards-Version to 3.9.5.
* Enable eclipse-changelog package.
* Enable eclipse-rpm-editor package.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*******************************************************************************
2
 
 * Copyright (c) 2006 IBM Corporation.
3
 
 * All rights reserved. This program and the accompanying materials
4
 
 * are made available under the terms of the Eclipse Public License v1.0
5
 
 * which accompanies this distribution, and is available at
6
 
 * http://www.eclipse.org/legal/epl-v10.html
7
 
 *
8
 
 * Contributors:
9
 
 *     IBM Corporation - Jeff Briggs, Henry Hughes, Ryan Morse
10
 
 *******************************************************************************/
11
 
 
12
 
package org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui.tests;
13
 
 
14
 
import java.util.ArrayList;
15
 
 
16
 
import org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui.datasets.row.RowDataSet;
17
 
import org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui.datasets.row.RowEntry;
18
 
 
19
 
 
20
 
public final class MockDataSet {
21
 
        public static RowDataSet buildDataSet(int rows, int cols) {
22
 
                String[] titles = new String[cols];
23
 
                int i;
24
 
                for(i=0; i<cols; i++)
25
 
                        titles[i] = ""+ i;
26
 
                
27
 
                RowDataSet data = new RowDataSet(titles);
28
 
                RowEntry entry;
29
 
                
30
 
                int j;
31
 
                for(i=0; i<rows; i++) {
32
 
                        Object[] d = new Object[cols];
33
 
                        for(j=0; j< cols; j++)
34
 
                                d[j] = new Double(i*cols + j);
35
 
                        entry = new RowEntry();
36
 
                        entry.putRow(0, d);
37
 
                        data.append(entry);
38
 
                }
39
 
                return data;
40
 
        }
41
 
        
42
 
        public static ArrayList<Object>[] buildArray(int width, int height, int wrap) {
43
 
                ArrayList<Object>[] list = createArrayList(width, new Object());
44
 
                
45
 
                for(int i=0; i<width; i++) {
46
 
                        list[i] = new ArrayList<Object>();
47
 
                        for(int j=0; j<height; j++) {
48
 
                                list[i].add("" + ((j+i) % wrap));
49
 
                        }
50
 
                }
51
 
                return list;
52
 
        }
53
 
        
54
 
        @SuppressWarnings("unchecked")
55
 
        public static <T> ArrayList<T>[] createArrayList(int size, T instance) {
56
 
                return new ArrayList[size];
57
 
        }
58
 
 
59
 
        public static Integer[] buildIntegerArray(int[] arr) {
60
 
                Integer[] ints = new Integer[arr.length];
61
 
                for(int i=0; i<arr.length; i++)
62
 
                        ints[i] = Integer.valueOf(arr[i]);
63
 
                return ints;
64
 
        }
65
 
        
66
 
        public static Double[] buildDoubleArray(double[] arr) {
67
 
                Double[] doubles = new Double[arr.length];
68
 
                for(int i=0; i<arr.length; i++)
69
 
                        doubles[i] = Double.valueOf(arr[i]);
70
 
                return doubles;
71
 
        }
72
 
}