Mercurial > dive4elements > river
view flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/Parameters.java @ 2740:64dc2997b2dd
Refactor static xpath, other artifacts will come in a later commit.
flys-artifacts/trunk@4474 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Wed, 23 May 2012 10:04:11 +0000 |
parents | a441be7f1589 |
children | c1f2e792704a |
line wrap: on
line source
package de.intevation.flys.artifacts.model; import gnu.trove.TDoubleArrayList; import java.io.Serializable; public class Parameters implements Serializable { protected String [] columnNames; protected TDoubleArrayList [] columns; public Parameters() { } public Parameters(String [] columnNames) { if (columnNames == null || columnNames.length < 1) { throw new IllegalArgumentException("columnNames too short."); } this.columnNames = columnNames; columns = new TDoubleArrayList[columnNames.length]; for (int i = 0; i < columns.length; ++i) { columns[i] = new TDoubleArrayList(); } } public int columnIndex(String name) { for (int i = 0; i < columnNames.length; ++i) { if (name.equals(name)) { return i; } } return -1; } public int newRow() { int N = columns[0].size(); for (int i = 0; i < columns.length; ++i) { columns[i].add(Double.NaN); } return N; } public double get(int i, int index) { return columns[index].getQuick(i); } public double get(int i, String columnName) { int index = columnIndex(columnName); return index >= 0 ? columns[index].getQuick(i) : Double.NaN; } public void set(int i, String columnName, double value) { int idx = columnIndex(columnName); if (idx >= 0) { columns[i].setQuick(idx, value); } } public int size() { return columns[0].size(); } public int getNumberColumns() { return columnNames.length; } public String [] getColumnNames() { return columnNames; } public void removeNaNs() { W.removeNaNs(columns); } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :