Coverage Summary for Class: ConnectionTypes (net.sf.persism)
Class |
Class, %
|
Method, %
|
Line, %
|
ConnectionTypes |
100%
(1/1)
|
100%
(7/7)
|
91.7%
(44/48)
|
1 package net.sf.persism;
2
3 enum ConnectionTypes {
4 Oracle("%", "\"", "\""),
5
6 MSSQL(null, "[", "]"),
7
8 @Deprecated
9 JTDS(null, "[", "]"),
10
11 Derby(null, "\"", "\""),
12
13 H2(null, "\"", "\""),
14
15 MySQL(null, "`", "`"),
16
17 PostgreSQL(null, "\"", "\""),
18
19 SQLite(null, "[", "]"),
20
21 Firebird(null, "\"", "\""),
22
23 HSQLDB(null, "", ""),
24
25 UCanAccess(null, "[", "]"),
26
27 Informix(null, "", ""),
28
29 Other(null, "", "")
30 ;
31
32 private final String schemaPattern;
33 private final String keywordStartDelimiter;
34 private final String keywordEndDelimiter;
35
36 ConnectionTypes(String schemaPattern, String keywordStartDelimiter, String keywordEndDelimiter) {
37 this.schemaPattern = schemaPattern;
38 this.keywordStartDelimiter = keywordStartDelimiter;
39 this.keywordEndDelimiter = keywordEndDelimiter;
40 }
41
42 public static ConnectionTypes get(String connectionUrl) {
43 if (connectionUrl == null) {
44 return null;
45 }
46
47 if (connectionUrl.startsWith("jdbc:h2")) {
48 return H2;
49 }
50
51 if (connectionUrl.startsWith("jdbc:jtds")) {
52 return JTDS;
53 }
54
55 if (connectionUrl.startsWith("jdbc:sqlserver")) {
56 return MSSQL;
57 }
58
59 if (connectionUrl.startsWith("jdbc:oracle")) {
60 return Oracle;
61 }
62
63 if (connectionUrl.startsWith("jdbc:sqlite")) {
64 return SQLite;
65 }
66
67 if (connectionUrl.startsWith("jdbc:derby")) {
68 return Derby;
69 }
70
71 if (connectionUrl.startsWith("jdbc:mysql")) {
72 return MySQL;
73 }
74
75 if (connectionUrl.startsWith("jdbc:postgresql")) {
76 return PostgreSQL;
77 }
78
79 if (connectionUrl.startsWith("jdbc:firebirdsql")) {
80 return Firebird;
81 }
82
83 if (connectionUrl.startsWith("jdbc:hsqldb")) {
84 return HSQLDB;
85 }
86
87 if (connectionUrl.startsWith("jdbc:ucanaccess")) {
88 return UCanAccess;
89 }
90
91 if (connectionUrl.startsWith("jdbc:informix")) {
92 return Informix;
93 }
94
95 return Other;
96 }
97
98 public String getSchemaPattern() {
99 return schemaPattern;
100 }
101
102 public String getKeywordStartDelimiter() {
103 return keywordStartDelimiter;
104 }
105
106 public String getKeywordEndDelimiter() {
107 return keywordEndDelimiter;
108 }
109 }