~ubuntu-branches/ubuntu/wily/eclipse-linuxtools/wily

« back to all changes in this revision

Viewing changes to systemtap/org.eclipse.linuxtools.systemtap.graphing.core/src/org/eclipse/linuxtools/systemtap/graphing/core/datasets/table/TableEntry.java

  • Committer: Package Import Robot
  • Author(s): Jakub Adam, Jakub Adam, tony mancill
  • Date: 2014-10-11 11:44:05 UTC
  • mfrom: (1.2.4)
  • Revision ID: package-import@ubuntu.com-20141011114405-yazjvxfzzhmi5sgj
Tags: 3.1.0-1
[ Jakub Adam ]
* New upstream release (Closes: #761524).
* Refreshed d/patches.
* Don't build removed feature org.eclipse.linuxtools.tools.launch
  - merged into org.eclipse.linuxtools.profiling.
* Use javac target 1.7.
* Build new feature org.eclipse.linuxtools.dataviewers.feature
  - required by Valgrind integration.
* Build-depend on eclipse-remote-services-api and eclipse-cdt-autotools.
* Bump Standards-Version to 3.9.6.
* Override incompatible-java-bytecode-format - linuxtools needs Java 7.
* Remove unused codeless-jar override.

[ tony mancill ]
* Tweak short package description to make lintian happy.

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.graphing.core.datasets.table;
 
13
 
 
14
import java.util.ArrayList;
 
15
import java.util.List;
 
16
 
 
17
import org.eclipse.linuxtools.systemtap.graphing.core.datasets.IDataEntry;
 
18
 
 
19
public class TableEntry implements IDataEntry {
 
20
    public TableEntry() {
 
21
        bodyContent = new ArrayList<>();
 
22
    }
 
23
 
 
24
    @Override
 
25
    public int getRowCount() {
 
26
        return bodyContent.size();
 
27
    }
 
28
 
 
29
    @Override
 
30
    public int getColCount() {
 
31
        if(getRowCount() > 0) {
 
32
            return bodyContent.get(0).length;
 
33
        }
 
34
        return 0;
 
35
    }
 
36
 
 
37
    @Override
 
38
    public Object get(String key, int col) {
 
39
        if(col >= 0 && col < getColCount()) {
 
40
            Object[] row = getRow(key);
 
41
            if(null != row)
 
42
                return row[col];
 
43
        }
 
44
        return null;
 
45
    }
 
46
 
 
47
    @Override
 
48
    public Object[][] getData() {
 
49
        Object[][] d = new Object[getRowCount()][getColCount()];
 
50
        for(int i=0; i<getRowCount(); i++) {
 
51
            d[i] = getRow(i);
 
52
        }
 
53
        return d;
 
54
    }
 
55
 
 
56
    @Override
 
57
    public Object[] getRow(int row) {
 
58
        if(row < 0 || row >= getRowCount())
 
59
            return null;
 
60
        return bodyContent.get(row);
 
61
    }
 
62
 
 
63
    @Override
 
64
    public Object[] getRow(String key) {
 
65
        Object[] row;
 
66
        for(int i=0; i<bodyContent.size(); i++) {
 
67
            row = bodyContent.get(i);
 
68
            if(row[0].toString().equals(key))
 
69
                return row;
 
70
        }
 
71
        return null;
 
72
    }
 
73
 
 
74
    @Override
 
75
    public Object[] getColumn(int col) {
 
76
        return getColumn(col, 0, getRowCount());
 
77
    }
 
78
 
 
79
    public Object[] getColumn(int col, int start, int end) {
 
80
        if(0 <= col && getColCount() > col && start >=0 && end > start && end <= getRowCount()) {
 
81
            Object[] res = new Object[Math.min(end-start, getRowCount())];
 
82
            for(int i=0; i<res.length; i++)
 
83
                res[i] = bodyContent.get(i+start)[col];
 
84
            return res;
 
85
        }
 
86
        return null;
 
87
    }
 
88
 
 
89
    @Override
 
90
    public void putRow(int row, Object[] data) {
 
91
        if(row >= bodyContent.size())
 
92
            add(data);
 
93
        else if(row >= 0) {
 
94
            bodyContent.add(row, data);
 
95
            bodyContent.remove(row+1);
 
96
        }
 
97
    }
 
98
 
 
99
    public void add(Object[] data) {
 
100
        if(null != data && (data.length == getColCount() || getRowCount() == 0))
 
101
            bodyContent.add(data);
 
102
    }
 
103
 
 
104
    @Override
 
105
    public IDataEntry copy() {
 
106
        TableEntry entry = new TableEntry();
 
107
        for(int i=0; i<bodyContent.size(); i++)
 
108
            entry.add(bodyContent.get(i));
 
109
 
 
110
        return entry;
 
111
    }
 
112
 
 
113
    @Override
 
114
    public boolean remove(int row) {
 
115
        return (null != bodyContent.remove(row));
 
116
    }
 
117
 
 
118
    private List<Object[]> bodyContent;    //ArrayList of arrays
 
119
}