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