java/sql-dk/src/main/java/info/globalcode/sql/dk/formatting/ColumnDescriptor.java
author František Kučera <franta-hg@frantovo.cz>
Tue, 05 Mar 2019 21:22:33 +0100
branchv_0
changeset 245 b6ff5b7a8422
parent 238 4a1864c3e867
child 250 aae5009bd0af
permissions -rw-r--r--
sqldk-relpipe convergence started
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
d8faf91519a5 formatter: ColumnDescriptor
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     7
 * the Free Software Foundation, either version 3 of the License, or
d8faf91519a5 formatter: ColumnDescriptor
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     8
 * (at your option) any later version.
d8faf91519a5 formatter: ColumnDescriptor
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     9
 *
d8faf91519a5 formatter: ColumnDescriptor
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    10
 * 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
    11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
d8faf91519a5 formatter: ColumnDescriptor
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
d8faf91519a5 formatter: ColumnDescriptor
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    13
 * GNU General Public License for more details.
d8faf91519a5 formatter: ColumnDescriptor
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    14
 *
d8faf91519a5 formatter: ColumnDescriptor
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    15
 * 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
    16
 * 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
    17
 */
d8faf91519a5 formatter: ColumnDescriptor
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    18
package info.globalcode.sql.dk.formatting;
d8faf91519a5 formatter: ColumnDescriptor
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    19
174
3c6d560a1d14 TeXFormatter: first version
František Kučera <franta-hg@frantovo.cz>
parents: 39
diff changeset
    20
import java.sql.Types;
3c6d560a1d14 TeXFormatter: first version
František Kučera <franta-hg@frantovo.cz>
parents: 39
diff changeset
    21
23
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
 *
d8faf91519a5 formatter: ColumnDescriptor
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    24
 * @author Ing. František Kučera (frantovo.cz)
d8faf91519a5 formatter: ColumnDescriptor
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    25
 */
