All Downloads are FREE. Search and download functionalities are using the official Maven repository.

uk.ac.starlink.table.ConstantColumn Maven / Gradle / Ivy

There is a newer version: 4.3
Show newest version
package uk.ac.starlink.table;

/**
 * Represents a column which has the same value in every row.
 *
 * @author   Mark Taylor
 * @since    19 Sep 2006
 */
public class ConstantColumn extends ColumnData {

    private final Object value_;

    /**
     * Constructs a new column with a given metadata object and constant
     * datum.
     *
     * @param   colinfo  column metadata
     * @param   value    value to be found in every cell of this column
     */
    public ConstantColumn( ColumnInfo colinfo, Object value ) {
        super( colinfo );
        Class clazz = colinfo.getContentClass();
        if ( value != null &&
             ! clazz.isAssignableFrom( value.getClass() ) ) {
            throw new IllegalArgumentException( value + " is not a "
                                              + clazz.getName() );
        }
        value_ = value;
    }

    public Object readValue( long irow ) {
        return value_;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy