blob: 4a1c32f4cbf7eefa4d09ca313f0632ecc717edc1 (
plain)
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
|
package com.redstoner.misc.mysql.types;
import com.redstoner.misc.mysql.types.date.*;
import com.redstoner.misc.mysql.types.number.Double;
import com.redstoner.misc.mysql.types.number.Float;
import com.redstoner.misc.mysql.types.number.*;
import com.redstoner.misc.mysql.types.text.Enum;
import com.redstoner.misc.mysql.types.text.*;
public abstract class MysqlType {
public static MysqlType getTypeFromString(String type) {
String[] splitType = type.split("\\(");
String toSwitch = splitType[0].toUpperCase();
String value = "";
if (type.contains("(") && type.endsWith(")")) {
value = splitType[1].substring(0, splitType[1].length() - 1);
}
switch (toSwitch) {
case "CHAR":
return new Char(Integer.valueOf(value));
case "ENUM":
return new Enum(value.replaceAll("'", "").split(","));
case "VARCHAR":
return new VarChar(Integer.valueOf(value));
case "SET":
return new Set(value.replaceAll("'", "").split(","));
case "BLOB":
return new Blob();
case "TEXT":
return new Text();
case "MEDIUMBLOB":
return new MediumBlob();
case "LONGBLOB":
return new LongBlob();
case "TINYTEXT":
return new TinyText();
case "MEDIUMTEXT":
return new MediumText();
case "LONGTEXT":
return new LongText();
case "INT":
return new Int(Integer.valueOf(value));
case "TINYINT":
return new TinyInt(Integer.valueOf(value));
case "SMALLINT":
return new SmallInt(Integer.valueOf(value));
case "MEDIUMINT":
return new MediumInt(Integer.valueOf(value));
case "BIGINT":
return new BigInt(Integer.valueOf(value));
case "BIT":
return new TinyInt(1);
case "FLOAT":
return new Float();
case "DOUBLE":
return new Double();
case "DECIMAL":
return new Decimal();
case "DATE":
return new Date();
case "DATETIME":
return new DateTime();
case "TIME":
return new Time();
case "TIMESTAMP":
return new TimeStamp();
case "YEAR":
return new Year();
}
return null;
}
public abstract String getName();
}
|