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 package org.utgenome.gwt.utgb.client.db.datatype;
27
28 import com.google.gwt.json.client.JSONString;
29 import com.google.gwt.json.client.JSONValue;
30
31
32 public abstract class DataTypeBase implements DataType
33 {
34 protected String name;
35 protected boolean isPrimaryKey = false;
36 protected boolean isNotNull = false;
37
38 public DataTypeBase(String name)
39 {
40 this.name = name;
41 }
42
43 public DataTypeBase(String name, boolean isPrimaryKey)
44 {
45 this.name = name;
46 this.isPrimaryKey = isPrimaryKey;
47 }
48
49
50 private DataTypeBase() {}
51
52 public DataTypeBase(String name, boolean isPrimaryKey, boolean isNotNull) {
53 this.name = name;
54 this.isPrimaryKey = isPrimaryKey;
55 this.isNotNull = isNotNull;
56 }
57
58 public String getName() {
59 return name;
60 }
61
62 public String toString(JSONValue value)
63 {
64 JSONString s = value.isString();
65 if(s != null)
66 return s.stringValue();
67 else
68 return value.toString();
69 }
70
71
72 public void setAsPrimaryKey()
73 {
74 this.isPrimaryKey = true;
75 }
76
77 public boolean isPrimaryKey()
78 {
79 return isPrimaryKey;
80 }
81
82 public void setNotNull()
83 {
84 this.isNotNull = true;
85 }
86 public boolean isNotNull()
87 {
88 return isNotNull;
89 }
90
91 }
92
93
94
95