java/sql-dk/src/main/java/info/globalcode/sql/dk/formatting/ColumnDescriptor.java
author František Kučera <franta-hg@frantovo.cz>
Mon, 04 Mar 2019 20:15:24 +0100
branchv_0
changeset 238 4a1864c3e867
parent 174 java/sql-dk/src/info/globalcode/sql/dk/formatting/ColumnDescriptor.java@3c6d560a1d14
child 245 b6ff5b7a8422
permissions -rw-r--r--
mavenized: sql-dk

/**
 * 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, 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 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;

	/**
	 * @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 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;
		}
	}
}