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

net.hexonet.apiconnector.Column Maven / Gradle / Ivy

There is a newer version: 4.0.18
Show newest version
package net.hexonet.apiconnector;

import java.util.ArrayList;

/**
 * Column covers Column Data in a better accessible way
 * 
 * @author Kai Schwarz
 * @version %I%, %G%
 * @since 2.0
 */
public class Column {
    /** column size */
    public int length;
    /** column name */
    private String key;
    /** column data container */
    private ArrayList data;

    /**
     * Class constructor.
     * 
     * @param key  column name
     * @param data column data as list
     */
    public Column(String key, ArrayList data) {
        this.data = new ArrayList(data);
        this.key = key;
        this.length = this.data.size();
    }

    /**
     * Get column name
     * 
     * @return column name
     */
    public String getKey() {
        return this.key;
    }

    /**
     * Get column data
     *
     * @return column data
     */
    public ArrayList getData() {
        return this.data;
    }

    /**
     * Get data for given column index
     * 
     * @param idx column data index
     * @return data for given column index
     */
    public String getDataByIndex(int idx) {
        if (this.hasDataIndex(idx)) {
            return this.data.get(idx);
        }
        return null;
    }

    /**
     * Check if column data index exists
     * 
     * @return boolean check result
     */
    private boolean hasDataIndex(int idx) {
        return (idx >= 0 && idx < this.length);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy