1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package net.sourceforge.addam.ddlgen.generic;
20
21 import java.util.ArrayList;
22 import java.util.List;
23
24 /**
25 * User: mkrishna
26 * Date: Nov 15, 2004
27 */
28
29 public class TableColumn {
30 private String name;
31 private String type;
32 private String size;
33 private static List includeInPrecision = new ArrayList();
34 private static List excludeInSize = new ArrayList();
35 private String precision;
36 private String defaultValue;
37
38 static {
39 includeInPrecision.add("NUMBER");
40 excludeInSize.add("DATE");
41 excludeInSize.add("LONG RAW");
42 excludeInSize.add("BLOB");
43 excludeInSize.add("datetime");
44 excludeInSize.add("int");
45 excludeInSize.add("bigint");
46 excludeInSize.add("image");
47 excludeInSize.add("bit");
48 }
49
50 public TableColumn(String name, String type, String size, String precision, String defaultValue) {
51 this.name = name;
52 this.type = type;
53 this.size = size;
54 this.precision = precision;
55 this.defaultValue = defaultValue;
56 }
57
58 public String getName() {
59 return name;
60 }
61
62 public String getTab() {
63 return getSpaces(50 - name.length());
64 }
65
66 public String getDefaultValue() {
67 return defaultValue;
68 }
69
70 private String getSpaces(int numberOfSpaces) {
71 String spaces = "";
72 for (int i = 0; i < numberOfSpaces; i++) {
73 spaces += " ";
74 }
75 return spaces;
76 }
77
78 public String getDescription() {
79 if (includeInPrecision.contains(type)) {
80 return type + "(" + size + "," + precision + ")";
81 } else if (excludeInSize.contains(type)) {
82 return type;
83 } else
84 return type + "(" + size + ")";
85 }
86 }