d8faf91519a5 formatter: ColumnDescriptor
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    26
public class ColumnDescriptor {
d8faf91519a5 formatter: ColumnDescriptor
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    27
d8faf91519a5 formatter: ColumnDescriptor
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    28
	private String name;
d8faf91519a5 formatter: ColumnDescriptor
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    29
	private String label;
d8faf91519a5 formatter: ColumnDescriptor
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    30
	private int type;
d8faf91519a5 formatter: ColumnDescriptor
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    31
	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
    32
	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
    33
	private boolean lastColumn;
39
be8db46a38c3 TabularFormatter: basic column padding
František Kučera <franta-hg@frantovo.cz>
parents: 37
diff changeset
    34
	private int columnNumber;
245
b6ff5b7a8422 sqldk-relpipe convergence started
František Kučera <franta-hg@frantovo.cz>
parents: 238
diff changeset
    35
	private String tableName;
23
d8faf91519a5 formatter: ColumnDescriptor
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    36
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
    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
    38
	 * @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
    39
	 * @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
    40
	 */
23
d8faf91519a5 formatter: ColumnDescriptor
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    41
	public String getName() {
d8faf91519a5 formatter: ColumnDescriptor
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    42
		return name;
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
d8faf91519a5 formatter: ColumnDescriptor
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    45
	public void setName(String name) {
d8faf91519a5 formatter: ColumnDescriptor
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    46
		this.name = name;
d8faf91519a5 formatter: ColumnDescriptor
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    47
	}
d8faf91519a5 formatter: ColumnDescriptor
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    48
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
    49
	/**
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
	 * @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
    51
	 */
23
d8faf91519a5 formatter: ColumnDescriptor
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    52
	public String getLabel() {
d8faf91519a5 formatter: ColumnDescriptor
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    53
		return label;
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
d8faf91519a5 formatter: ColumnDescriptor
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    56
	public void setLabel(String label) {
d8faf91519a5 formatter: ColumnDescriptor
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    57
		this.label = label;
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
d8faf91519a5 formatter: ColumnDescriptor
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    60
	public int getType() {
d8faf91519a5 formatter: ColumnDescriptor
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    61
		return type;
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
d8faf91519a5 formatter: ColumnDescriptor
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    64
	public void setType(int type) {
d8faf91519a5 formatter: ColumnDescriptor
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    65
		this.type = type;
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
d8faf91519a5 formatter: ColumnDescriptor
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    68
	public String getTypeName() {
d8faf91519a5 formatter: ColumnDescriptor
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    69
		return typeName;
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
d8faf91519a5 formatter: ColumnDescriptor
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    72
	public void setTypeName(String typeName) {
d8faf91519a5 formatter: ColumnDescriptor
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    73
		this.typeName = typeName;
d8faf91519a5 formatter: ColumnDescriptor
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    74
	}
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
    75
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
	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
    77
		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
    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
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
	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
    81
		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
    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
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
	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
    85
		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
    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
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
	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
    89
		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
    90
	}
39
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
	/**
be8db46a38c3 TabularFormatter: basic column padding
František Kučera <franta-hg@frantovo.cz>
parents: 37
diff changeset
    93
	 * @return number of this column, 1 = first
be8db46a38c3 TabularFormatter: basic column padding
František Kučera <franta-hg@frantovo.cz>
parents: 37
diff changeset
    94
	 */
be8db46a38c3 TabularFormatter: basic column padding
František Kučera <franta-hg@frantovo.cz>
parents: 37
diff changeset
    95
	public int getColumnNumber() {
be8db46a38c3 TabularFormatter: basic column padding
František Kučera <franta-hg@frantovo.cz>
parents: 37
diff changeset
    96
		return columnNumber;
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
be8db46a38c3 TabularFormatter: basic column padding
František Kučera <franta-hg@frantovo.cz>
parents: 37
diff changeset
    99
	public void setColumnNumber(int columnNumber) {
be8db46a38c3 TabularFormatter: basic column padding
František Kučera <franta-hg@frantovo.cz>
parents: 37
diff changeset
   100
		this.columnNumber = columnNumber;
be8db46a38c3 TabularFormatter: basic column padding
František Kučera <franta-hg@frantovo.cz>
parents: 37
diff changeset
   101
	}
174
3c6d560a1d14 TeXFormatter: first version
František Kučera <franta-hg@frantovo.cz>
parents: 39
diff changeset
   102
245
b6ff5b7a8422 sqldk-relpipe convergence started
František Kučera <franta-hg@frantovo.cz>
parents: 238
diff changeset
   103
	public String getTableName() {
b6ff5b7a8422 sqldk-relpipe convergence started
František Kučera <franta-hg@frantovo.cz>
parents: 238
diff changeset
   104
		return tableName;
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
b6ff5b7a8422 sqldk-relpipe convergence started
František Kučera <franta-hg@frantovo.cz>
parents: 238
diff changeset
   107
	public void setTableName(String tableName) {
b6ff5b7a8422 sqldk-relpipe convergence started
František Kučera <franta-hg@frantovo.cz>
parents: 238
diff changeset
   108
		this.tableName = tableName;
b6ff5b7a8422 sqldk-relpipe convergence started
František Kučera <franta-hg@frantovo.cz>
parents: 238
diff changeset
   109
	}
b6ff5b7a8422 sqldk-relpipe convergence started
František Kučera <franta-hg@frantovo.cz>
parents: 238
diff changeset
   110
174
3c6d560a1d14 TeXFormatter: first version
František Kučera <franta-hg@frantovo.cz>
parents: 39
diff changeset
   111
	public boolean isBoolean() {
3c6d560a1d14 TeXFormatter: first version
František Kučera <franta-hg@frantovo.cz>
parents: 39
diff changeset
   112
		return type == Types.BOOLEAN;
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
3c6d560a1d14 TeXFormatter: first version
František Kučera <franta-hg@frantovo.cz>
parents: 39
diff changeset
   115
	public boolean isNumeric() {
3c6d560a1d14 TeXFormatter: first version
František Kučera <franta-hg@frantovo.cz>
parents: 39
diff changeset
   116
		switch (type) {
3c6d560a1d14 TeXFormatter: first version
František Kučera <franta-hg@frantovo.cz>
parents: 39
diff changeset
   117
			case Types.BIGINT:
3c6d560a1d14 TeXFormatter: first version
František Kučera <franta-hg@frantovo.cz>
parents: 39
diff changeset
   118
			case Types.DECIMAL:
3c6d560a1d14 TeXFormatter: first version
František Kučera <franta-hg@frantovo.cz>
parents: 39
diff changeset
   119
			case Types.DOUBLE:
3c6d560a1d14 TeXFormatter: first version
František Kučera <franta-hg@frantovo.cz>
parents: 39
diff changeset
   120
			case Types.FLOAT:
3c6d560a1d14 TeXFormatter: first version
František Kučera <franta-hg@frantovo.cz>
parents: 39
diff changeset
   121
			case Types.INTEGER:
3c6d560a1d14 TeXFormatter: first version
František Kučera <franta-hg@frantovo.cz>
parents: 39
diff changeset
   122
			case Types.NUMERIC:
3c6d560a1d14 TeXFormatter: first version
František Kučera <franta-hg@frantovo.cz>
parents: 39
diff changeset
   123
			case Types.REAL:
3c6d560a1d14 TeXFormatter: first version
František Kučera <franta-hg@frantovo.cz>
parents: 39
diff changeset
   124
			case Types.SMALLINT:
3c6d560a1d14 TeXFormatter: first version
František Kučera <franta-hg@frantovo.cz>
parents: 39
diff changeset
   125
			case Types.TINYINT:
3c6d560a1d14 TeXFormatter: first version
František Kučera <franta-hg@frantovo.cz>
parents: 39
diff changeset
   126
				return true;
3c6d560a1d14 TeXFormatter: first version
František Kučera <franta-hg@frantovo.cz>
parents: 39
diff changeset
   127
			default:
3c6d560a1d14 TeXFormatter: first version
František Kučera <franta-hg@frantovo.cz>
parents: 39
diff changeset
   128
				return false;
3c6d560a1d14 TeXFormatter: first version
František Kučera <franta-hg@frantovo.cz>
parents: 39
diff changeset
   129
		}
3c6d560a1d14 TeXFormatter: first version
František Kučera <franta-hg@frantovo.cz>
parents: 39
diff changeset
   130
	}
23
d8faf91519a5 formatter: ColumnDescriptor
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
   131
}