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
     1 /**
     2  * SQL-DK
     3  * Copyright © 2013 František Kučera (frantovo.cz)
     4  *
     5  * This program is free software: you can redistribute it and/or modify
     6  * it under the terms of the GNU General Public License as published by
     7  * the Free Software Foundation, version 3 of the License.
     8  *
     9  * This program is distributed in the hope that it will be useful,
    10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    12  * GNU General Public License for more details.
    13  *
    14  * You should have received a copy of the GNU General Public License
    15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
    16  */
    17 package info.globalcode.sql.dk.formatting;
    18 
    19 import java.sql.Types;
    20 
    21 /**
    22  *
    23  * @author Ing. František Kučera (frantovo.cz)
    24  */
    25 public class ColumnDescriptor {
    26 
    27 	private String name;
    28 	private String label;
    29 	private int type;
    30 	private String typeName;
    31 	private boolean firstColumn;
    32 	private boolean lastColumn;
    33 	private int columnNumber;
    34 	private String tableName;
    35 
    36 	/**
    37 	 * @return column name
    38 	 * @see #getLabel()
    39 	 */
    40 	public String getName() {
    41 		return name;
    42 	}
    43 
    44 	public void setName(String name) {
    45 		this.name = name;
    46 	}
    47 
    48 	/**
    49 	 * @return label specified by the SQL AS clause
    50 	 */
    51 	public String getLabel() {
    52 		return label;
    53 	}
    54 
    55 	public void setLabel(String label) {
    56 		this.label = label;
    57 	}
    58 
    59 	public int getType() {
    60 		return type;
    61 	}
    62 
    63 	public void setType(int type) {
    64 		this.type = type;
    65 	}
    66 
    67 	public String getTypeName() {
    68 		return typeName;
    69 	}
    70 
    71 	public void setTypeName(String typeName) {
    72 		this.typeName = typeName;
    73 	}
    74 
    75 	public boolean isFirstColumn() {
    76 		return firstColumn;
    77 	}
    78 
    79 	public void setFirstColumn(boolean firstColumn) {
    80 		this.firstColumn = firstColumn;
    81 	}
    82 
    83 	public boolean isLastColumn() {
    84 		return lastColumn;
    85 	}
    86 
    87 	public void setLastColumn(boolean lastColumn) {
    88 		this.lastColumn = lastColumn;
    89 	}
    90 
    91 	/**
    92 	 * @return number of this column, 1 = first
    93 	 */
    94 	public int getColumnNumber() {
    95 		return columnNumber;
    96 	}
    97 
    98 	public void setColumnNumber(int columnNumber) {
    99 		this.columnNumber = columnNumber;
   100 	}
   101 
   102 	public String getTableName() {
   103 		return tableName;
   104 	}
   105 
   106 	public void setTableName(String tableName) {
   107 		this.tableName = tableName;
   108 	}
   109 
   110 	public boolean isBoolean() {
   111 		return type == Types.BOOLEAN;
   112 	}
   113 
   114 	public boolean isNumeric() {
   115 		switch (type) {
   116 			case Types.BIGINT:
   117 			case Types.DECIMAL:
   118 			case Types.DOUBLE:
   119 			case Types.FLOAT:
   120 			case Types.INTEGER:
   121 			case Types.NUMERIC:
   122 			case Types.REAL:
   123 			case Types.SMALLINT:
   124 			case Types.TINYINT:
   125 				return true;
   126 			default:
   127 				return false;
   128 		}
   129 	}
   130 }