1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package jdbcadmin.core.data;
21
22 import java.io.Serializable;
23
24 import jdbcadmin.core.util.StringUtil;
25
26 /***
27 * Represents a table column.
28 */
29 public class Column implements Comparable, Serializable {
30
31
32 /*** Size of the buffer "name". */
33 private static final int BUFFER_SIZE_NAME = 25;
34 /*** Size of the buffer "type". */
35 private static final int BUFFER_SIZE_TYPE = 10;
36 /*** Size of the buffer "size". */
37 private static final int BUFFER_SIZE_SIZE = 4;
38 /*** Size of the buffer "nullable". */
39 private static final int BUFFER_SIZE_NULLABLE = 5;
40 /*** Size of the buffer "primary key". */
41 private static final int BUFFER_SIZE_PK = 5;
42
43
44 /*** Column name. */
45 private String name;
46 /*** Size of the column. */
47 private int size;
48 /*** Is NULL allowed. */
49 private boolean isNullable;
50 /*** Number of decimalDigits. */
51 private int decimalDigits;
52 /*** Database vendor type name. */
53 private String typeName;
54 /*** Type of the columns. */
55 private int type;
56
57
58
59 /*** {@inheritDoc} */
60 public String toString() {
61 StringBuffer buff = new StringBuffer();
62 StringUtil.append(buff, "NOM: <", ">", name, BUFFER_SIZE_NAME, " |", ' ');
63 StringUtil.append(buff, "TYPE: ", null, typeName, BUFFER_SIZE_TYPE, " |", ' ');
64 StringUtil.append(buff, "TAILLE: ", null, String.valueOf(size), BUFFER_SIZE_SIZE, " |", ' ');
65 StringUtil.append(buff, "NULL: ", null, String.valueOf(isNullable), BUFFER_SIZE_NULLABLE, " |", ' ');
66 StringUtil.append(buff, " DEC: ", null, String.valueOf(decimalDigits), BUFFER_SIZE_SIZE, " |", ' ');
67 return buff.toString();
68 }
69
70
71 /*** {@inheritDoc} */
72 public int compareTo(Object aObj) {
73 if (aObj instanceof Column) {
74 Column col = (Column) aObj;
75 return name.compareTo(col.getName());
76 } else {
77 throw new IllegalArgumentException("Impossible de comparer une Colonne avec un objet d'une autre classe");
78 }
79 }
80
81
82 /***
83 * @return Returns the decimalDigits.
84 */
85 public int getDecimalDigits() {
86 return decimalDigits;
87 }
88 /***
89 * @param aDecimalDigits The decimalDigits to set.
90 */
91 public void setDecimalDigits(int aDecimalDigits) {
92 decimalDigits = aDecimalDigits;
93 }
94 /***
95 * @return Returns the isNullable.
96 */
97 public boolean isNullable() {
98 return isNullable;
99 }
100 /***
101 * @param aIsNullable The isNullable to set.
102 */
103 public void setNullable(boolean aIsNullable) {
104 isNullable = aIsNullable;
105 }
106 /***
107 * @return Returns the name.
108 */
109 public String getName() {
110 return name;
111 }
112 /***
113 * @param aName The name to set.
114 */
115 public void setName(String aName) {
116 name = aName;
117 }
118 /***
119 * @return Returns the size.
120 */
121 public int getSize() {
122 return size;
123 }
124 /***
125 * @param aSize The size to set.
126 */
127 public void setSize(int aSize) {
128 size = aSize;
129 }
130 /***
131 * @return Returns the type.
132 */
133 public int getType() {
134 return type;
135 }
136 /***
137 * @param aType The type to set.
138 */
139 public void setType(int aType) {
140 type = aType;
141 }
142 /***
143 * @return Returns the typeName.
144 */
145 public String getTypeName() {
146 return typeName;
147 }
148 /***
149 * @param aTypeName The typeName to set.
150 */
151 public void setTypeName(String aTypeName) {
152 typeName = aTypeName;
153 }
154 }