java/sql-dk/src/main/java/info/globalcode/sql/dk/formatting/ColumnDescriptor.java
author František Kučera <franta-hg@frantovo.cz>
Thu, 24 Oct 2019 21:43:08 +0200
branchv_0
changeset 250 aae5009bd0af
parent 245 b6ff5b7a8422
permissions -rw-r--r--
fix license version: GNU GPLv3

/**
 * SQL-DK
 * Copyright © 2013 František Kučera (frantovo.cz)
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, version 3 of the License.
 *
 * 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */
package info.globalcode.sql.dk.formatting;

import java.sql.Types;

/**
 *
 * @author Ing. František Kučera (frantovo.cz)
 */
public class ColumnDescriptor {

	private String name;
	private String label;
	private int type;
	private String typeName;
	private boolean firstColumn;
	private boolean lastColumn;
	private int columnNumber;
	private String tableName;

	/**
	 * @return column name
	 * @see #getLabel()
	 */
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	/**
	 * @return label specified by the SQL AS clause
	 */
	public String getLabel() {
		return label;
	}

	public void setLabel(String label) {
		this.label = label;
	}

	public int getType() {
		return type;
	}

	public void setType(int type) {
		this.type = type;
	}

	public String getTypeName() {
		return typeName;
	}

	public void setTypeName(String typeName) {
		this.typeName = typeName;
	}

	public boolean isFirstColumn() {
		return firstColumn;
	}

	public void setFirstColumn(boolean firstColumn) {
		this.firstColumn = firstColumn;
	}

	public boolean isLastColumn() {
		return lastColumn;
	}

	public void setLastColumn(boolean lastColumn) {
		this.lastColumn = lastColumn;
	}

	/**
	 * @return number of this column, 1 = first
	 */
	public int getColumnNumber() {
		return columnNumber;
	}

	public void setColumnNumber(int columnNumber) {
		this.columnNumber = columnNumber;
	}

	public String getTableName() {
		return tableName;
	}

	public void setTableName(String tableName) {
		this.tableName = tableName;
	}

	public boolean isBoolean() {
		return type == Types.BOOLEAN;
	}

	public boolean isNumeric() {
		switch (type) {
			case Types.BIGINT:
			case Types.DECIMAL:
			case Types.DOUBLE:
			case Types.FLOAT:
			case Types.INTEGER:
			case Types.NUMERIC:
			case Types.REAL:
			case Types.SMALLINT:
			case Types.TINYINT:
				return true;
			default:
				return false;
		}
	}
}