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
9
* IBM Corporation - Jeff Briggs, Henry Hughes, Ryan Morse
10
*******************************************************************************/
12
package org.eclipse.linuxtools.systemtap.graphing.core.datasets.table;
14
import java.util.ArrayList;
15
import java.util.List;
17
import org.eclipse.linuxtools.systemtap.graphing.core.datasets.IDataEntry;
19
public class TableEntry implements IDataEntry {
21
bodyContent = new ArrayList<>();
25
public int getRowCount() {
26
return bodyContent.size();
30
public int getColCount() {
31
if(getRowCount() > 0) {
32
return bodyContent.get(0).length;
38
public Object get(String key, int col) {
39
if(col >= 0 && col < getColCount()) {
40
Object[] row = getRow(key);
48
public Object[][] getData() {
49
Object[][] d = new Object[getRowCount()][getColCount()];
50
for(int i=0; i<getRowCount(); i++) {
57
public Object[] getRow(int row) {
58
if(row < 0 || row >= getRowCount())
60
return bodyContent.get(row);
64
public Object[] getRow(String key) {
66
for(int i=0; i<bodyContent.size(); i++) {
67
row = bodyContent.get(i);
68
if(row[0].toString().equals(key))
75
public Object[] getColumn(int col) {
76
return getColumn(col, 0, getRowCount());
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];
90
public void putRow(int row, Object[] data) {
91
if(row >= bodyContent.size())
94
bodyContent.add(row, data);
95
bodyContent.remove(row+1);
99
public void add(Object[] data) {
100
if(null != data && (data.length == getColCount() || getRowCount() == 0))
101
bodyContent.add(data);
105
public IDataEntry copy() {
106
TableEntry entry = new TableEntry();
107
for(int i=0; i<bodyContent.size(); i++)
108
entry.add(bodyContent.get(i));
114
public boolean remove(int row) {
115
return (null != bodyContent.remove(row));
118
private List<Object[]> bodyContent; //ArrayList of arrays