|
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, either version 3 of the License, or |
|
8 * (at your option) any later version. |
|
9 * |
|
10 * This program is distributed in the hope that it will be useful, |
|
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 * GNU General Public License for more details. |
|
14 * |
|
15 * You should have received a copy of the GNU General Public License |
|
16 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
17 */ |
|
18 package info.globalcode.sql.dk.formatting; |
|
19 |
|
20 import java.sql.Types; |
|
21 |
|
22 /** |
|
23 * |
|
24 * @author Ing. František Kučera (frantovo.cz) |
|
25 */ |
|
26 public class ColumnDescriptor { |
|
27 |
|
28 private String name; |
|
29 private String label; |
|
30 private int type; |
|
31 private String typeName; |
|
32 private boolean firstColumn; |
|
33 private boolean lastColumn; |
|
34 private int columnNumber; |
|
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 boolean isBoolean() { |
|
103 return type == Types.BOOLEAN; |
|
104 } |
|
105 |
|
106 public boolean isNumeric() { |
|
107 switch (type) { |
|
108 case Types.BIGINT: |
|
109 case Types.DECIMAL: |
|
110 case Types.DOUBLE: |
|
111 case Types.FLOAT: |
|
112 case Types.INTEGER: |
|
113 case Types.NUMERIC: |
|
114 case Types.REAL: |
|
115 case Types.SMALLINT: |
|
116 case Types.TINYINT: |
|
117 return true; |
|
118 default: |
|
119 return false; |
|
120 } |
|
121 } |
|
122 } |