diff options
Diffstat (limited to 'src/de/lmu/ifi/dbs/elki/data/type/VectorFieldTypeInformation.java')
-rw-r--r-- | src/de/lmu/ifi/dbs/elki/data/type/VectorFieldTypeInformation.java | 76 |
1 files changed, 55 insertions, 21 deletions
diff --git a/src/de/lmu/ifi/dbs/elki/data/type/VectorFieldTypeInformation.java b/src/de/lmu/ifi/dbs/elki/data/type/VectorFieldTypeInformation.java index 43bc149f..99bed220 100644 --- a/src/de/lmu/ifi/dbs/elki/data/type/VectorFieldTypeInformation.java +++ b/src/de/lmu/ifi/dbs/elki/data/type/VectorFieldTypeInformation.java @@ -1,26 +1,27 @@ package de.lmu.ifi.dbs.elki.data.type; -/* -This file is part of ELKI: -Environment for Developing KDD-Applications Supported by Index-Structures - -Copyright (C) 2011 -Ludwig-Maximilians-Universität München -Lehr- und Forschungseinheit für Datenbanksysteme -ELKI Development Team - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU Affero General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Affero General Public License for more details. -You should have received a copy of the GNU Affero General Public License -along with this program. If not, see <http://www.gnu.org/licenses/>. -*/ +/* + This file is part of ELKI: + Environment for Developing KDD-Applications Supported by Index-Structures + + Copyright (C) 2011 + Ludwig-Maximilians-Universität München + Lehr- und Forschungseinheit für Datenbanksysteme + ELKI Development Team + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + */ import de.lmu.ifi.dbs.elki.data.FeatureVector; @@ -38,6 +39,11 @@ public class VectorFieldTypeInformation<V extends FeatureVector<?, ?>> extends V private final V factory; /** + * Labels + */ + private String[] labels = null; + + /** * Constructor for a request without fixed dimensionality. * * @param cls Vector restriction class. @@ -82,6 +88,21 @@ public class VectorFieldTypeInformation<V extends FeatureVector<?, ?>> extends V this.factory = factory; } + /** + * Constructor with given dimensionality and factory, so usually an instance. + * + * @param cls Restriction java class + * @param dim Dimensionality + * @param labels Labels + * @param factory Factory class + */ + public VectorFieldTypeInformation(Class<? super V> cls, int dim, String[] labels, V factory) { + super(cls, dim, dim); + this.labels = labels; + this.factory = factory; + assert (labels == null || labels.length == dim) : "Created vector field with incomplete labels."; + } + @Override public boolean isAssignableFromType(TypeInformation type) { // Do all checks from superclass @@ -154,4 +175,17 @@ public class VectorFieldTypeInformation<V extends FeatureVector<?, ?>> extends V return super.toString(); } } + + /** + * Get the column label + * + * @param col Column number + * @return Label + */ + public String getLabel(int col) { + if(labels == null) { + return null; + } + return labels[col - 1]; + } }
\ No newline at end of file |