-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathColumn.java
More file actions
94 lines (69 loc) · 2.21 KB
/
Column.java
File metadata and controls
94 lines (69 loc) · 2.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
package javaxt.sql;
//******************************************************************************
//** Column Class
//******************************************************************************
/**
* Used to represent a column in a table.
*
******************************************************************************/
public class Column {
private String Name;
private String Description;
private String Type;
private String Length;
private String IsRequired;
private boolean isPrimaryKey = false;
private boolean isForeignKey = false;
private Table Table;
private Key ForeignKey;
protected Column(java.sql.ResultSet rs, Table table) throws Exception {
this.Name = rs.getString("COLUMN_NAME");
this.Type = rs.getString("TYPE_NAME"); ////DATA_TYPE?
this.Length = rs.getString("COLUMN_SIZE");
this.Description = rs.getString("REMARKS");
this.IsRequired = rs.getString("IS_NULLABLE");
this.Table = table;
}
public String getName(){return Name;}
public String getType(){return Type;}
public Table getTable(){return Table;}
public String getDescription(){
if (Description==null) return "";
else return Description;
}
public int getLength(){
if (Length==null) return 0;
else return Integer.valueOf(Length).intValue();
}
public boolean isRequired(){
if (IsRequired==null) return true;
else{
IsRequired = IsRequired.trim();
if (IsRequired.equalsIgnoreCase("NO")){
return true;
}
else{
return false;
}
}
}
public boolean isPrimaryKey(){
return isPrimaryKey;
}
protected void setIsPrimaryKey(boolean isPrimaryKey){
this.isPrimaryKey = isPrimaryKey;
}
public boolean isForeignKey(){
return isForeignKey;
}
protected void setForeignKey(Key key){
this.ForeignKey = key;
this.isForeignKey = true;
}
public Key getForeignKey(){
return ForeignKey;
}
public String toString(){
return Table.getName() + "." + Name;
}
}