|
| 1 | +/** |
| 2 | + * Copyright (C) 2010-18 diirt developers. See COPYRIGHT.TXT |
| 3 | + * All rights reserved. Use is subject to license terms. See LICENSE.TXT |
| 4 | + */ |
| 5 | +package org.epics.vtype; |
| 6 | + |
| 7 | +import java.util.List; |
| 8 | +import org.epics.util.array.ListNumber; |
| 9 | + |
| 10 | +/** |
| 11 | + * A table. Tables are collections of columns, each of which is composed of a |
| 12 | + * String representing the name of the column and a list of a particular type |
| 13 | + * (all elements of the same column must be of the same type). |
| 14 | + * |
| 15 | + * @author carcassi, shroff |
| 16 | + */ |
| 17 | +public abstract class VTable extends VType { |
| 18 | + |
| 19 | + /** |
| 20 | + * The number of columns in the table. |
| 21 | + * |
| 22 | + * @return the number of columns |
| 23 | + */ |
| 24 | + abstract int getColumnCount(); |
| 25 | + |
| 26 | + /** |
| 27 | + * The number of rows in the table. |
| 28 | + * <p> |
| 29 | + * Currently, it is not clear whether all columns actually have the same number |
| 30 | + * of rows, that is if all arrays have the same length. In the case of variable |
| 31 | + * row, this will return the maximum row count, that is the length of the |
| 32 | + * longest array/column. |
| 33 | + * |
| 34 | + * @return the number of rows |
| 35 | + */ |
| 36 | + abstract int getRowCount(); |
| 37 | + |
| 38 | + /** |
| 39 | + * The type of the elements in the column. The column array will be an array of |
| 40 | + * the given type. For primitive types, this function will return the TYPE class |
| 41 | + * (such as {@link Double#TYPE}, while {@link #getColumnData(int) } will return |
| 42 | + * a {@link ListNumber}. |
| 43 | + * |
| 44 | + * @param column the column index |
| 45 | + * @return the type of this column |
| 46 | + */ |
| 47 | + abstract Class<?> getColumnType(int column); |
| 48 | + |
| 49 | + /** |
| 50 | + * The name of the given column. |
| 51 | + * |
| 52 | + * @param column the column index |
| 53 | + * @return the name of the column |
| 54 | + */ |
| 55 | + abstract String getColumnName(int column); |
| 56 | + |
| 57 | + /** |
| 58 | + * The data for the given column. |
| 59 | + * <p> |
| 60 | + * The data is going to be a {@link List} in case of objects or a |
| 61 | + * {@link ListNumber} in case of a numeric primitive. |
| 62 | + * |
| 63 | + * @param column the column index |
| 64 | + * @return the data of the column |
| 65 | + */ |
| 66 | + abstract Object getColumnData(int column); |
| 67 | + |
| 68 | + /** |
| 69 | + * Create a new VTable |
| 70 | + * |
| 71 | + * @param types the types of each column |
| 72 | + * @param names the name of each column |
| 73 | + * @param values the values of each column |
| 74 | + * @return an immutable instance of the VTable |
| 75 | + */ |
| 76 | + public static VTable of(List<Class<?>> types, List<String> names, List<Object> values) { |
| 77 | + return new IVTable(types, names, values); |
| 78 | + } |
| 79 | +} |
0 commit comments